Specifically, @[] and @{} didn't have a type associated with them; we now
use "NSArray *" and "NSDictionary *", respectively. @"" has the type
"NSString *". @(), unfortunately, has type "id", since it (currently) may
be either an NSNumber or an NSString.
Add a test for all the Objective-C at-expression completions.
<rdar://problem/
11507708&
11507668&
11507711>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158533
91177308-0d34-0410-b5e6-
96231b3b80d8
const char *EncodeType = "char[]";
if (Results.getSema().getLangOpts().CPlusPlus ||
Results.getSema().getLangOpts().ConstStrings)
- EncodeType = " const char[]";
+ EncodeType = "const char[]";
Builder.AddResultTypeChunk(EncodeType);
Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,"encode"));
Builder.AddChunk(CodeCompletionString::CK_LeftParen);
Builder.AddPlaceholderChunk("selector");
Builder.AddChunk(CodeCompletionString::CK_RightParen);
Results.AddResult(Result(Builder.TakeString()));
-
+
+ // @"string"
+ Builder.AddResultTypeChunk("NSString *");
+ Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,"\""));
+ Builder.AddPlaceholderChunk("string");
+ Builder.AddTextChunk("\"");
+ Results.AddResult(Result(Builder.TakeString()));
+
// @[ objects, ... ]
+ Builder.AddResultTypeChunk("NSArray *");
Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,"["));
Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
Builder.AddPlaceholderChunk("objects, ...");
Results.AddResult(Result(Builder.TakeString()));
// @{ key : object, ... }
+ Builder.AddResultTypeChunk("NSDictionary *");
Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,"{"));
Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
Builder.AddPlaceholderChunk("key");
Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
Builder.AddChunk(CodeCompletionString::CK_RightBrace);
Results.AddResult(Result(Builder.TakeString()));
+
+ // @( expression )
+ Builder.AddResultTypeChunk("id");
+ Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt, "("));
+ Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+ Builder.AddPlaceholderChunk("expression");
+ Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+ Builder.AddChunk(CodeCompletionString::CK_RightParen);
+ Results.AddResult(Result(Builder.TakeString()));
}
static void AddObjCStatementResults(ResultBuilder &Results, bool NeedAt) {
--- /dev/null
+// Note: the run lines follow all tests, since line/column matter here
+
+id testCompleteAfterAtSign() {
+ return @"";
+}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:4:11 %s -fno-const-strings -o - | FileCheck -check-prefix=AT %s
+// CHECK-AT: COMPLETION: Pattern : [#NSString *#]"<#string#>"
+// CHECK-AT: COMPLETION: Pattern : [#id#]( <#expression#> )
+// CHECK-AT: COMPLETION: Pattern : [#NSArray *#][ <#objects, ...#> ]
+// CHECK-AT: COMPLETION: Pattern : [#char[]#]encode(<#type-name#>)
+// CHECK-AT: COMPLETION: Pattern : [#Protocol *#]protocol(<#protocol-name#>)
+// CHECK-AT: COMPLETION: Pattern : [#SEL#]selector(<#selector#>)
+// CHECK-AT: COMPLETION: Pattern : [#NSDictionary *#]{ <#key#> : <#object, ...#> }
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:4:11 %s -fconst-strings -o - | FileCheck -check-prefix=CONST-STRINGS %s
+// CHECK-CONST-STRINGS: COMPLETION: Pattern : [#const char[]#]encode(<#type-name#>)
@end
// RUN: c-index-test -code-completion-at=%s:13:2 %s | FileCheck -check-prefix=CHECK-CC1 %s
-// CHECK-CC1: NotImplemented:{TypedText @[}{HorizontalSpace }{Placeholder objects, ...}{HorizontalSpace }{RightBracket ]} (40)
-// CHECK-CC1: NotImplemented:{TypedText @{}{HorizontalSpace }{Placeholder key}{HorizontalSpace }{Colon :}{HorizontalSpace }{Placeholder object, ...}{HorizontalSpace }{RightBrace }} (40)
+// CHECK-CC1: NotImplemented:{ResultType NSString *}{TypedText @"}{Placeholder string}{Text "} (40)
+// CHECK-CC1: NotImplemented:{ResultType id}{TypedText @(}{HorizontalSpace }{Placeholder expression}{HorizontalSpace }{RightParen )} (40)
+// CHECK-CC1: NotImplemented:{ResultType NSArray *}{TypedText @[}{HorizontalSpace }{Placeholder objects, ...}{HorizontalSpace }{RightBracket ]} (40)
+// CHECK-CC1: NotImplemented:{ResultType NSDictionary *}{TypedText @{}{HorizontalSpace }{Placeholder key}{HorizontalSpace }{Colon :}{HorizontalSpace }{Placeholder object, ...}{HorizontalSpace }{RightBrace }} (40)
// CHECK-CC1: NotImplemented:{ResultType SEL}{TypedText _cmd} (80)
// CHECK-CC1: TypedefDecl:{TypedText BOOL} (50)
// CHECK-CC1: macro definition:{TypedText bool} (51)
// RUN: c-index-test -code-completion-at=%s:15:5 %s | FileCheck -check-prefix=CHECK-CC4 %s
// RUN: c-index-test -code-completion-at=%s:16:5 %s | FileCheck -check-prefix=CHECK-CC4 %s
// RUN: c-index-test -code-completion-at=%s:16:14 %s | FileCheck -check-prefix=CHECK-CC4 %s
-// CHECK-CC4: NotImplemented:{TypedText @[}{HorizontalSpace }{Placeholder objects, ...}{HorizontalSpace }{RightBracket ]} (40)
-// CHECK-CC4: NotImplemented:{TypedText @{}{HorizontalSpace }{Placeholder key}{HorizontalSpace }{Colon :}{HorizontalSpace }{Placeholder object, ...}{HorizontalSpace }{RightBrace }} (40)
+// CHECK-CC4: NotImplemented:{ResultType NSArray *}{TypedText @[}{HorizontalSpace }{Placeholder objects, ...}{HorizontalSpace }{RightBracket ]} (40)
+// CHECK-CC4: NotImplemented:{ResultType NSDictionary *}{TypedText @{}{HorizontalSpace }{Placeholder key}{HorizontalSpace }{Colon :}{HorizontalSpace }{Placeholder object, ...}{HorizontalSpace }{RightBrace }} (40)
// CHECK-CC4: NotImplemented:{ResultType SEL}{TypedText _cmd} (80)
// CHECK-CC4: macro definition:{TypedText bool} (51)
// CHECK-CC4: macro definition:{TypedText NO} (65)