summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/CodeCompleteConsumer.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-09-22 23:15:58 +0000
committerDouglas Gregor <dgregor@apple.com>2009-09-22 23:15:58 +0000
commit5bf52697b079b4b7c9db9a38c202788743d7264d (patch)
treeb6b3ffa4b827c85b1ee51df593f3f60ca9757834 /clang/lib/Sema/CodeCompleteConsumer.cpp
parentcc52f65500cc929fcf4e4eab37025a1a31dd8761 (diff)
downloadbcm5719-llvm-5bf52697b079b4b7c9db9a38c202788743d7264d.tar.gz
bcm5719-llvm-5bf52697b079b4b7c9db9a38c202788743d7264d.zip
Tweak the code-completion results ranking and formation, so that
members found in base classes have the same ranking as members found in derived classes. However, we will introduce an informative note for members found in base classes, showing (as a nested-name-specifier) the qualification to name the base class, to make it clear which members are from bases. llvm-svn: 82586
Diffstat (limited to 'clang/lib/Sema/CodeCompleteConsumer.cpp')
-rw-r--r--clang/lib/Sema/CodeCompleteConsumer.cpp44
1 files changed, 28 insertions, 16 deletions
diff --git a/clang/lib/Sema/CodeCompleteConsumer.cpp b/clang/lib/Sema/CodeCompleteConsumer.cpp
index 1e505090fb9..f490a2b5235 100644
--- a/clang/lib/Sema/CodeCompleteConsumer.cpp
+++ b/clang/lib/Sema/CodeCompleteConsumer.cpp
@@ -26,14 +26,19 @@ using namespace clang;
//===----------------------------------------------------------------------===//
// Code completion string implementation
//===----------------------------------------------------------------------===//
-CodeCompletionString::Chunk
-CodeCompletionString::Chunk::CreateText(const char *Text) {
- Chunk Result;
- Result.Kind = CK_Text;
+CodeCompletionString::Chunk::Chunk(ChunkKind Kind, const char *Text)
+ : Kind(Kind), Text(0)
+{
+ assert((Kind == CK_Text || Kind == CK_Placeholder || Kind == CK_Informative)
+ && "Invalid text chunk kind");
char *New = new char [std::strlen(Text) + 1];
std::strcpy(New, Text);
- Result.Text = New;
- return Result;
+ this->Text = New;
+}
+
+CodeCompletionString::Chunk
+CodeCompletionString::Chunk::CreateText(const char *Text) {
+ return Chunk(CK_Text, Text);
}
CodeCompletionString::Chunk
@@ -47,20 +52,26 @@ CodeCompletionString::Chunk::CreateOptional(
CodeCompletionString::Chunk
CodeCompletionString::Chunk::CreatePlaceholder(const char *Placeholder) {
- Chunk Result;
- Result.Kind = CK_Placeholder;
- char *New = new char [std::strlen(Placeholder) + 1];
- std::strcpy(New, Placeholder);
- Result.Placeholder = New;
- return Result;
+ return Chunk(CK_Placeholder, Placeholder);
+}
+
+CodeCompletionString::Chunk
+CodeCompletionString::Chunk::CreateInformative(const char *Informative) {
+ return Chunk(CK_Informative, Informative);
}
void
CodeCompletionString::Chunk::Destroy() {
switch (Kind) {
- case CK_Text: delete [] Text; break;
- case CK_Optional: delete Optional; break;
- case CK_Placeholder: delete [] Placeholder; break;
+ case CK_Optional:
+ delete Optional;
+ break;
+
+ case CK_Text:
+ case CK_Placeholder:
+ case CK_Informative:
+ delete [] Text;
+ break;
}
}
@@ -77,7 +88,8 @@ std::string CodeCompletionString::getAsString() const {
switch (C->Kind) {
case CK_Text: OS << C->Text; break;
case CK_Optional: OS << "{#" << C->Optional->getAsString() << "#}"; break;
- case CK_Placeholder: OS << "<#" << C->Placeholder << "#>"; break;
+ case CK_Placeholder: OS << "<#" << C->Text << "#>"; break;
+ case CK_Informative: OS << "[#" << C->Text << "#]"; break;
}
}
OpenPOWER on IntegriCloud