[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 05:01:29 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE360039: [clangd] Expose whether no-compile completion was used. (authored by sammccall, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D61588?vs=198246&id=198251#toc
Repository:
rCTE Clang Tools Extra
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D61588/new/
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.198251.patch
Type: text/x-patch
Size: 2011 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190506/5ee628fa/attachment.bin>
More information about the cfe-commits
mailing list