]> granicus.if.org Git - clang/commitdiff
Tweak the @selector completion to collapse multiple informative and
authorDouglas Gregor <dgregor@apple.com>
Thu, 26 Aug 2010 16:46:39 +0000 (16:46 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 26 Aug 2010 16:46:39 +0000 (16:46 +0000)
typed-text blocks into one of each.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112194 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaCodeComplete.cpp
test/Index/complete-at-exprstmt.m

index 392152630d5d5f180bb93dd97c7b46440fa186c1..4c06fac01283d2c07663f38f1c47f16f9c7b6255 100644 (file)
@@ -4064,16 +4064,19 @@ void Sema::CodeCompleteObjCSelector(Scope *S, IdentifierInfo **SelIdents,
       continue;
     }
     
+    std::string Accumulator;
     for (unsigned I = 0, N = Sel.getNumArgs(); I != N; ++I) {
-      std::string Piece = Sel.getIdentifierInfoForSlot(I)->getName().str();
-      Piece += ':';
-      if (I < NumSelIdents)
-        Pattern->AddInformativeChunk(Piece);
-      else if (I == NumSelIdents)
-        Pattern->AddTypedTextChunk(Piece);
-      else
-        Pattern->AddTextChunk(Piece);
+      if (I == NumSelIdents) {
+        if (!Accumulator.empty()) {
+          Pattern->AddInformativeChunk(Accumulator);
+          Accumulator.clear();
+        }
+      }
+      
+      Accumulator += Sel.getIdentifierInfoForSlot(I)->getName().str();
+      Accumulator += ':';
     }
+    Pattern->AddTypedTextChunk(Accumulator);
     Results.AddResult(Pattern);
   }
   Results.ExitScope();
index 834b42e4b3007a7da5a1ebf167536b456e1f4a56..cccfa261ca79a2b938c6a6f19117271b53f263c9 100644 (file)
@@ -46,10 +46,10 @@ void f() {
 // CHECK-CC3: TypedefDecl:{TypedText SEL}
 // CHECK-CC3: NotImplemented:{ResultType MyClass *}{TypedText self}
 // RUN: c-index-test -code-completion-at=%s:19:13 %s | FileCheck -check-prefix=CHECK-CC4 %s
-// CHECK-CC4: NotImplemented:{TypedText add:}{Text to:} (30)
-// CHECK-CC4: NotImplemented:{TypedText add:}{Text to:}{Text plus:} (30)
+// CHECK-CC4: NotImplemented:{TypedText add:to:} (30)
+// CHECK-CC4: NotImplemented:{TypedText add:to:plus:} (30)
 // CHECK-CC4: NotImplemented:{TypedText myMethod:} (30)
 // RUN: c-index-test -code-completion-at=%s:19:17 %s | FileCheck -check-prefix=CHECK-CC5 %s
 // CHECK-CC5: NotImplemented:{Informative add:}{TypedText to:} (30)
-// CHECK-CC5: NotImplemented:{Informative add:}{TypedText to:}{Text plus:} (30)
+// CHECK-CC5: NotImplemented:{Informative add:}{TypedText to:plus:} (30)