@@ -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,43 @@ void CompletionLookup::getAttributeDeclParamCompletions(
2969
2988
break ;
2970
2989
}
2971
2990
break ;
2991
+ case CustomSyntaxAttributeKind::StorageRestrictions: {
2992
+ bool suggestInitializesLabel = false ;
2993
+ bool suggestAccessesLabel = false ;
2994
+ bool suggestArgument = false ;
2995
+ switch (static_cast <StorageRestrictionsCompletionKind>(ParamIndex)) {
2996
+ case StorageRestrictionsCompletionKind::Label:
2997
+ suggestAccessesLabel = true ;
2998
+ suggestInitializesLabel = true ;
2999
+ break ;
3000
+ case StorageRestrictionsCompletionKind::Argument:
3001
+ suggestArgument = true ;
3002
+ break ;
3003
+ case StorageRestrictionsCompletionKind::ArgumentOrInitializesLabel:
3004
+ suggestArgument = true ;
3005
+ suggestInitializesLabel = true ;
3006
+ break ;
3007
+ case StorageRestrictionsCompletionKind::ArgumentOrAccessesLabel:
3008
+ suggestArgument = true ;
3009
+ suggestAccessesLabel = true ;
3010
+ break ;
3011
+ }
3012
+ if (suggestInitializesLabel) {
3013
+ addDeclAttrParamKeyword (" initializes" , /* Parameters=*/ {},
3014
+ " Specify variables initialized by the accessor" ,
3015
+ true );
3016
+ }
3017
+ if (suggestAccessesLabel) {
3018
+ addDeclAttrParamKeyword (" accesses" , /* Parameters=*/ {},
3019
+ " Specify variables accessed by the accessor" ,
3020
+ true );
3021
+ }
3022
+ if (suggestArgument) {
3023
+ if (auto NT = dyn_cast<NominalTypeDecl>(CurrDeclContext)) {
3024
+ getStoredPropertyCompletions (NT);
3025
+ }
3026
+ }
3027
+ }
2972
3028
}
2973
3029
}
2974
3030
0 commit comments