[clang-tools-extra] [clangd] Correctly identify the next token after the completion point (PR #69153)

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 11 22:03:10 PST 2023


================
@@ -1491,6 +1491,46 @@ FuzzyFindRequest speculativeFuzzyFindRequestForCompletion(
   return CachedReq;
 }
 
+// This function is similar to Lexer::findNextToken(), but assumes
+// that the input SourceLocation is the completion point (which is
+// a case findNextToken() does not handle).
+std::optional<Token>
+findTokenAfterCompletionPoint(SourceLocation CompletionPoint,
+                              const SourceManager &SM,
+                              const LangOptions &LangOpts) {
+  SourceLocation Loc = CompletionPoint;
----------------
HighCommander4 wrote:

> do you think it's possible to make this function a static member of `Lexer` like `Lexer::findNextToken`? That way we might need a slight refactor to reuse some common logics.

I think this would be a good improvement, but I'd like to leave it to a follow-up patch, because it involves adding new public API to `clang/Lex/Lexer.h`, so it should probably be approved by a code owner of the Lexer component.

https://github.com/llvm/llvm-project/pull/69153


More information about the cfe-commits mailing list