diff options
Diffstat (limited to 'clangd/CodeComplete.cpp')
-rw-r--r-- | clangd/CodeComplete.cpp | 249 |
1 files changed, 127 insertions, 122 deletions
diff --git a/clangd/CodeComplete.cpp b/clangd/CodeComplete.cpp index 74b90bcf..7642ea9d 100644 --- a/clangd/CodeComplete.cpp +++ b/clangd/CodeComplete.cpp @@ -59,7 +59,6 @@ // We log detailed candidate here if you run with -debug-only=codecomplete. #define DEBUG_TYPE "CodeComplete" -using namespace llvm; namespace clang { namespace clangd { namespace { @@ -181,7 +180,8 @@ std::string getOptionalParameters(const CodeCompletionString &CCS, /// Creates a `HeaderFile` from \p Header which can be either a URI or a literal /// include. -static Expected<HeaderFile> toHeaderFile(StringRef Header, StringRef HintPath) { +static llvm::Expected<HeaderFile> toHeaderFile(llvm::StringRef Header, + llvm::StringRef HintPath) { if (isLiteralInclude(Header)) return HeaderFile{Header.str(), /*Verbatim=*/true}; auto U = URI::parse(Header); @@ -203,16 +203,16 @@ static Expected<HeaderFile> toHeaderFile(StringRef Header, StringRef HintPath) { /// A code completion result, in clang-native form. /// It may be promoted to a CompletionItem if it's among the top-ranked results. struct CompletionCandidate { - StringRef Name; // Used for filtering and sorting. + llvm::StringRef Name; // Used for filtering and sorting. // We may have a result from Sema, from the index, or both. const CodeCompletionResult *SemaResult = nullptr; const Symbol *IndexResult = nullptr; - SmallVector<StringRef, 1> RankedIncludeHeaders; + llvm::SmallVector<llvm::StringRef, 1> RankedIncludeHeaders; // Returns a token identifying the overload set this is part of. // 0 indicates it's not part of any overload set. size_t overloadSet() const { - SmallString<256> Scratch; + llvm::SmallString<256> Scratch; if (IndexResult) { switch (IndexResult->SymInfo.Kind) { case index::SymbolKind::ClassMethod: @@ -226,7 +226,7 @@ struct CompletionCandidate { case index::SymbolKind::Function: // We can't group overloads together that need different #includes. // This could break #include insertion. - return hash_combine( + return llvm::hash_combine( (IndexResult->Scope + IndexResult->Name).toStringRef(Scratch), headerToInsertIfAllowed().getValueOr("")); default: @@ -239,14 +239,15 @@ struct CompletionCandidate { if (!D || !D->isFunctionOrFunctionTemplate()) return 0; { - raw_svector_ostream OS(Scratch); + llvm::raw_svector_ostream OS(Scratch); D->printQualifiedName(OS); } - return hash_combine(Scratch, headerToInsertIfAllowed().getValueOr("")); + return llvm::hash_combine(Scratch, + headerToInsertIfAllowed().getValueOr("")); } // The best header to include if include insertion is allowed. - Optional<StringRef> headerToInsertIfAllowed() const { + llvm::Optional<llvm::StringRef> headerToInsertIfAllowed() const { if (RankedIncludeHeaders.empty()) return None; if (SemaResult && SemaResult->Declaration) { @@ -260,7 +261,7 @@ struct CompletionCandidate { return RankedIncludeHeaders[0]; } - using Bundle = SmallVector<CompletionCandidate, 4>; + using Bundle = llvm::SmallVector<CompletionCandidate, 4>; }; using ScoredBundle = std::pair<CompletionCandidate::Bundle, CodeCompletion::Scores>; @@ -283,8 +284,9 @@ struct ScoredBundleGreater { struct CodeCompletionBuilder { CodeCompletionBuilder(ASTContext &ASTCtx, const CompletionCandidate &C, CodeCompletionString *SemaCCS, - ArrayRef<std::string> QueryScopes, - const IncludeInserter &Includes, StringRef FileName, + llvm::ArrayRef<std::string> QueryScopes, + const IncludeInserter &Includes, + llvm::StringRef FileName, CodeCompletionContext::Kind ContextKind, const CodeCompleteOptions &Opts) : ASTCtx(ASTCtx), ExtractDocumentation(Opts.IncludeComments), @@ -292,7 +294,7 @@ struct CodeCompletionBuilder { add(C, SemaCCS); if (C.SemaResult) { Completion.Origin |= SymbolOrigin::AST; - Completion.Name = StringRef(SemaCCS->getTypedText()); + Completion.Name = llvm::StringRef(SemaCCS->getTypedText()); if (Completion.Scope.empty()) { if ((C.SemaResult->Kind == CodeCompletionResult::RK_Declaration) || (C.SemaResult->Kind == CodeCompletionResult::RK_Pattern)) @@ -330,9 +332,9 @@ struct CodeCompletionBuilder { // If the completion was visible to Sema, no qualifier is needed. This // avoids unneeded qualifiers in cases like with `using ns::X`. if (Completion.RequiredQualifier.empty() && !C.SemaResult) { - StringRef ShortestQualifier = C.IndexResult->Scope; - for (StringRef Scope : QueryScopes) { - StringRef Qualifier = C.IndexResult->Scope; + llvm::StringRef ShortestQualifier = C.IndexResult->Scope; + for (llvm::StringRef Scope : QueryScopes) { + llvm::StringRef Qualifier = C.IndexResult->Scope; if (Qualifier.consume_front(Scope) && Qualifier.size() < ShortestQualifier.size()) ShortestQualifier = Qualifier; @@ -343,8 +345,8 @@ struct CodeCompletionBuilder { } // Turn absolute path into a literal string that can be #included. - auto Inserted = - [&](StringRef Header) -> Expected<std::pair<std::string, bool>> { + auto Inserted = [&](llvm::StringRef Header) + -> llvm::Expected<std::pair<std::string, bool>> { auto ResolvedDeclaring = toHeaderFile(C.IndexResult->CanonicalDeclaration.FileURI, FileName); if (!ResolvedDeclaring) @@ -462,7 +464,7 @@ private: // foo<${1:class}>(${2:int p1}). // We transform this pattern to '<$1>()$0' or '<$0>()'. - bool EmptyArgs = StringRef(*Snippet).endswith("()"); + bool EmptyArgs = llvm::StringRef(*Snippet).endswith("()"); if (Snippet->front() == '<') return EmptyArgs ? "<$1>()$0" : "<$1>($0)"; if (Snippet->front() == '(') @@ -476,7 +478,7 @@ private: // Classes and template using aliases can only have template arguments, // e.g. Foo<${1:class}>. - if (StringRef(*Snippet).endswith("<>")) + if (llvm::StringRef(*Snippet).endswith("<>")) return "<>"; // can happen with defaulted template arguments. return "<$0>"; } @@ -492,14 +494,14 @@ private: ASTContext &ASTCtx; CodeCompletion Completion; - SmallVector<BundledEntry, 1> Bundled; + llvm::SmallVector<BundledEntry, 1> Bundled; bool ExtractDocumentation; bool EnableFunctionArgSnippets; }; // Determine the symbol ID for a Sema code completion result, if possible. -Optional<SymbolID> getSymbolID(const CodeCompletionResult &R, - const SourceManager &SM) { +llvm::Optional<SymbolID> getSymbolID(const CodeCompletionResult &R, + const SourceManager &SM) { switch (R.Kind) { case CodeCompletionResult::RK_Declaration: case CodeCompletionResult::RK_Pattern: { @@ -539,13 +541,13 @@ struct SpecifiedScope { std::vector<std::string> AccessibleScopes; // The full scope qualifier as typed by the user (without the leading "::"). // Set if the qualifier is not fully resolved by Sema. - Optional<std::string> UnresolvedQualifier; + llvm::Optional<std::string> UnresolvedQualifier; // Construct scopes being queried in indexes. The results are deduplicated. // This method format the scopes to match the index request representation. std::vector<std::string> scopesForIndexQuery() { std::set<std::string> Results; - for (StringRef AS : AccessibleScopes) + for (llvm::StringRef AS : AccessibleScopes) Results.insert( ((UnresolvedQualifier ? *UnresolvedQualifier : "") + AS).str()); return {Results.begin(), Results.end()}; @@ -688,7 +690,7 @@ static bool isBlacklistedMember(const NamedDecl &D) { // within the callback. struct CompletionRecorder : public CodeCompleteConsumer { CompletionRecorder(const CodeCompleteOptions &Opts, - unique_function<void()> ResultsCallback) + llvm::unique_function<void()> ResultsCallback) : CodeCompleteConsumer(Opts.getClangCompleteOpts(), /*OutputIsBinary=*/false), CCContext(CodeCompletionContext::CCC_Other), Opts(Opts), @@ -766,7 +768,7 @@ struct CompletionRecorder : public CodeCompleteConsumer { // Returns the filtering/sorting name for Result, which must be from Results. // Returned string is owned by this recorder (or the AST). - StringRef getName(const CodeCompletionResult &Result) { + llvm::StringRef getName(const CodeCompletionResult &Result) { switch (Result.Kind) { case CodeCompletionResult::RK_Declaration: if (auto *ID = Result.Declaration->getIdentifier()) @@ -796,13 +798,13 @@ private: CodeCompleteOptions Opts; std::shared_ptr<GlobalCodeCompletionAllocator> CCAllocator; CodeCompletionTUInfo CCTUInfo; - unique_function<void()> ResultsCallback; + llvm::unique_function<void()> ResultsCallback; }; struct ScoredSignature { // When set, requires documentation to be requested from the index with this // ID. - Optional<SymbolID> IDForDoc; + llvm::Optional<SymbolID> IDForDoc; SignatureInformation Signature; SignatureQualitySignals Quality; }; @@ -862,7 +864,7 @@ public: // Sema does not load the docs from the preamble, so we need to fetch extra // docs from the index instead. - DenseMap<SymbolID, std::string> FetchedDocs; + llvm::DenseMap<SymbolID, std::string> FetchedDocs; if (Index) { LookupRequest IndexRequest; for (const auto &S : ScoredSignatures) { @@ -879,38 +881,37 @@ public: IndexRequest.IDs.size(), FetchedDocs.size()); } - llvm::sort( - ScoredSignatures, - [](const ScoredSignature &L, const ScoredSignature &R) { - // Ordering follows: - // - Less number of parameters is better. - // - Function is better than FunctionType which is better than - // Function Template. - // - High score is better. - // - Shorter signature is better. - // - Alphebatically smaller is better. - if (L.Quality.NumberOfParameters != R.Quality.NumberOfParameters) - return L.Quality.NumberOfParameters < R.Quality.NumberOfParameters; - if (L.Quality.NumberOfOptionalParameters != - R.Quality.NumberOfOptionalParameters) - return L.Quality.NumberOfOptionalParameters < - R.Quality.NumberOfOptionalParameters; - if (L.Quality.Kind != R.Quality.Kind) { - using OC = CodeCompleteConsumer::OverloadCandidate; - switch (L.Quality.Kind) { - case OC::CK_Function: - return true; - case OC::CK_FunctionType: - return R.Quality.Kind != OC::CK_Function; - case OC::CK_FunctionTemplate: - return false; - } - llvm_unreachable("Unknown overload candidate type."); - } - if (L.Signature.label.size() != R.Signature.label.size()) - return L.Signature.label.size() < R.Signature.label.size(); - return L.Signature.label < R.Signature.label; - }); + llvm::sort(ScoredSignatures, [](const ScoredSignature &L, + const ScoredSignature &R) { + // Ordering follows: + // - Less number of parameters is better. + // - Function is better than FunctionType which is better than + // Function Template. + // - High score is better. + // - Shorter signature is better. + // - Alphebatically smaller is better. + if (L.Quality.NumberOfParameters != R.Quality.NumberOfParameters) + return L.Quality.NumberOfParameters < R.Quality.NumberOfParameters; + if (L.Quality.NumberOfOptionalParameters != + R.Quality.NumberOfOptionalParameters) + return L.Quality.NumberOfOptionalParameters < + R.Quality.NumberOfOptionalParameters; + if (L.Quality.Kind != R.Quality.Kind) { + using OC = CodeCompleteConsumer::OverloadCandidate; + switch (L.Quality.Kind) { + case OC::CK_Function: + return true; + case OC::CK_FunctionType: + return R.Quality.Kind != OC::CK_Function; + case OC::CK_FunctionTemplate: + return false; + } + llvm_unreachable("Unknown overload candidate type."); + } + if (L.Signature.label.size() != R.Signature.label.size()) + return L.Signature.label.size() < R.Signature.label.size(); + return L.Signature.label < R.Signature.label; + }); for (auto &SS : ScoredSignatures) { auto IndexDocIt = @@ -931,7 +932,7 @@ private: // CompletionString.h. ScoredSignature processOverloadCandidate(const OverloadCandidate &Candidate, const CodeCompletionString &CCS, - StringRef DocComment) const { + llvm::StringRef DocComment) const { SignatureInformation Signature; SignatureQualitySignals Signal; const char *ReturnType = nullptr; @@ -1003,9 +1004,9 @@ struct SemaCompleteInput { PathRef FileName; const tooling::CompileCommand &Command; const PreambleData *Preamble; - StringRef Contents; + llvm::StringRef Contents; Position Pos; - IntrusiveRefCntPtr<vfs::FileSystem> VFS; + llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS; std::shared_ptr<PCHContainerOperations> PCHs; }; @@ -1026,7 +1027,7 @@ bool semaCodeComplete(std::unique_ptr<CodeCompleteConsumer> Consumer, // working dirs. } - IntrusiveRefCntPtr<vfs::FileSystem> VFS = Input.VFS; + llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = Input.VFS; if (Input.Preamble && Input.Preamble->StatCache) VFS = Input.Preamble->StatCache->getConsumingFS(std::move(VFS)); IgnoreDiagnostics DummyDiagsConsumer; @@ -1057,8 +1058,8 @@ bool semaCodeComplete(std::unique_ptr<CodeCompleteConsumer> Consumer, FrontendOpts.CodeCompletionAt.Column) = offsetToClangLineColumn(Input.Contents, *Offset); - std::unique_ptr<MemoryBuffer> ContentsBuffer = - MemoryBuffer::getMemBufferCopy(Input.Contents, Input.FileName); + std::unique_ptr<llvm::MemoryBuffer> ContentsBuffer = + llvm::MemoryBuffer::getMemBufferCopy(Input.Contents, Input.FileName); // The diagnostic options must be set before creating a CompilerInstance. CI->getDiagnosticOpts().IgnoreWarnings = true; // We reuse the preamble whether it's valid or not. This is a @@ -1140,8 +1141,10 @@ std::future<SymbolSlab> startAsyncFuzzyFind(const SymbolIndex &Index, // Creates a `FuzzyFindRequest` based on the cached index request from the // last completion, if any, and the speculated completion filter text in the // source code. -Optional<FuzzyFindRequest> speculativeFuzzyFindRequestForCompletion( - FuzzyFindRequest CachedReq, PathRef File, StringRef Content, Position Pos) { +llvm::Optional<FuzzyFindRequest> +speculativeFuzzyFindRequestForCompletion(FuzzyFindRequest CachedReq, + PathRef File, llvm::StringRef Content, + Position Pos) { auto Filter = speculateCompletionFilter(Content, Pos); if (!Filter) { elog("Failed to speculate filter text for code completion at Pos " @@ -1153,32 +1156,10 @@ Optional<FuzzyFindRequest> speculativeFuzzyFindRequestForCompletion( return CachedReq; } -} // namespace - -clang::CodeCompleteOptions CodeCompleteOptions::getClangCompleteOpts() const { - clang::CodeCompleteOptions Result; - Result.IncludeCodePatterns = EnableSnippets && IncludeCodePatterns; - Result.IncludeMacros = IncludeMacros; - Result.IncludeGlobals = true; - // We choose to include full comments and not do doxygen parsing in - // completion. - // FIXME: ideally, we should support doxygen in some form, e.g. do markdown - // formatting of the comments. - Result.IncludeBriefComments = false; - - // When an is used, Sema is responsible for completing the main file, - // the index can provide results from the preamble. - // Tell Sema not to deserialize the preamble to look for results. - Result.LoadExternal = !Index; - Result.IncludeFixIts = IncludeFixIts; - - return Result; -} - // Returns the most popular include header for \p Sym. If two headers are // equally popular, prefer the shorter one. Returns empty string if \p Sym has // no include header. -SmallVector<StringRef, 1> getRankedIncludes(const Symbol &Sym) { +llvm::SmallVector<llvm::StringRef, 1> getRankedIncludes(const Symbol &Sym) { auto Includes = Sym.IncludeHeaders; // Sort in descending order by reference count and header length. llvm::sort(Includes, [](const Symbol::IncludeHeaderWithReferences &LHS, @@ -1187,7 +1168,7 @@ SmallVector<StringRef, 1> getRankedIncludes(const Symbol &Sym) { return LHS.IncludeHeader.size() < RHS.IncludeHeader.size(); return LHS.References > RHS.References; }); - SmallVector<StringRef, 1> Headers; + llvm::SmallVector<llvm::StringRef, 1> Headers; for (const auto &Include : Includes) Headers.push_back(Include.IncludeHeader); return Headers; @@ -1224,30 +1205,30 @@ SmallVector<StringRef, 1> getRankedIncludes(const Symbol &Sym) { // - TopN determines the results with the best score. class CodeCompleteFlow { PathRef FileName; - IncludeStructure Includes; // Complete once the compiler runs. + IncludeStructure Includes; // Complete once the compiler runs. SpeculativeFuzzyFind *SpecFuzzyFind; // Can be nullptr. const CodeCompleteOptions &Opts; // Sema takes ownership of Recorder. Recorder is valid until Sema cleanup. CompletionRecorder *Recorder = nullptr; int NSema = 0, NIndex = 0, NBoth = 0; // Counters for logging. - bool Incomplete = false; // Would more be available with a higher limit? - Optional<FuzzyMatcher> Filter; // Initialized once Sema runs. + 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. // Initialized once QueryScopes is initialized, if there are scopes. - Optional<ScopeDistance> ScopeProximity; + llvm::Optional<ScopeDistance> ScopeProximity; llvm::Optional<OpaqueType> PreferredType; // Initialized once Sema runs. // Whether to query symbols from any scope. Initialized once Sema runs. bool AllScopes = false; // Include-insertion and proximity scoring rely on the include structure. // This is available after Sema has run. - Optional<IncludeInserter> Inserter; // Available during runWithSema. - Optional<URIDistance> FileProximity; // Initialized once Sema runs. + llvm::Optional<IncludeInserter> Inserter; // Available during runWithSema. + llvm::Optional<URIDistance> FileProximity; // Initialized once Sema runs. /// Speculative request based on the cached request and the filter text before /// the cursor. /// Initialized right before sema run. This is only set if `SpecFuzzyFind` is /// set and contains a cached request. - Optional<FuzzyFindRequest> SpecReq; + llvm::Optional<FuzzyFindRequest> SpecReq; public: // A CodeCompleteFlow object is only useful for calling run() exactly once. @@ -1297,7 +1278,7 @@ public: // The per-result proximity scoring is (amortized) very cheap. FileDistanceOptions ProxOpts{}; // Use defaults. const auto &SM = Recorder->CCSema->getSourceManager(); - StringMap<SourceParams> ProxSources; + llvm::StringMap<SourceParams> ProxSources; for (auto &Entry : Includes.includeDepth( SM.getFileEntryForID(SM.getMainFileID())->getName())) { auto &Source = ProxSources[Entry.getKey()]; @@ -1317,7 +1298,7 @@ public: log("Code complete: sema context {0}, query scopes [{1}] (AnyScope={2}), " "expected type {3}", getCompletionKindString(Recorder->CCContext.getKind()), - join(QueryScopes.begin(), QueryScopes.end(), ","), AllScopes, + llvm::join(QueryScopes.begin(), QueryScopes.end(), ","), AllScopes, PreferredType ? Recorder->CCContext.getPreferredType().getAsString() : "<none>"); }); @@ -1442,7 +1423,7 @@ private: const SymbolSlab &IndexResults) { trace::Span Tracer("Merge and score results"); std::vector<CompletionCandidate::Bundle> Bundles; - DenseMap<size_t, size_t> BundleLookup; + llvm::DenseMap<size_t, size_t> BundleLookup; auto AddToBundles = [&](const CodeCompletionResult *SemaResult, const Symbol *IndexResult) { CompletionCandidate C; @@ -1461,7 +1442,7 @@ private: Bundles.back().push_back(std::move(C)); } }; - DenseSet<const Symbol *> UsedIndexResults; + llvm::DenseSet<const Symbol *> UsedIndexResults; auto CorrespondingIndexResult = [&](const CodeCompletionResult &SemaResult) -> const Symbol * { if (auto SymID = @@ -1491,7 +1472,7 @@ private: return std::move(Top).items(); } - Optional<float> fuzzyScore(const CompletionCandidate &C) { + llvm::Optional<float> fuzzyScore(const CompletionCandidate &C) { // Macros can be very spammy, so we only support prefix completion. // We won't end up with underfull index results, as macros are sema-only. if (C.SemaResult && C.SemaResult->Kind == CodeCompletionResult::RK_Macro && @@ -1558,8 +1539,8 @@ private: : Scores.Quality; dlog("CodeComplete: {0} ({1}) = {2}\n{3}{4}\n", First.Name, - to_string(Origin), Scores.Total, to_string(Quality), - to_string(Relevance)); + llvm::to_string(Origin), Scores.Total, llvm::to_string(Quality), + llvm::to_string(Relevance)); NSema += bool(Origin & SymbolOrigin::AST); NIndex += FromIndex; @@ -1569,7 +1550,7 @@ private: } CodeCompletion toCodeCompletion(const CompletionCandidate::Bundle &Bundle) { - Optional<CodeCompletionBuilder> Builder; + llvm::Optional<CodeCompletionBuilder> Builder; for (const auto &Item : Bundle) { CodeCompletionString *SemaCCS = Item.SemaResult ? Recorder->codeCompletionString(*Item.SemaResult) @@ -1585,12 +1566,35 @@ private: } }; -Expected<StringRef> speculateCompletionFilter(StringRef Content, Position Pos) { +} // namespace + +clang::CodeCompleteOptions CodeCompleteOptions::getClangCompleteOpts() const { + clang::CodeCompleteOptions Result; + Result.IncludeCodePatterns = EnableSnippets && IncludeCodePatterns; + Result.IncludeMacros = IncludeMacros; + Result.IncludeGlobals = true; + // We choose to include full comments and not do doxygen parsing in + // completion. + // FIXME: ideally, we should support doxygen in some form, e.g. do markdown + // formatting of the comments. + Result.IncludeBriefComments = false; + + // When an is used, Sema is responsible for completing the main file, + // the index can provide results from the preamble. + // Tell Sema not to deserialize the preamble to look for results. + Result.LoadExternal = !Index; + Result.IncludeFixIts = IncludeFixIts; + + return Result; +} + +llvm::Expected<llvm::StringRef> +speculateCompletionFilter(llvm::StringRef Content, Position Pos) { auto Offset = positionToOffset(Content, Pos); if (!Offset) - return make_error<StringError>( + return llvm::make_error<llvm::StringError>( "Failed to convert position to offset in content.", - inconvertibleErrorCode()); + llvm::inconvertibleErrorCode()); if (*Offset == 0) return ""; @@ -1611,8 +1615,8 @@ Expected<StringRef> speculateCompletionFilter(StringRef Content, Position Pos) { CodeCompleteResult codeComplete(PathRef FileName, const tooling::CompileCommand &Command, - const PreambleData *Preamble, StringRef Contents, Position Pos, - IntrusiveRefCntPtr<vfs::FileSystem> VFS, + const PreambleData *Preamble, llvm::StringRef Contents, + Position Pos, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, std::shared_ptr<PCHContainerOperations> PCHs, CodeCompleteOptions Opts, SpeculativeFuzzyFind *SpecFuzzyFind) { return CodeCompleteFlow(FileName, @@ -1623,9 +1627,9 @@ codeComplete(PathRef FileName, const tooling::CompileCommand &Command, SignatureHelp signatureHelp(PathRef FileName, const tooling::CompileCommand &Command, - const PreambleData *Preamble, StringRef Contents, - Position Pos, - IntrusiveRefCntPtr<vfs::FileSystem> VFS, + const PreambleData *Preamble, + llvm::StringRef Contents, Position Pos, + llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, std::shared_ptr<PCHContainerOperations> PCHs, const SymbolIndex *Index) { SignatureHelp Result; @@ -1670,12 +1674,12 @@ CompletionItem CodeCompletion::render(const CodeCompleteOptions &Opts) const { LSP.label = ((InsertInclude && InsertInclude->Insertion) ? Opts.IncludeIndicator.Insert : Opts.IncludeIndicator.NoInsert) + - (Opts.ShowOrigins ? "[" + to_string(Origin) + "]" : "") + + (Opts.ShowOrigins ? "[" + llvm::to_string(Origin) + "]" : "") + RequiredQualifier + Name + Signature; LSP.kind = Kind; - LSP.detail = - BundleSize > 1 ? formatv("[{0} overloads]", BundleSize) : ReturnType; + LSP.detail = BundleSize > 1 ? llvm::formatv("[{0} overloads]", BundleSize) + : ReturnType; LSP.deprecated = Deprecated; if (InsertInclude) LSP.detail += "\n" + InsertInclude->Header; @@ -1712,12 +1716,13 @@ CompletionItem CodeCompletion::render(const CodeCompleteOptions &Opts) const { return LSP; } -raw_ostream &operator<<(raw_ostream &OS, const CodeCompletion &C) { +llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const CodeCompletion &C) { // For now just lean on CompletionItem. return OS << C.render(CodeCompleteOptions()); } -raw_ostream &operator<<(raw_ostream &OS, const CodeCompleteResult &R) { +llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, + const CodeCompleteResult &R) { OS << "CodeCompleteResult: " << R.Completions.size() << (R.HasMore ? "+" : "") << " (" << getCompletionKindString(R.Context) << ")" << " items:\n"; |