[cfe-commits] r93231 - in /cfe/trunk: lib/Sema/SemaCodeComplete.cpp test/Index/complete-at-directives.m test/Index/complete-at-exprstmt.m test/Index/complete-objc-message.m

Douglas Gregor dgregor at apple.com
Mon Jan 11 22:38:30 PST 2010


Author: dgregor
Date: Tue Jan 12 00:38:28 2010
New Revision: 93231

URL: http://llvm.org/viewvc/llvm-project?rev=93231&view=rev
Log:
Use horizontal-space markers in code-completion results rather than
embedding single space characters. <rdar://problem/7485503>

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

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=93231&r1=93230&r2=93231&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Tue Jan 12 00:38:28 2010
@@ -1677,7 +1677,7 @@
       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 @@
       // @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 @@
     // @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 @@
     // 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 @@
   // @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);

Modified: cfe/trunk/test/Index/complete-at-directives.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-at-directives.m?rev=93231&r1=93230&r2=93231&view=diff

==============================================================================
--- cfe/trunk/test/Index/complete-at-directives.m (original)
+++ cfe/trunk/test/Index/complete-at-directives.m Tue Jan 12 00:38:28 2010
@@ -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}

Modified: cfe/trunk/test/Index/complete-at-exprstmt.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-at-exprstmt.m?rev=93231&r1=93230&r2=93231&view=diff

==============================================================================
--- cfe/trunk/test/Index/complete-at-exprstmt.m (original)
+++ cfe/trunk/test/Index/complete-at-exprstmt.m Tue Jan 12 00:38:28 2010
@@ -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 )}

Modified: cfe/trunk/test/Index/complete-objc-message.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-objc-message.m?rev=93231&r1=93230&r2=93231&view=diff

==============================================================================
--- cfe/trunk/test/Index/complete-objc-message.m (original)
+++ cfe/trunk/test/Index/complete-objc-message.m Tue Jan 12 00:38:28 2010
@@ -105,7 +105,7 @@
 
 // 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 @@
 // 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 @@
 // 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}





More information about the cfe-commits mailing list