[PATCH] D61588: [clangd] Expose whether no-compile completion was used.
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 6 03:41:35 PDT 2019
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.
Embedding clients want to experiment with showing such results in e.g. a different color.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D61588
Files:
clangd/CodeComplete.cpp
clangd/CodeComplete.h
clangd/unittests/CodeCompleteTests.cpp
Index: clangd/unittests/CodeCompleteTests.cpp
===================================================================
--- clangd/unittests/CodeCompleteTests.cpp
+++ clangd/unittests/CodeCompleteTests.cpp
@@ -235,6 +235,7 @@
)cpp",
{cls("IndexClass"), var("index_var"), func("index_func")}, Opts);
+ EXPECT_TRUE(Results.RanParser);
// Class members. The only items that must be present in after-dot
// completion.
EXPECT_THAT(Results.Completions,
@@ -284,6 +285,7 @@
)cpp",
{cls("IndexClass"), var("index_var"), func("index_func")}, Opts);
+ EXPECT_TRUE(Results.RanParser);
// Class members. Should never be present in global completions.
EXPECT_THAT(Results.Completions,
Not(AnyOf(Has("method"), Has("method()"), Has("field"))));
@@ -2459,6 +2461,7 @@
^
}
)cpp");
+ EXPECT_FALSE(Results.RanParser);
EXPECT_THAT(Results.Completions,
UnorderedElementsAre(Named("void"), Named("func"), Named("int"),
Named("xyz"), Named("abc")));
Index: clangd/CodeComplete.h
===================================================================
--- clangd/CodeComplete.h
+++ clangd/CodeComplete.h
@@ -207,6 +207,9 @@
std::vector<CodeCompletion> Completions;
bool HasMore = false;
CodeCompletionContext::Kind Context = CodeCompletionContext::CCC_Other;
+ // Usually the source will be parsed with a real C++ parser.
+ // But heuristics may be used instead if e.g. the preamble is not ready.
+ bool RanParser = true;
};
raw_ostream &operator<<(raw_ostream &, const CodeCompleteResult &);
Index: clangd/CodeComplete.cpp
===================================================================
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -1380,6 +1380,7 @@
CodeCompleteResult Output = toCodeCompleteResult(mergeResults(
/*SemaResults=*/{}, IndexResults, IdentifierResults));
+ Output.RanParser = false;
logResults(Output, Tracer);
return Output;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61588.198246.patch
Type: text/x-patch
Size: 2011 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190506/8a39d9f8/attachment-0001.bin>
More information about the cfe-commits
mailing list