Skip to content

Commit 0bebba8

Browse files
authored
Merge pull request swiftlang#22539 from rintaro/ide-codecompletion-dottype-rdar22072865
[CodeCompletion] Implement .Type completion in expression context
2 parents b70447f + ec85151 commit 0bebba8

14 files changed

+148
-37
lines changed

lib/IDE/CodeCompletion.cpp

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3042,6 +3042,29 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
30423042
return false;
30433043
}
30443044

3045+
void getPostfixKeywordCompletions(Type ExprType, Expr *ParsedExpr) {
3046+
if (!ExprType->getAs<ModuleType>()) {
3047+
addKeyword(getTokenText(tok::kw_self), ExprType->getRValueType(),
3048+
SemanticContextKind::CurrentNominal,
3049+
CodeCompletionKeywordKind::kw_self);
3050+
}
3051+
3052+
if (isa<TypeExpr>(ParsedExpr)) {
3053+
if (auto *T = ExprType->getAs<AnyMetatypeType>()) {
3054+
auto instanceTy = T->getInstanceType();
3055+
if (instanceTy->isAnyExistentialType()) {
3056+
addKeyword("Protocol", MetatypeType::get(instanceTy),
3057+
SemanticContextKind::CurrentNominal);
3058+
addKeyword("Type", ExistentialMetatypeType::get(instanceTy),
3059+
SemanticContextKind::CurrentNominal);
3060+
} else {
3061+
addKeyword("Type", MetatypeType::get(instanceTy),
3062+
SemanticContextKind::CurrentNominal);
3063+
}
3064+
}
3065+
}
3066+
}
3067+
30453068
void getValueExprCompletions(Type ExprType, ValueDecl *VD = nullptr) {
30463069
Kind = LookupKind::ValueExpr;
30473070
NeedLeadingDot = !HaveDot;
@@ -3665,11 +3688,15 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
36653688
Kind = LookupKind::Type;
36663689
this->BaseType = BaseType;
36673690
NeedLeadingDot = !HaveDot;
3668-
Type MetaBase = MetatypeType::get(BaseType);
3669-
lookupVisibleMemberDecls(*this, MetaBase,
3691+
lookupVisibleMemberDecls(*this, MetatypeType::get(BaseType),
36703692
CurrDeclContext, TypeResolver,
36713693
IncludeInstanceMembers);
3672-
addKeyword("Type", MetaBase);
3694+
if (BaseType->isAnyExistentialType()) {
3695+
addKeyword("Protocol", MetatypeType::get(BaseType));
3696+
addKeyword("Type", ExistentialMetatypeType::get(BaseType));
3697+
} else {
3698+
addKeyword("Type", MetatypeType::get(BaseType));
3699+
}
36733700
}
36743701

36753702
static bool canUseAttributeOnDecl(DeclAttrKind DAK, bool IsInSil,
@@ -4844,11 +4871,7 @@ void CodeCompletionCallbacksImpl::doneParsing() {
48444871
if (isDynamicLookup(*ExprType))
48454872
Lookup.setIsDynamicLookup();
48464873

4847-
if (!ExprType.getValue()->getAs<ModuleType>())
4848-
Lookup.addKeyword(getTokenText(tok::kw_self),
4849-
(*ExprType)->getRValueType(),
4850-
SemanticContextKind::CurrentNominal,
4851-
CodeCompletionKeywordKind::kw_self);
4874+
Lookup.getPostfixKeywordCompletions(*ExprType, ParsedExpr);
48524875

48534876
if (isa<BindOptionalExpr>(ParsedExpr) || isa<ForceValueExpr>(ParsedExpr))
48544877
Lookup.setIsUnwrappedOptional(true);
@@ -4906,12 +4929,7 @@ void CodeCompletionCallbacksImpl::doneParsing() {
49064929
Lookup.setIsDynamicLookup();
49074930
Lookup.getValueExprCompletions(*ExprType, ReferencedDecl.getDecl());
49084931
Lookup.getOperatorCompletions(ParsedExpr, leadingSequenceExprs);
4909-
4910-
if (!ExprType.getValue()->getAs<ModuleType>())
4911-
Lookup.addKeyword(getTokenText(tok::kw_self),
4912-
(*ExprType)->getRValueType(),
4913-
SemanticContextKind::CurrentNominal,
4914-
CodeCompletionKeywordKind::kw_self);
4932+
Lookup.getPostfixKeywordCompletions(*ExprType, ParsedExpr);
49154933
break;
49164934
}
49174935

test/IDE/complete_associated_types.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ struct StructWithBrokenConformance : FooProtocolWithAssociatedTypes {
267267
func testBrokenConformances1() {
268268
StructWithBrokenConformance.#^BROKEN_CONFORMANCE_1^#
269269
}
270-
// BROKEN_CONFORMANCE_1: Begin completions, 33 items
270+
// BROKEN_CONFORMANCE_1: Begin completions, 34 items
271271
// BROKEN_CONFORMANCE_1-DAG: Decl[TypeAlias]/CurrNominal: DefaultedTypeCommonA[#StructWithBrokenConformance.DefaultedTypeCommonA#]; name=DefaultedTypeCommonA
272272
// BROKEN_CONFORMANCE_1-DAG: Decl[TypeAlias]/CurrNominal: DefaultedTypeCommonB[#StructWithBrokenConformance.DefaultedTypeCommonB#]; name=DefaultedTypeCommonB
273273
// BROKEN_CONFORMANCE_1-DAG: Decl[TypeAlias]/CurrNominal: FooBaseDefaultedTypeB[#StructWithBrokenConformance.FooBaseDefaultedTypeB#]; name=FooBaseDefaultedTypeB

test/IDE/complete_at_top_level.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ var topLevelVar2 = FooStruct#^TOP_LEVEL_VAR_INIT_2^#
266266
// TOP_LEVEL_VAR_INIT_2-NEXT: Decl[Constructor]/CurrNominal: ({#instanceVar: Int#})[#FooStruct#]{{; name=.+$}}
267267
// TOP_LEVEL_VAR_INIT_2-NEXT: Decl[Constructor]/CurrNominal: ()[#FooStruct#]{{; name=.+$}}
268268
// TOP_LEVEL_VAR_INIT_2-NEXT: Keyword[self]/CurrNominal: .self[#FooStruct.Type#]; name=self
269+
// TOP_LEVEL_VAR_INIT_2-NEXT: Keyword/CurrNominal: .Type[#FooStruct.Type#]; name=Type
269270
// TOP_LEVEL_VAR_INIT_2-NEXT: End completions
270271

271272
func resyncParser8() {}

test/IDE/complete_constructor.swift

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ struct ImplicitConstructors1 {
5858

5959
func testImplicitConstructors1() {
6060
ImplicitConstructors1#^IMPLICIT_CONSTRUCTORS_1^#
61-
// IMPLICIT_CONSTRUCTORS_1: Begin completions, 2 items
61+
// IMPLICIT_CONSTRUCTORS_1: Begin completions, 3 items
6262
// IMPLICIT_CONSTRUCTORS_1-DAG: Decl[Constructor]/CurrNominal: ()[#ImplicitConstructors1#]{{; name=.+$}}
6363
// IMPLICIT_CONSTRUCTORS_1-DAG: Keyword[self]/CurrNominal: .self[#ImplicitConstructors1.Type#]; name=self
64+
// IMPLICIT_CONSTRUCTORS_1-DAG: Keyword/CurrNominal: .Type[#ImplicitConstructors1.Type#]; name=Type
6465
// IMPLICIT_CONSTRUCTORS_1: End completions
6566
}
6667
func testImplicitConstructors1P() {
@@ -74,10 +75,11 @@ struct ImplicitConstructors2 {
7475

7576
func testImplicitConstructors2() {
7677
ImplicitConstructors2#^IMPLICIT_CONSTRUCTORS_2^#
77-
// IMPLICIT_CONSTRUCTORS_2: Begin completions, 3 items
78+
// IMPLICIT_CONSTRUCTORS_2: Begin completions, 4 items
7879
// IMPLICIT_CONSTRUCTORS_2-DAG: Decl[Constructor]/CurrNominal: ({#instanceVar: Int#})[#ImplicitConstructors2#]{{; name=.+$}}
7980
// IMPLICIT_CONSTRUCTORS_2-DAG: Decl[Constructor]/CurrNominal: ()[#ImplicitConstructors2#]{{; name=.+$}}
8081
// IMPLICIT_CONSTRUCTORS_2-DAG: Keyword[self]/CurrNominal: .self[#ImplicitConstructors2.Type#]; name=self
82+
// IMPLICIT_CONSTRUCTORS_2-DAG: Keyword/CurrNominal: .Type[#ImplicitConstructors2.Type#]; name=Type
8183
// IMPLICIT_CONSTRUCTORS_2: End completions
8284
}
8385
func testImplicitConstructors2P() {
@@ -95,11 +97,12 @@ struct ExplicitConstructors1 {
9597

9698
func testExplicitConstructors1() {
9799
ExplicitConstructors1#^EXPLICIT_CONSTRUCTORS_1^#
98-
// EXPLICIT_CONSTRUCTORS_1: Begin completions, 4 items
100+
// EXPLICIT_CONSTRUCTORS_1: Begin completions, 5 items
99101
// EXPLICIT_CONSTRUCTORS_1-DAG: Decl[Constructor]/CurrNominal: ()[#ExplicitConstructors1#]{{; name=.+$}}
100102
// EXPLICIT_CONSTRUCTORS_1-DAG: Decl[Constructor]/CurrNominal: ({#a: Int#})[#ExplicitConstructors1#]{{; name=.+$}}
101103
// EXPLICIT_CONSTRUCTORS_1-DAG: Decl[Constructor]/CurrNominal: ({#a: Int#}, {#b: Float#})[#ExplicitConstructors1#]{{; name=.+$}}
102104
// EXPLICIT_CONSTRUCTORS_1-DAG: Keyword[self]/CurrNominal: .self[#ExplicitConstructors1.Type#]; name=self
105+
// EXPLICIT_CONSTRUCTORS_1-DAG: Keyword/CurrNominal: .Type[#ExplicitConstructors1.Type#]; name=Type
103106
// EXPLICIT_CONSTRUCTORS_1: End completions
104107
}
105108
func testExplicitConstructors1P() {
@@ -112,11 +115,12 @@ func testExplicitConstructors1P() {
112115

113116
ExplicitConstructors1#^EXPLICIT_CONSTRUCTORS_2^#
114117

115-
// EXPLICIT_CONSTRUCTORS_2: Begin completions, 4 items
118+
// EXPLICIT_CONSTRUCTORS_2: Begin completions, 5 items
116119
// EXPLICIT_CONSTRUCTORS_2-DAG: Decl[Constructor]/CurrNominal: ()[#ExplicitConstructors1#]
117120
// EXPLICIT_CONSTRUCTORS_2-DAG: Decl[Constructor]/CurrNominal: ({#a: Int#})[#ExplicitConstructors1#]
118121
// EXPLICIT_CONSTRUCTORS_2-DAG: Decl[Constructor]/CurrNominal: ({#a: Int#}, {#b: Float#})[#ExplicitConstructors1#]
119122
// EXPLICIT_CONSTRUCTORS_2-DAG: Keyword[self]/CurrNominal: .self[#ExplicitConstructors1.Type#]; name=self
123+
// EXPLICIT_CONSTRUCTORS_2-DAG: Keyword/CurrNominal: .Type[#ExplicitConstructors1.Type#]; name=Type
120124
// EXPLICIT_CONSTRUCTORS_2: End completions
121125

122126
ExplicitConstructors1(#^EXPLICIT_CONSTRUCTORS_2P^#
@@ -149,10 +153,11 @@ struct ExplicitConstructorsSelector1 {
149153

150154
func testExplicitConstructorsSelector1() {
151155
ExplicitConstructorsSelector1#^EXPLICIT_CONSTRUCTORS_SELECTOR_1^#
152-
// EXPLICIT_CONSTRUCTORS_SELECTOR_1: Begin completions, 3 items
156+
// EXPLICIT_CONSTRUCTORS_SELECTOR_1: Begin completions, 4 items
153157
// EXPLICIT_CONSTRUCTORS_SELECTOR_1-DAG: Decl[Constructor]/CurrNominal: ({#int: Int#})[#ExplicitConstructorsSelector1#]{{; name=.+$}}
154158
// EXPLICIT_CONSTRUCTORS_SELECTOR_1-DAG: Decl[Constructor]/CurrNominal: ({#int: Int#}, {#andFloat: Float#})[#ExplicitConstructorsSelector1#]{{; name=.+$}}
155159
// EXPLICIT_CONSTRUCTORS_SELECTOR_1-DAG: Keyword[self]/CurrNominal: .self[#ExplicitConstructorsSelector1.Type#]; name=self
160+
// EXPLICIT_CONSTRUCTORS_SELECTOR_1-DAG: Keyword/CurrNominal: .Type[#ExplicitConstructorsSelector1.Type#]; name=Type
156161
// EXPLICIT_CONSTRUCTORS_SELECTOR_1: End completions
157162
}
158163

@@ -176,12 +181,13 @@ struct ExplicitConstructorsSelector2 {
176181

177182
func testExplicitConstructorsSelector2() {
178183
ExplicitConstructorsSelector2#^EXPLICIT_CONSTRUCTORS_SELECTOR_2^#
179-
// EXPLICIT_CONSTRUCTORS_SELECTOR_2: Begin completions, 5 items
184+
// EXPLICIT_CONSTRUCTORS_SELECTOR_2: Begin completions, 6 items
180185
// EXPLICIT_CONSTRUCTORS_SELECTOR_2-DAG: Decl[Constructor]/CurrNominal: ({#noArgs: ()#})[#ExplicitConstructorsSelector2#]{{; name=.+$}}
181186
// EXPLICIT_CONSTRUCTORS_SELECTOR_2-DAG: Decl[Constructor]/CurrNominal: ({#Int#})[#ExplicitConstructorsSelector2#]{{; name=.+$}}
182187
// EXPLICIT_CONSTRUCTORS_SELECTOR_2-DAG: Decl[Constructor]/CurrNominal: ({#Int#}, {#withFloat: Float#})[#ExplicitConstructorsSelector2#]{{; name=.+$}}
183188
// EXPLICIT_CONSTRUCTORS_SELECTOR_2-DAG: Decl[Constructor]/CurrNominal: ({#int: Int#}, {#Float#})[#ExplicitConstructorsSelector2#]{{; name=.+$}}
184189
// EXPLICIT_CONSTRUCTORS_SELECTOR_2-DAG: Keyword[self]/CurrNominal: .self[#ExplicitConstructorsSelector2.Type#]; name=self
190+
// EXPLICIT_CONSTRUCTORS_SELECTOR_2-DAG: Keyword/CurrNominal: .Type[#ExplicitConstructorsSelector2.Type#]; name=Type
185191
// EXPLICIT_CONSTRUCTORS_SELECTOR_2: End completions
186192
}
187193

@@ -206,18 +212,20 @@ class ExplicitConstructorsDerived2 : ExplicitConstructorsBase1 {
206212
func testExplicitConstructorsBaseDerived1() {
207213
ExplicitConstructorsDerived1#^EXPLICIT_CONSTRUCTORS_BASE_DERIVED_1^#
208214
}
209-
// EXPLICIT_CONSTRUCTORS_BASE_DERIVED_1: Begin completions, 3 items
215+
// EXPLICIT_CONSTRUCTORS_BASE_DERIVED_1: Begin completions, 4 items
210216
// EXPLICIT_CONSTRUCTORS_BASE_DERIVED_1-DAG: Decl[Constructor]/CurrNominal: ()[#ExplicitConstructorsDerived1#]{{; name=.+$}}
211217
// EXPLICIT_CONSTRUCTORS_BASE_DERIVED_1-DAG: Decl[Constructor]/CurrNominal: ({#a: Int#})[#ExplicitConstructorsDerived1#]{{; name=.+$}}
212218
// EXPLICIT_CONSTRUCTORS_BASE_DERIVED_1-DAG: Keyword[self]/CurrNominal: .self[#ExplicitConstructorsDerived1.Type#]; name=self
219+
// EXPLICIT_CONSTRUCTORS_BASE_DERIVED_1-DAG: Keyword/CurrNominal: .Type[#ExplicitConstructorsDerived1.Type#]; name=Type
213220
// EXPLICIT_CONSTRUCTORS_BASE_DERIVED_1: End completions
214221

215222
func testGetInitFromMetatype1() {
216223
ExplicitConstructorsBase1.#^INIT_FROM_METATYPE1^#
217224
}
218225

219226
// INIT_FROM_METATYPE1: Begin completions
220-
// INIT_FROM_METATYPE1-NEXT: Keyword[self]/CurrNominal: self[#ExplicitConstructorsBase1.Type#]; name=self
227+
// INIT_FROM_METATYPE1-NEXT: Keyword[self]/CurrNominal: self[#ExplicitConstructorsBase1.Type#]; name=self
228+
// INIT_FROM_METATYPE1-NEXT: Keyword/CurrNominal: Type[#ExplicitConstructorsBase1.Type#]; name=Type
221229
// INIT_FROM_METATYPE1-NEXT: Decl[Constructor]/CurrNominal: init()[#ExplicitConstructorsBase1#]{{; name=.+$}}
222230
// INIT_FROM_METATYPE1-NEXT: Decl[Constructor]/CurrNominal: init({#a: Int#})[#ExplicitConstructorsBase1#]{{; name=.+$}}
223231
// INIT_FROM_METATYPE1-NEXT: End completions

test/IDE/complete_enum_elements.swift

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,12 @@ enum FooEnum: CaseIterable {
9999
// FOO_ENUM_NO_DOT-NEXT: Decl[TypeAlias]/CurrNominal: .AllCases[#[FooEnum]#]{{; name=.+$}}
100100
// FOO_ENUM_NO_DOT-NEXT: Decl[StaticVar]/CurrNominal: .allCases[#[FooEnum]#]{{; name=.+$}}
101101
// FOO_ENUM_NO_DOT-NEXT: Keyword[self]/CurrNominal: .self[#FooEnum.Type#]; name=self
102+
// FOO_ENUM_NO_DOT-NEXT: Keyword/CurrNominal: .Type[#FooEnum.Type#]; name=Type
102103
// FOO_ENUM_NO_DOT-NEXT: End completions
103104

104105
// FOO_ENUM_DOT: Begin completions
105106
// FOO_ENUM_DOT-NEXT: Keyword[self]/CurrNominal: self[#FooEnum.Type#]; name=self
107+
// FOO_ENUM_DOT-NEXT: Keyword/CurrNominal: Type[#FooEnum.Type#]; name=Type
106108
// FOO_ENUM_DOT-NEXT: Decl[EnumElement]/CurrNominal: Foo1[#FooEnum#]{{; name=.+$}}
107109
// FOO_ENUM_DOT-NEXT: Decl[EnumElement]/CurrNominal: Foo2[#FooEnum#]{{; name=.+$}}
108110
// FOO_ENUM_DOT-NEXT: Decl[InstanceMethod]/CurrNominal: hash({#self: FooEnum#})[#(into: inout Hasher) -> Void#]; name=hash(FooEnum)
@@ -112,6 +114,7 @@ enum FooEnum: CaseIterable {
112114

113115
// FOO_ENUM_DOT_INVALID: Begin completions
114116
// FOO_ENUM_DOT_INVALID-NEXT: Keyword[self]/CurrNominal: self[#FooEnum.Type#]; name=self
117+
// FOO_ENUM_DOT_INVALID-NEXT: Keyword/CurrNominal: Type[#FooEnum.Type#]; name=Type
115118
// FOO_ENUM_DOT_INVALID-NEXT: Decl[EnumElement]/CurrNominal: Foo1[#FooEnum#]{{; name=.+$}}
116119
// FOO_ENUM_DOT_INVALID-NEXT: Decl[EnumElement]/CurrNominal: Foo2[#FooEnum#]{{; name=.+$}}
117120
// FOO_ENUM_DOT_INVALID-NEXT: Decl[InstanceMethod]/CurrNominal/NotRecommended/TypeRelation[Invalid]: hash({#self: FooEnum#})[#(into: inout Hasher) -> Void#]; name=hash(FooEnum)
@@ -176,10 +179,12 @@ enum BarEnum {
176179
// BAR_ENUM_NO_DOT-NEXT: Decl[StaticVar]/CurrNominal: .staticVar[#Int#]{{; name=.+$}}
177180
// BAR_ENUM_NO_DOT-NEXT: Decl[StaticMethod]/CurrNominal: .barStaticFunc()[#Void#]{{; name=.+$}}
178181
// BAR_ENUM_NO_DOT-NEXT: Keyword[self]/CurrNominal: .self[#BarEnum.Type#]; name=self
182+
// BAR_ENUM_NO_DOT-NEXT: Keyword/CurrNominal: .Type[#BarEnum.Type#]; name=Type
179183
// BAR_ENUM_NO_DOT-NEXT: End completions
180184

181185
// BAR_ENUM_DOT: Begin completions
182186
// BAR_ENUM_DOT-NEXT: Keyword[self]/CurrNominal: self[#BarEnum.Type#]; name=self
187+
// BAR_ENUM_DOT-NEXT: Keyword/CurrNominal: Type[#BarEnum.Type#]; name=Type
183188
// BAR_ENUM_DOT-NEXT: Decl[EnumElement]/CurrNominal: Bar1[#BarEnum#]{{; name=.+$}}
184189
// BAR_ENUM_DOT-NEXT: Decl[EnumElement]/CurrNominal: Bar2()[#() -> BarEnum#]{{; name=.+$}}
185190
// BAR_ENUM_DOT-NEXT: Decl[EnumElement]/CurrNominal: Bar3({#Int#})[#(Int) -> BarEnum#]{{; name=.+$}}
@@ -213,14 +218,15 @@ enum BazEnum<T> {
213218
// BAZ_ENUM_TYPE_CONTEXT-DAG: Decl[EnumElement]/ExprSpecific: .Baz2({#T#})[#(T) -> BazEnum<T>#]{{; name=.+$}}
214219
// BAZ_ENUM_TYPE_CONTEXT: End completions
215220

216-
// BAZ_INT_ENUM_NO_DOT: Begin completions, 7 items
221+
// BAZ_INT_ENUM_NO_DOT: Begin completions, 8 items
217222
// BAZ_INT_ENUM_NO_DOT-NEXT: Decl[EnumElement]/CurrNominal: .Baz1[#BazEnum<T>#]{{; name=.+$}}
218223
// BAZ_INT_ENUM_NO_DOT-NEXT: Decl[EnumElement]/CurrNominal: .Baz2({#T#})[#(T) -> BazEnum<T>#]{{; name=.+$}}
219224
// BAZ_INT_ENUM_NO_DOT-NEXT: Decl[InstanceMethod]/CurrNominal: .bazInstanceFunc({#self: &BazEnum<Int>#})[#() -> Void#]{{; name=.+$}}
220225
// BAZ_INT_ENUM_NO_DOT-NEXT: Decl[StaticVar]/CurrNominal: .staticVar[#Int#]{{; name=.+$}}
221226
// BAZ_INT_ENUM_NO_DOT-NEXT: Decl[StaticVar]/CurrNominal: .staticVarT[#Int#]{{; name=.+$}}
222227
// BAZ_INT_ENUM_NO_DOT-NEXT: Decl[StaticMethod]/CurrNominal: .bazStaticFunc()[#Void#]{{; name=.+$}}
223228
// BAZ_INT_ENUM_NO_DOT-NEXT: Keyword[self]/CurrNominal: .self[#BazEnum<Int>.Type#]; name=self
229+
// BAZ_INT_ENUM_NO_DOT-NEXT: Keyword/CurrNominal: .Type[#BazEnum<Int>.Type#]; name=Type
224230
// BAZ_INT_ENUM_NO_DOT-NEXT: End completions
225231

226232
// BAZ_T_ENUM_NO_DOT: Begin completions
@@ -231,10 +237,12 @@ enum BazEnum<T> {
231237
// BAZ_T_ENUM_NO_DOT-NEXT: Decl[StaticVar]/CurrNominal: .staticVarT[#_#]{{; name=.+$}}
232238
// BAZ_T_ENUM_NO_DOT-NEXT: Decl[StaticMethod]/CurrNominal: .bazStaticFunc()[#Void#]{{; name=.+$}}
233239
// BAZ_T_ENUM_NO_DOT-NEXT: Keyword[self]/CurrNominal: .self[#BazEnum<_>.Type#]; name=self
240+
// BAZ_T_ENUM_NO_DOT-NEXT: Keyword/CurrNominal: .Type[#BazEnum<_>.Type#]; name=Type
234241
// BAZ_T_ENUM_NO_DOT-NEXT: End completions
235242

236-
// BAZ_INT_ENUM_DOT: Begin completions, 7 items
243+
// BAZ_INT_ENUM_DOT: Begin completions, 8 items
237244
// BAZ_INT_ENUM_DOT-NEXT: Keyword[self]/CurrNominal: self[#BazEnum<Int>.Type#]; name=self
245+
// BAZ_INT_ENUM_DOT-NEXT: Keyword/CurrNominal: Type[#BazEnum<Int>.Type#]; name=Type
238246
// BAZ_INT_ENUM_DOT-NEXT: Decl[EnumElement]/CurrNominal: Baz1[#BazEnum<T>#]{{; name=.+$}}
239247
// BAZ_INT_ENUM_DOT-NEXT: Decl[EnumElement]/CurrNominal: Baz2({#T#})[#(T) -> BazEnum<T>#]{{; name=.+$}}
240248
// BAZ_INT_ENUM_DOT-NEXT: Decl[InstanceMethod]/CurrNominal/NotRecommended/TypeRelation[Invalid]: bazInstanceFunc({#self: &BazEnum<Int>#})[#() -> Void#]{{; name=.+$}}
@@ -243,8 +251,9 @@ enum BazEnum<T> {
243251
// BAZ_INT_ENUM_DOT-NEXT: Decl[StaticMethod]/CurrNominal/NotRecommended/TypeRelation[Invalid]: bazStaticFunc()[#Void#]{{; name=.+$}}
244252
// BAZ_INT_ENUM_DOT-NEXT: End completions
245253

246-
// BAZ_T_ENUM_DOT: Begin completions, 7 items
254+
// BAZ_T_ENUM_DOT: Begin completions, 8 items
247255
// BAZ_T_ENUM_DOT-NEXT: Keyword[self]/CurrNominal: self[#BazEnum<_>.Type#]; name=self
256+
// BAZ_T_ENUM_DOT-NEXT: Keyword/CurrNominal: Type[#BazEnum<_>.Type#]; name=Type
248257
// BAZ_T_ENUM_DOT-NEXT: Decl[EnumElement]/CurrNominal: Baz1[#BazEnum<T>#]{{; name=.+$}}
249258
// BAZ_T_ENUM_DOT-NEXT: Decl[EnumElement]/CurrNominal: Baz2({#T#})[#(T) -> BazEnum<T>#]{{; name=.+$}}
250259
// BAZ_T_ENUM_DOT-NEXT: Decl[InstanceMethod]/CurrNominal: bazInstanceFunc({#self: &BazEnum<_>#})[#() -> Void#]{{; name=.+$}}
@@ -263,17 +272,19 @@ enum QuxEnum : Int {
263272
// QUX_ENUM_TYPE_CONTEXT-DAG: Decl[EnumElement]/ExprSpecific: .Qux2[#QuxEnum#]{{; name=.+$}}
264273
// QUX_ENUM_TYPE_CONTEXT: End completions
265274

266-
// QUX_ENUM_NO_DOT: Begin completions, 6 items
275+
// QUX_ENUM_NO_DOT: Begin completions, 7 items
267276
// QUX_ENUM_NO_DOT-NEXT: Decl[EnumElement]/CurrNominal: .Qux1[#QuxEnum#]{{; name=.+$}}
268277
// QUX_ENUM_NO_DOT-NEXT: Decl[EnumElement]/CurrNominal: .Qux2[#QuxEnum#]{{; name=.+$}}
269278
// QUX_ENUM_NO_DOT-NEXT: Decl[TypeAlias]/CurrNominal: .RawValue[#Int#]{{; name=.+$}}
270279
// QUX_ENUM_NO_DOT-NEXT: Decl[Constructor]/CurrNominal: ({#rawValue: Int#})[#QuxEnum?#]{{; name=.+$}}
271280
// QUX_ENUM_NO_DOT-NEXT: Decl[InstanceMethod]/Super: .hash({#self: QuxEnum#})[#(into: inout Hasher) -> Void#]; name=hash(QuxEnum)
272281
// QUX_ENUM_NO_DOT-NEXT: Keyword[self]/CurrNominal: .self[#QuxEnum.Type#]; name=self
282+
// QUX_ENUM_NO_DOT-NEXT: Keyword/CurrNominal: .Type[#QuxEnum.Type#]; name=Type
273283
// QUX_ENUM_NO_DOT-NEXT: End completions
274284

275-
// QUX_ENUM_DOT: Begin completions, 6 items
285+
// QUX_ENUM_DOT: Begin completions, 7 items
276286
// QUX_ENUM_DOT-NEXT: Keyword[self]/CurrNominal: self[#QuxEnum.Type#]; name=self
287+
// QUX_ENUM_DOT-NEXT: Keyword/CurrNominal: Type[#QuxEnum.Type#]; name=Type
277288
// QUX_ENUM_DOT-NEXT: Decl[EnumElement]/CurrNominal: Qux1[#QuxEnum#]{{; name=.+$}}
278289
// QUX_ENUM_DOT-NEXT: Decl[EnumElement]/CurrNominal: Qux2[#QuxEnum#]{{; name=.+$}}
279290
// QUX_ENUM_DOT-NEXT: Decl[TypeAlias]/CurrNominal: RawValue[#Int#]{{; name=.+$}}

test/IDE/complete_from_clang_framework.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ func testCompleteStructMembers1() {
246246
// CLANG_STRUCT_MEMBERS_1-NEXT: Decl[Constructor]/CurrNominal: ()[#FooStruct1#]{{; name=.+$}}
247247
// CLANG_STRUCT_MEMBERS_1-NEXT: Decl[Constructor]/CurrNominal: ({#x: Int32#}, {#y: Double#})[#FooStruct1#]{{; name=.+$}}
248248
// CLANG_STRUCT_MEMBERS_1-NEXT: Keyword[self]/CurrNominal: .self[#FooStruct1.Type#]; name=self
249+
// CLANG_STRUCT_MEMBERS_1-NEXT: Keyword/CurrNominal: .Type[#FooStruct1.Type#]; name=Type
249250
// CLANG_STRUCT_MEMBERS_1-NEXT: End completions
250251
}
251252

@@ -272,6 +273,7 @@ func testCompleteClassMembers1() {
272273
// CLANG_CLASS_MEMBERS_1-NEXT: Decl[StaticMethod]/CurrNominal: ._internalMeth1()[#Any!#]
273274
// CLANG_CLASS_MEMBERS_1-NEXT: Decl[InstanceMethod]/CurrNominal: ._internalMeth1({#self: FooClassBase#})[#() -> Any?#]
274275
// CLANG_CLASS_MEMBERS_1-NEXT: Keyword[self]/CurrNominal: .self[#FooClassBase.Type#]; name=self
276+
// CLANG_CLASS_MEMBERS_1-NEXT: Keyword/CurrNominal: .Type[#FooClassBase.Type#]; name=Type
275277
// CLANG_CLASS_MEMBERS_1-NEXT: End completions
276278
}
277279

@@ -305,6 +307,7 @@ func testCompleteClassMembers2() {
305307
// CLANG_CLASS_MEMBERS_2-NEXT: Decl[StaticMethod]/Super: ._internalMeth1()[#Any!#]
306308
// CLANG_CLASS_MEMBERS_2-NEXT: Decl[InstanceMethod]/Super: ._internalMeth1({#self: FooClassBase#})[#() -> Any?#]
307309
// CLANG_CLASS_MEMBERS_2-NEXT: Keyword[self]/CurrNominal: .self[#FooClassDerived.Type#]; name=self
310+
// CLANG_CLASS_MEMBERS_2-NEXT: Keyword/CurrNominal: .Type[#FooClassDerived.Type#]; name=Type
308311
// CLANG_CLASS_MEMBERS_2-NEXT: End completions
309312
}
310313

0 commit comments

Comments
 (0)