@@ -1305,6 +1305,7 @@ bool CompletionLookup::isImplicitlyCurriedInstanceMethod(
1305
1305
1306
1306
switch (Kind) {
1307
1307
case LookupKind::ValueExpr:
1308
+ case LookupKind::StoredProperty:
1308
1309
return ExprType->is <AnyMetatypeType>();
1309
1310
case LookupKind::ValueInDeclContext:
1310
1311
if (InsideStaticMethod)
@@ -2166,6 +2167,13 @@ void CompletionLookup::foundDecl(ValueDecl *D, DeclVisibilityKind Reason,
2166
2167
}
2167
2168
2168
2169
return ;
2170
+ case LookupKind::StoredProperty:
2171
+ if (auto *VD = dyn_cast<VarDecl>(D)) {
2172
+ if (VD->getImplInfo ().hasStorage ()) {
2173
+ addVarDeclRef (VD, Reason, dynamicLookupInfo);
2174
+ }
2175
+ return ;
2176
+ }
2169
2177
}
2170
2178
}
2171
2179
@@ -2381,6 +2389,17 @@ void CompletionLookup::getValueExprCompletions(Type ExprType, ValueDecl *VD,
2381
2389
/* includeProtocolExtensionMembers*/ true );
2382
2390
}
2383
2391
2392
+ void CompletionLookup::getStoredPropertyCompletions (const NominalTypeDecl *D) {
2393
+ Kind = LookupKind::StoredProperty;
2394
+ NeedLeadingDot = false ;
2395
+
2396
+ lookupVisibleMemberDecls (*this , D->getDeclaredInterfaceType (),
2397
+ /* DotLoc=*/ SourceLoc (), CurrDeclContext,
2398
+ /* IncludeInstanceMembers*/ true ,
2399
+ /* includeDerivedRequirements*/ false ,
2400
+ /* includeProtocolExtensionMembers*/ false );
2401
+ }
2402
+
2384
2403
void CompletionLookup::collectOperators (
2385
2404
SmallVectorImpl<OperatorDecl *> &results) {
2386
2405
assert (CurrDeclContext);
@@ -2969,6 +2988,44 @@ void CompletionLookup::getAttributeDeclParamCompletions(
2969
2988
break ;
2970
2989
}
2971
2990
break ;
2991
+ case CustomSyntaxAttributeKind::StorageRestrictions:
2992
+ if (!HasLabel) {
2993
+ bool suggestInitializesLabel = false ;
2994
+ bool suggestAccessesLabel = false ;
2995
+ bool suggestArgument = false ;
2996
+ switch (static_cast <StorageRestrictionsCompletionKind>(ParamIndex)) {
2997
+ case StorageRestrictionsCompletionKind::Label:
2998
+ suggestAccessesLabel = true ;
2999
+ suggestInitializesLabel = true ;
3000
+ break ;
3001
+ case StorageRestrictionsCompletionKind::Argument:
3002
+ suggestArgument = true ;
3003
+ break ;
3004
+ case StorageRestrictionsCompletionKind::ArgumentOrInitializesLabel:
3005
+ suggestArgument = true ;
3006
+ suggestInitializesLabel = true ;
3007
+ break ;
3008
+ case StorageRestrictionsCompletionKind::ArgumentOrAccessesLabel:
3009
+ suggestArgument = true ;
3010
+ suggestAccessesLabel = true ;
3011
+ break ;
3012
+ }
3013
+ if (suggestInitializesLabel) {
3014
+ addDeclAttrParamKeyword (" initializes" , /* Parameters=*/ {},
3015
+ " Specify variables initialized by the accessor" ,
3016
+ true );
3017
+ }
3018
+ if (suggestAccessesLabel) {
3019
+ addDeclAttrParamKeyword (" accesses" , /* Parameters=*/ {},
3020
+ " Specify variables accessed by the accessor" ,
3021
+ true );
3022
+ }
3023
+ if (suggestArgument) {
3024
+ if (auto NT = dyn_cast<NominalTypeDecl>(CurrDeclContext)) {
3025
+ getStoredPropertyCompletions (NT);
3026
+ }
3027
+ }
3028
+ }
2972
3029
}
2973
3030
}
2974
3031
0 commit comments