[PATCH] D55994: [clangd] Check preceding char when completion triggers on ':' or '>'

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 2 07:26:30 PST 2019


ilya-biryukov added inline comments.


================
Comment at: clangd/ClangdLSPServer.cpp:811
+  if (Trigger == ">")
+    return (*Code)[*Offset - 2] != '-'; // trigger only on '->'.
+  if (Trigger == ":")
----------------
hokein wrote:
> Checking `Offset` is not always right for rare cases like (`bar:/*commment*/:`), a robust way is to use lexer and get the token at the current position, but I don't think it is worth (these rare cases should not happen when people write code). Maybe add a comment documenting the limitation?
Done. Note that `bar:/*comment*/:` is not actually a qualifier, i.e. a single token cannot be split in half by the comment.
But the comment is totally valid: use the lexer would allow to filter out more things, e.g. we don't want to auto-trigger inside a comment, etc.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55994/new/

https://reviews.llvm.org/D55994





More information about the cfe-commits mailing list