summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/CodeComplete.cpp
diff options
context:
space:
mode:
authorEric Liu <ioeric@google.com>2018-06-22 10:46:59 +0000
committerEric Liu <ioeric@google.com>2018-06-22 10:46:59 +0000
commit7ad1696900e6189f89688a346f6d954372748a33 (patch)
treebd2483a20c4882d97f8eadde0a1267aaceeb4b16 /clang-tools-extra/clangd/CodeComplete.cpp
parent6d448da1bef6ff485b1588136433ba5a58b2ccb0 (diff)
downloadbcm5719-llvm-7ad1696900e6189f89688a346f6d954372748a33.tar.gz
bcm5719-llvm-7ad1696900e6189f89688a346f6d954372748a33.zip
[clangd] Expose qualified symbol names in CompletionItem (C++ structure only, no json).
Summary: The qualified name can be used to match a completion item to its corresponding symbol. This can be useful for tools that measure code completion quality. Qualified names are not precise for identifying symbols; we need to figure out a better way to identify completion items. Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48425 llvm-svn: 335334
Diffstat (limited to 'clang-tools-extra/clangd/CodeComplete.cpp')
-rw-r--r--clang-tools-extra/clangd/CodeComplete.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp
index 31619398d17..647e02da728 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -19,6 +19,7 @@
//===---------------------------------------------------------------------===//
#include "CodeComplete.h"
+#include "AST.h"
#include "CodeCompletionStrings.h"
#include "Compiler.h"
#include "FuzzyMatch.h"
@@ -243,6 +244,8 @@ struct CompletionCandidate {
const IncludeInserter &Includes,
llvm::StringRef SemaDocComment) const {
assert(bool(SemaResult) == bool(SemaCCS));
+ assert(SemaResult || IndexResult);
+
CompletionItem I;
bool InsertingInclude = false; // Whether a new #include will be added.
if (SemaResult) {
@@ -253,8 +256,14 @@ struct CompletionCandidate {
I.filterText = Text;
I.documentation = formatDocumentation(*SemaCCS, SemaDocComment);
I.detail = getDetail(*SemaCCS);
+ if (SemaResult->Kind == CodeCompletionResult::RK_Declaration)
+ if (const auto *D = SemaResult->getDeclaration())
+ if (const auto *ND = llvm::dyn_cast<NamedDecl>(D))
+ I.SymbolScope = splitQualifiedName(printQualifiedName(*ND)).first;
}
if (IndexResult) {
+ if (I.SymbolScope.empty())
+ I.SymbolScope = IndexResult->Scope;
if (I.kind == CompletionItemKind::Missing)
I.kind = toCompletionItemKind(IndexResult->SymInfo.Kind);
// FIXME: reintroduce a way to show the index source for debugging.
OpenPOWER on IntegriCloud