[PATCH] D48724: [clangd] Log sema completion context kind and query scopes. NFC
Eric Liu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 5 01:34:27 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE336321: [clangd] Log sema completion context kind and query scopes. NFC (authored by ioeric, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D48724?vs=154185&id=154186#toc
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D48724
Files:
clangd/CodeComplete.cpp
Index: clangd/CodeComplete.cpp
===================================================================
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -41,6 +41,7 @@
#include "clang/Sema/Sema.h"
#include "clang/Tooling/Core/Replacement.h"
#include "llvm/Support/Format.h"
+#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/ScopedPrinter.h"
#include <queue>
@@ -940,6 +941,7 @@
int NSema = 0, NIndex = 0, NBoth = 0; // Counters for logging.
bool Incomplete = false; // Would more be available with a higher limit?
llvm::Optional<FuzzyMatcher> Filter; // Initialized once Sema runs.
+ std::vector<std::string> QueryScopes; // Initialized once Sema runs.
// Include-insertion and proximity scoring rely on the include structure.
// This is available after Sema has run.
llvm::Optional<IncludeInserter> Inserter; // Available during runWithSema.
@@ -1001,6 +1003,10 @@
Inserter.reset(); // Make sure this doesn't out-live Clang.
SPAN_ATTACH(Tracer, "sema_completion_kind",
getCompletionKindString(Recorder->CCContext.getKind()));
+ log(llvm::formatv(
+ "Code complete: sema context {0}, query scopes [{1}]",
+ getCompletionKindString(Recorder->CCContext.getKind()),
+ llvm::join(QueryScopes.begin(), QueryScopes.end(), ",")));
});
Recorder = RecorderOwner.get();
@@ -1028,6 +1034,8 @@
CodeCompleteResult runWithSema() {
Filter = FuzzyMatcher(
Recorder->CCSema->getPreprocessor().getCodeCompletionFilter());
+ QueryScopes = getQueryScopes(Recorder->CCContext,
+ Recorder->CCSema->getSourceManager());
// Sema provides the needed context to query the index.
// FIXME: in addition to querying for extra/overlapping symbols, we should
// explicitly request symbols corresponding to Sema results.
@@ -1059,8 +1067,7 @@
Req.MaxCandidateCount = Opts.Limit;
Req.Query = Filter->pattern();
Req.RestrictForCodeCompletion = true;
- Req.Scopes = getQueryScopes(Recorder->CCContext,
- Recorder->CCSema->getSourceManager());
+ Req.Scopes = QueryScopes;
// FIXME: we should send multiple weighted paths here.
Req.ProximityPaths.push_back(FileName);
log(llvm::formatv("Code complete: fuzzyFind(\"{0}\", scopes=[{1}])",
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48724.154186.patch
Type: text/x-patch
Size: 2378 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180705/95d2720e/attachment-0001.bin>
More information about the cfe-commits
mailing list