@@ -1305,6 +1305,7 @@ bool CompletionLookup::isImplicitlyCurriedInstanceMethod(
13051305
13061306 switch (Kind) {
13071307 case LookupKind::ValueExpr:
1308+ case LookupKind::StoredProperty:
13081309 return ExprType->is <AnyMetatypeType>();
13091310 case LookupKind::ValueInDeclContext:
13101311 if (InsideStaticMethod)
@@ -2248,6 +2249,13 @@ void CompletionLookup::foundDecl(ValueDecl *D, DeclVisibilityKind Reason,
22482249 }
22492250
22502251 return ;
2252+ case LookupKind::StoredProperty:
2253+ if (auto *VD = dyn_cast<VarDecl>(D)) {
2254+ if (VD->getImplInfo ().hasStorage ()) {
2255+ addVarDeclRef (VD, Reason, dynamicLookupInfo);
2256+ }
2257+ return ;
2258+ }
22512259 }
22522260}
22532261
@@ -2463,6 +2471,17 @@ void CompletionLookup::getValueExprCompletions(Type ExprType, ValueDecl *VD,
24632471 /* includeProtocolExtensionMembers*/ true );
24642472}
24652473
2474+ void CompletionLookup::getStoredPropertyCompletions (const NominalTypeDecl *D) {
2475+ Kind = LookupKind::StoredProperty;
2476+ NeedLeadingDot = false ;
2477+
2478+ lookupVisibleMemberDecls (*this , D->getDeclaredInterfaceType (),
2479+ /* DotLoc=*/ SourceLoc (), CurrDeclContext,
2480+ /* IncludeInstanceMembers*/ true ,
2481+ /* includeDerivedRequirements*/ false ,
2482+ /* includeProtocolExtensionMembers*/ false );
2483+ }
2484+
24662485void CompletionLookup::collectOperators (
24672486 SmallVectorImpl<OperatorDecl *> &results) {
24682487 assert (CurrDeclContext);
@@ -3051,6 +3070,43 @@ void CompletionLookup::getAttributeDeclParamCompletions(
30513070 break ;
30523071 }
30533072 break ;
3073+ case CustomSyntaxAttributeKind::StorageRestrictions: {
3074+ bool suggestInitializesLabel = false ;
3075+ bool suggestAccessesLabel = false ;
3076+ bool suggestArgument = false ;
3077+ switch (static_cast <StorageRestrictionsCompletionKind>(ParamIndex)) {
3078+ case StorageRestrictionsCompletionKind::Label:
3079+ suggestAccessesLabel = true ;
3080+ suggestInitializesLabel = true ;
3081+ break ;
3082+ case StorageRestrictionsCompletionKind::Argument:
3083+ suggestArgument = true ;
3084+ break ;
3085+ case StorageRestrictionsCompletionKind::ArgumentOrInitializesLabel:
3086+ suggestArgument = true ;
3087+ suggestInitializesLabel = true ;
3088+ break ;
3089+ case StorageRestrictionsCompletionKind::ArgumentOrAccessesLabel:
3090+ suggestArgument = true ;
3091+ suggestAccessesLabel = true ;
3092+ break ;
3093+ }
3094+ if (suggestInitializesLabel) {
3095+ addDeclAttrParamKeyword (
3096+ " initializes" , /* Parameters=*/ {},
3097+ " Specify stored properties initialized by the accessor" , true );
3098+ }
3099+ if (suggestAccessesLabel) {
3100+ addDeclAttrParamKeyword (
3101+ " accesses" , /* Parameters=*/ {},
3102+ " Specify stored properties accessed by the accessor" , true );
3103+ }
3104+ if (suggestArgument) {
3105+ if (auto NT = dyn_cast<NominalTypeDecl>(CurrDeclContext)) {
3106+ getStoredPropertyCompletions (NT);
3107+ }
3108+ }
3109+ }
30543110 }
30553111}
30563112
0 commit comments