[clangd] Expose whether no-compile completion was used.
Summary: Embedding clients want to experiment with showing such results in e.g. a different color. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61588 llvm-svn: 360039
This commit is contained in:
parent
4ce1c3c3ff
commit
8940f46880
|
@ -1380,6 +1380,7 @@ public:
|
|||
|
||||
CodeCompleteResult Output = toCodeCompleteResult(mergeResults(
|
||||
/*SemaResults=*/{}, IndexResults, IdentifierResults));
|
||||
Output.RanParser = false;
|
||||
logResults(Output, Tracer);
|
||||
return Output;
|
||||
}
|
||||
|
|
|
@ -207,6 +207,9 @@ struct CodeCompleteResult {
|
|||
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 &);
|
||||
|
||||
|
|
|
@ -235,6 +235,7 @@ void TestAfterDotCompletion(clangd::CodeCompleteOptions Opts) {
|
|||
)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 @@ void TestGlobalScopeCompletion(clangd::CodeCompleteOptions Opts) {
|
|||
)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 @@ TEST(NoCompileCompletionTest, Basic) {
|
|||
^
|
||||
}
|
||||
)cpp");
|
||||
EXPECT_FALSE(Results.RanParser);
|
||||
EXPECT_THAT(Results.Completions,
|
||||
UnorderedElementsAre(Named("void"), Named("func"), Named("int"),
|
||||
Named("xyz"), Named("abc")));
|
||||
|
|
Loading…
Reference in New Issue