|
@@ -37,6 +37,7 @@
|
|
|
#include "llvm/Support/Path.h"
|
|
|
#include <list>
|
|
|
#include <map>
|
|
|
+#include <string>
|
|
|
#include <vector>
|
|
|
|
|
|
using namespace clang;
|
|
@@ -1828,19 +1829,6 @@ static void AddStaticAssertResult(CodeCompletionBuilder &Builder,
|
|
|
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 +3150,42 @@ CodeCompletionString *CodeCompletionResult::CreateCodeCompletionString(
|
|
|
PP, Ctx, Result, IncludeBriefComments, CCContext, Policy);
|
|
|
}
|
|
|
|
|
|
+static void printOverrideString(const CodeCompletionString &CCS,
|
|
|
+ std::string &BeforeName,
|
|
|
+ std::string &NameAndSignature) {
|
|
|
+ bool SeenTypedChunk = false;
|
|
|
+ for (auto &Chunk : CCS) {
|
|
|
+ if (Chunk.Kind == CodeCompletionString::CK_Optional) {
|
|
|
+ assert(SeenTypedChunk && "optional parameter before name");
|
|
|
+ // Note that we put all chunks inside into NameAndSignature.
|
|
|
+ printOverrideString(*Chunk.Optional, NameAndSignature, NameAndSignature);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ SeenTypedChunk |= Chunk.Kind == CodeCompletionString::CK_TypedText;
|
|
|
+ if (SeenTypedChunk)
|
|
|
+ NameAndSignature += Chunk.Text;
|
|
|
+ else
|
|
|
+ BeforeName += Chunk.Text;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
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()));
|
|
|
+ std::string BeforeName;
|
|
|
+ std::string NameAndSignature;
|
|
|
+ // For overrides all chunks go into the result, none are informative.
|
|
|
+ printOverrideString(*CCS, BeforeName, NameAndSignature);
|
|
|
+ NameAndSignature += " override";
|
|
|
+
|
|
|
+ Result.AddTextChunk(Result.getAllocator().CopyString(BeforeName));
|
|
|
+ Result.AddChunk(CodeCompletionString::CK_HorizontalSpace);
|
|
|
+ Result.AddTypedTextChunk(Result.getAllocator().CopyString(NameAndSignature));
|
|
|
return Result.TakeString();
|
|
|
}
|
|
|
|