]> granicus.if.org Git - clang/commitdiff
Use horizontal-space markers in code-completion results rather than
authorDouglas Gregor <dgregor@apple.com>
Tue, 12 Jan 2010 06:38:28 +0000 (06:38 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 12 Jan 2010 06:38:28 +0000 (06:38 +0000)
embedding single space characters. <rdar://problem/7485503>

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

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

index 582b36901c9a11868e252fe2411d47bcc9b495db..d54e4c0e03a5308afe57112b0d593097e1468d64 100644 (file)
@@ -1677,7 +1677,7 @@ CodeCompleteConsumer::Result::CreateCodeCompletionString(Sema &S) {
       if (Idx > 0) {
         std::string Keyword;
         if (Idx > StartParameter)
-          Keyword = " ";
+          Result->AddChunk(CodeCompletionString::CK_HorizontalSpace);
         if (IdentifierInfo *II = Sel.getIdentifierInfoForSlot(Idx))
           Keyword += II->getName().str();
         Keyword += ":";
@@ -2462,14 +2462,14 @@ void Sema::CodeCompleteObjCAtDirective(Scope *S, DeclPtrTy ObjCImpDecl,
       // @dynamic
       Pattern = new CodeCompletionString;
       Pattern->AddTypedTextChunk("dynamic");
-      Pattern->AddTextChunk(" ");
+      Pattern->AddChunk(CodeCompletionString::CK_HorizontalSpace);
       Pattern->AddPlaceholderChunk("property");
       Results.MaybeAddResult(Result(Pattern, 0));
 
       // @synthesize
       Pattern = new CodeCompletionString;
       Pattern->AddTypedTextChunk("synthesize");
-      Pattern->AddTextChunk(" ");
+      Pattern->AddChunk(CodeCompletionString::CK_HorizontalSpace);
       Pattern->AddPlaceholderChunk("property");
       Results.MaybeAddResult(Result(Pattern, 0));
     }
@@ -2493,9 +2493,9 @@ void Sema::CodeCompleteObjCAtDirective(Scope *S, DeclPtrTy ObjCImpDecl,
     // @class name ;
     Pattern = new CodeCompletionString;
     Pattern->AddTypedTextChunk("class");
-    Pattern->AddTextChunk(" ");
+    Pattern->AddChunk(CodeCompletionString::CK_HorizontalSpace);
     Pattern->AddPlaceholderChunk("identifier");
-    Pattern->AddTextChunk(";"); // add ';' chunk
+    Pattern->AddChunk(CodeCompletionString::CK_SemiColon);
     Results.MaybeAddResult(Result(Pattern, 0));
 
     // @interface name 
@@ -2503,30 +2503,35 @@ void Sema::CodeCompleteObjCAtDirective(Scope *S, DeclPtrTy ObjCImpDecl,
     // such.
     Pattern = new CodeCompletionString;
     Pattern->AddTypedTextChunk("interface");
-    Pattern->AddTextChunk(" ");
+    Pattern->AddChunk(CodeCompletionString::CK_HorizontalSpace);
+
     Pattern->AddPlaceholderChunk("class");
     Results.MaybeAddResult(Result(Pattern, 0));
 
     // @protocol name
     Pattern = new CodeCompletionString;
     Pattern->AddTypedTextChunk("protocol");
-    Pattern->AddTextChunk(" ");
+    Pattern->AddChunk(CodeCompletionString::CK_HorizontalSpace);
+
     Pattern->AddPlaceholderChunk("protocol");
     Results.MaybeAddResult(Result(Pattern, 0));
 
     // @implementation name
     Pattern = new CodeCompletionString;
     Pattern->AddTypedTextChunk("implementation");
-    Pattern->AddTextChunk(" ");
+    Pattern->AddChunk(CodeCompletionString::CK_HorizontalSpace);
+
     Pattern->AddPlaceholderChunk("class");
     Results.MaybeAddResult(Result(Pattern, 0));
 
     // @compatibility_alias name
     Pattern = new CodeCompletionString;
     Pattern->AddTypedTextChunk("compatibility_alias");
-    Pattern->AddTextChunk(" ");
+    Pattern->AddChunk(CodeCompletionString::CK_HorizontalSpace);
+
     Pattern->AddPlaceholderChunk("alias");
-    Pattern->AddTextChunk(" ");
+    Pattern->AddChunk(CodeCompletionString::CK_HorizontalSpace);
+
     Pattern->AddPlaceholderChunk("class");
     Results.MaybeAddResult(Result(Pattern, 0));
   }
@@ -2593,15 +2598,17 @@ void Sema::CodeCompleteObjCAtStatement(Scope *S) {
   // @throw
   Pattern = new CodeCompletionString;
   Pattern->AddTypedTextChunk("throw");
-  Pattern->AddTextChunk(" ");
+  Pattern->AddChunk(CodeCompletionString::CK_HorizontalSpace);
+
   Pattern->AddPlaceholderChunk("expression");
-  Pattern->AddTextChunk(";");
-  Results.MaybeAddResult(Result(Pattern, 0)); // FIXME: add ';' chunk
+  Pattern->AddChunk(CodeCompletionString::CK_SemiColon);
+  Results.MaybeAddResult(Result(Pattern, 0));
 
   // @synchronized ( expression ) { statements }
   Pattern = new CodeCompletionString;
   Pattern->AddTypedTextChunk("synchronized");
-  Pattern->AddTextChunk(" ");
+  Pattern->AddChunk(CodeCompletionString::CK_HorizontalSpace);
+
   Pattern->AddChunk(CodeCompletionString::CK_LeftParen);
   Pattern->AddPlaceholderChunk("expression");
   Pattern->AddChunk(CodeCompletionString::CK_RightParen);
index 68d1ef42f863d12962734b43df2c4ec56d77a6b5..346e04f1ff14674c9f57a0e0c00fb3f0dc99451f 100644 (file)
@@ -6,11 +6,11 @@
 @end
 
 // RUN: c-index-test -code-completion-at=%s:2:2 %s | FileCheck -check-prefix=CHECK-CC1 %s
-// CHECK-CC1: {TypedText class}{Text  }{Placeholder identifier}{Text ;}
-// CHECK-CC1: {TypedText compatibility_alias}{Text  }{Placeholder alias}{Text  }{Placeholder class}
-// CHECK-CC1: {TypedText implementation}{Text  }{Placeholder class}
-// CHECK-CC1: {TypedText interface}{Text  }{Placeholder class}
-// CHECK-CC1: {TypedText protocol}{Text  }{Placeholder protocol}
+// CHECK-CC1: {TypedText class}{HorizontalSpace  }{Placeholder identifier}{Text ;}
+// CHECK-CC1: {TypedText compatibility_alias}{HorizontalSpace  }{Placeholder alias}{HorizontalSpace  }{Placeholder class}
+// CHECK-CC1: {TypedText implementation}{HorizontalSpace  }{Placeholder class}
+// CHECK-CC1: {TypedText interface}{HorizontalSpace  }{Placeholder class}
+// CHECK-CC1: {TypedText protocol}{HorizontalSpace  }{Placeholder protocol}
 
 // RUN: c-index-test -code-completion-at=%s:3:2 %s | FileCheck -check-prefix=CHECK-CC2 %s
 // CHECK-CC2: {TypedText end}
@@ -19,6 +19,6 @@
 // CHECK-CC2: {TypedText required}
 
 // RUN: c-index-test -code-completion-at=%s:6:2 %s | FileCheck -check-prefix=CHECK-CC3 %s
-// CHECK-CC3: {TypedText dynamic}{Text  }{Placeholder property}
+// CHECK-CC3: {TypedText dynamic}{HorizontalSpace  }{Placeholder property}
 // CHECK-CC3: {TypedText end}
-// CHECK-CC3: {TypedText synthesize}{Text  }{Placeholder property}
+// CHECK-CC3: {TypedText synthesize}{HorizontalSpace  }{Placeholder property}
index 82c3983e82b2b6340c7b0b2ecb37a17652add4a4..962cf40ed83ae0e425b897a17f0bad238390cc59 100644 (file)
@@ -13,8 +13,8 @@
 // CHECK-CC1: {TypedText encode}{LeftParen (}{Placeholder type-name}{RightParen )}
 // CHECK-CC1: {TypedText protocol}{LeftParen (}{Placeholder protocol-name}{RightParen )}
 // CHECK-CC1: {TypedText selector}{LeftParen (}{Placeholder selector}{RightParen )}
-// CHECK-CC1: {TypedText synchronized}{Text  }{LeftParen (}{Placeholder expression}{RightParen )}{LeftBrace {}{Placeholder statements}{RightBrace }}
-// CHECK-CC1: {TypedText throw}{Text  }{Placeholder expression}{Text ;}
+// CHECK-CC1: {TypedText synchronized}{HorizontalSpace  }{LeftParen (}{Placeholder expression}{RightParen )}{LeftBrace {}{Placeholder statements}{RightBrace }}
+// CHECK-CC1: {TypedText throw}{HorizontalSpace  }{Placeholder expression}{Text ;}
 // CHECK-CC1: {TypedText try}{LeftBrace {}{Placeholder statements}{RightBrace }}{Text @catch}{LeftParen (}{Placeholder parameter}{RightParen )}{LeftBrace {}{Placeholder statements}{RightBrace }}{Text @finally}{LeftBrace {}{Placeholder statements}{RightBrace }}
 // RUN: c-index-test -code-completion-at=%s:9:19 %s | FileCheck -check-prefix=CHECK-CC2 %s
 // CHECK-CC2: {TypedText encode}{LeftParen (}{Placeholder type-name}{RightParen )}
index a7b37fd2442cb13c01393bc4cc0243524d40a98b..79ced32b3b9746995a876c8e594524fd32fd75be 100644 (file)
@@ -105,7 +105,7 @@ void f(Ellipsis *e) {
 
 // RUN: c-index-test -code-completion-at=%s:23:19 %s | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: {TypedText categoryClassMethod}
-// CHECK-CC1: {TypedText classMethod1:}{Placeholder (id)a}{Text  withKeyword:}{Placeholder (int)b}
+// CHECK-CC1: {TypedText classMethod1:}{Placeholder (id)a}{HorizontalSpace  }{Text withKeyword:}{Placeholder (int)b}
 // CHECK-CC1: {TypedText classMethod2}
 // CHECK-CC1: {TypedText new}
 // CHECK-CC1: {TypedText protocolClassMethod}
@@ -117,10 +117,10 @@ void f(Ellipsis *e) {
 // CHECK-CC3: ObjCClassMethodDecl:{ResultType int}{TypedText MyClassMethod:}{Placeholder (id)obj}
 // CHECK-CC3: ObjCClassMethodDecl:{ResultType int}{TypedText MyPrivateMethod}
 // RUN: c-index-test -code-completion-at=%s:65:16 %s | FileCheck -check-prefix=CHECK-CC4 %s
-// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)x}{Text  second:}{Placeholder (id)y}
+// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)x}{HorizontalSpace  }{Text second:}{Placeholder (id)y}
 // CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyPrivateInstMethod}
 // RUN: c-index-test -code-completion-at=%s:74:9 %s | FileCheck -check-prefix=CHECK-CC5 %s
-// CHECK-CC5: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)x}{Text  second:}{Placeholder (id)y}
+// CHECK-CC5: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)x}{HorizontalSpace  }{Text second:}{Placeholder (id)y}
 // CHECK-CC5: ObjCInstanceMethodDecl:{ResultType int}{TypedText MySubInstMethod}
 // RUN: c-index-test -code-completion-at=%s:82:8 %s | FileCheck -check-prefix=CHECK-CC6 %s
 // CHECK-CC6: ObjCInstanceMethodDecl:{ResultType id}{TypedText protocolInstanceMethod:}{Placeholder (int)value}
@@ -128,15 +128,15 @@ void f(Ellipsis *e) {
 // RUN: c-index-test -code-completion-at=%s:95:8 %s | FileCheck -check-prefix=CHECK-CC7 %s
 // CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method}
 // CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i}
-// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{Text  Arg1:}{Placeholder (int)i1}{Text  Arg2:}{Placeholder (int)i2}
-// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{Text  Arg1:}{Placeholder (int)i1}{Text  OtherArg:}{Placeholder (id)obj}
-// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{Text  SomeArg:}{Placeholder (int)i1}{Text  OtherArg:}{Placeholder (id)obj}
-// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)f}{Text  Arg1:}{Placeholder (int)i1}{Text  Arg2:}{Placeholder (int)i2}
+// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace  }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace  }{Text Arg2:}{Placeholder (int)i2}
+// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace  }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace  }{Text OtherArg:}{Placeholder (id)obj}
+// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace  }{Text SomeArg:}{Placeholder (int)i1}{HorizontalSpace  }{Text OtherArg:}{Placeholder (id)obj}
+// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)f}{HorizontalSpace  }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace  }{Text Arg2:}{Placeholder (int)i2}
 // RUN: c-index-test -code-completion-at=%s:95:17 %s | FileCheck -check-prefix=CHECK-CC8 %s
 // CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText }
-// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{Text  Arg2:}{Placeholder (int)i2}
-// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{Text  OtherArg:}{Placeholder (id)obj}
-// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText SomeArg:}{Placeholder (int)i1}{Text  OtherArg:}{Placeholder (id)obj}
+// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{HorizontalSpace  }{Text Arg2:}{Placeholder (int)i2}
+// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{HorizontalSpace  }{Text OtherArg:}{Placeholder (id)obj}
+// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText SomeArg:}{Placeholder (int)i1}{HorizontalSpace  }{Text OtherArg:}{Placeholder (id)obj}
 // RUN: c-index-test -code-completion-at=%s:95:24 %s | FileCheck -check-prefix=CHECK-CC9 %s
 // CHECK-CC9: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText Arg2:}{Placeholder (int)i2}
 // CHECK-CC9: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText OtherArg:}{Placeholder (id)obj}