[PATCH] D62298: [CodeComplete] Override completion items are filtered by funciton names
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 23 03:57:34 PDT 2019
ilya-biryukov updated this revision to Diff 200924.
ilya-biryukov added a comment.
- Use the old name for the helper function
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62298/new/
https://reviews.llvm.org/D62298
Files:
clang/lib/Sema/SemaCodeComplete.cpp
Index: clang/lib/Sema/SemaCodeComplete.cpp
===================================================================
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -1828,19 +1828,6 @@
Results.AddResult(CodeCompletionResult(Builder.TakeString()));
}
-static void printOverrideString(llvm::raw_ostream &OS,
- CodeCompletionString *CCS) {
- for (const auto &C : *CCS) {
- if (C.Kind == CodeCompletionString::CK_Optional)
- printOverrideString(OS, C.Optional);
- else
- OS << C.Text;
- // Add a space after return type.
- if (C.Kind == CodeCompletionString::CK_ResultType)
- OS << ' ';
- }
-}
-
static void AddOverrideResults(ResultBuilder &Results,
const CodeCompletionContext &CCContext,
CodeCompletionBuilder &Builder) {
@@ -3162,19 +3149,37 @@
PP, Ctx, Result, IncludeBriefComments, CCContext, Policy);
}
+/// Turns a completion string for a declaration into a textual representation.
+/// The result contains only 'typed text' and 'text' chunks.
+static void PrintOverrideString(const CodeCompletionString &CCS,
+ CodeCompletionBuilder &Result) {
+ for (auto &Chunk : CCS) {
+ if (Chunk.Kind == CodeCompletionString::CK_Optional) {
+ PrintOverrideString(*Chunk.Optional, Result);
+ continue;
+ }
+ if (Chunk.Kind == CodeCompletionString::CK_TypedText)
+ Result.AddTypedTextChunk(Chunk.Text);
+ else
+ Result.AddTextChunk(Chunk.Text);
+ // Add a space after return type.
+ if (Chunk.Kind == CodeCompletionString::CK_ResultType)
+ Result.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+ }
+}
+
CodeCompletionString *
CodeCompletionResult::createCodeCompletionStringForOverride(
Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result,
bool IncludeBriefComments, const CodeCompletionContext &CCContext,
PrintingPolicy &Policy) {
- std::string OverrideSignature;
- llvm::raw_string_ostream OS(OverrideSignature);
auto *CCS = createCodeCompletionStringForDecl(PP, Ctx, Result,
/*IncludeBriefComments=*/false,
CCContext, Policy);
- printOverrideString(OS, CCS);
- OS << " override";
- Result.AddTypedTextChunk(Result.getAllocator().CopyString(OS.str()));
+ // For overrides all chunks go into the result, none are informative.
+ PrintOverrideString(*CCS, Result);
+ Result.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+ Result.AddTextChunk("override");
return Result.TakeString();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62298.200924.patch
Type: text/x-patch
Size: 2679 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190523/eccbd7a5/attachment.bin>
More information about the cfe-commits
mailing list