Skip to content

Commit 673d6a1

Browse files
committed
[IDE] Rename CustomSyntaxAttributeKind to ParameterizedDeclAttributeKind
1 parent 8c4dea9 commit 673d6a1

File tree

5 files changed

+26
-24
lines changed

5 files changed

+26
-24
lines changed

include/swift/IDE/CompletionLookup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
612612

613613
void getAttributeDeclCompletions(bool IsInSil, std::optional<DeclKind> DK);
614614

615-
void getAttributeDeclParamCompletions(CustomSyntaxAttributeKind AttrKind,
615+
void getAttributeDeclParamCompletions(ParameterizedDeclAttributeKind AttrKind,
616616
int ParamIndex, bool HasLabel);
617617

618618
void getTypeAttributeKeywordCompletions(CompletionKind completionKind);

include/swift/Parse/IDEInspectionCallbacks.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ enum class ObjCSelectorContext {
3232
/// Attributes that have syntax which can't be modelled using a function call.
3333
/// This can't be \c DeclAttrKind because '@freestandig' and '@attached' have
3434
/// the same attribute kind but take different macro roles as arguemnts.
35-
enum class CustomSyntaxAttributeKind {
35+
enum class ParameterizedDeclAttributeKind {
3636
Available,
3737
FreestandingMacro,
3838
AttachedMacro,
@@ -228,7 +228,7 @@ class CodeCompletionCallbacks {
228228
/// @available.
229229
/// If `HasLabel` is `true`, then the argument already has a label specified,
230230
/// e.g. we're completing after `names: ` in a macro declaration.
231-
virtual void completeDeclAttrParam(CustomSyntaxAttributeKind DK, int Index,
231+
virtual void completeDeclAttrParam(ParameterizedDeclAttributeKind DK, int Index,
232232
bool HasLabel){};
233233

234234
/// Complete 'async' and 'throws' at effects specifier position.

lib/IDE/CodeCompletion.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class CodeCompletionCallbacksImpl : public CodeCompletionCallbacks,
114114
SourceLoc DotLoc;
115115
TypeLoc ParsedTypeLoc;
116116
DeclContext *CurDeclContext = nullptr;
117-
CustomSyntaxAttributeKind AttrKind;
117+
ParameterizedDeclAttributeKind AttrKind;
118118

119119
/// When the code completion token occurs in a custom attribute, the attribute
120120
/// it occurs in. Used so we can complete inside the attribute even if it's
@@ -272,7 +272,7 @@ class CodeCompletionCallbacksImpl : public CodeCompletionCallbacks,
272272
void completeCaseStmtKeyword() override;
273273
void completeCaseStmtBeginning(CodeCompletionExpr *E) override;
274274
void completeDeclAttrBeginning(bool Sil, bool isIndependent) override;
275-
void completeDeclAttrParam(CustomSyntaxAttributeKind DK, int Index,
275+
void completeDeclAttrParam(ParameterizedDeclAttributeKind DK, int Index,
276276
bool HasLabel) override;
277277
void completeEffectsSpecifier(bool hasAsync, bool hasThrows) override;
278278
void completeInPrecedenceGroup(
@@ -460,7 +460,9 @@ void CodeCompletionCallbacksImpl::completeTypeSimpleBeginning() {
460460
}
461461

462462
void CodeCompletionCallbacksImpl::completeDeclAttrParam(
463-
CustomSyntaxAttributeKind DK, int Index, bool HasLabel) {
463+
ParameterizedDeclAttributeKind DK, int Index, bool HasLabel) {
464+
assert(P.Tok.is(tok::code_complete));
465+
464466
Kind = CompletionKind::AttributeDeclParen;
465467
AttrKind = DK;
466468
AttrParamIndex = Index;

lib/IDE/CompletionLookup.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3103,9 +3103,9 @@ void CompletionLookup::getAttributeDeclCompletions(bool IsInSil,
31033103
}
31043104

31053105
void CompletionLookup::getAttributeDeclParamCompletions(
3106-
CustomSyntaxAttributeKind AttrKind, int ParamIndex, bool HasLabel) {
3106+
ParameterizedDeclAttributeKind AttrKind, int ParamIndex, bool HasLabel) {
31073107
switch (AttrKind) {
3108-
case CustomSyntaxAttributeKind::Available:
3108+
case ParameterizedDeclAttributeKind::Available:
31093109
if (ParamIndex == 0) {
31103110
addDeclAttrParamKeyword("*", /*Parameters=*/{}, "Platform", false);
31113111

@@ -3126,15 +3126,15 @@ void CompletionLookup::getAttributeDeclParamCompletions(
31263126
"Specify version number", true);
31273127
}
31283128
break;
3129-
case CustomSyntaxAttributeKind::FreestandingMacro:
3130-
case CustomSyntaxAttributeKind::AttachedMacro:
3129+
case ParameterizedDeclAttributeKind::FreestandingMacro:
3130+
case ParameterizedDeclAttributeKind::AttachedMacro:
31313131
switch (ParamIndex) {
31323132
case 0:
31333133
for (auto role : getAllMacroRoles()) {
31343134
bool isRoleSupported = isMacroSupported(role, Ctx);
3135-
if (AttrKind == CustomSyntaxAttributeKind::FreestandingMacro) {
3135+
if (AttrKind == ParameterizedDeclAttributeKind::FreestandingMacro) {
31363136
isRoleSupported &= isFreestandingMacro(role);
3137-
} else if (AttrKind == CustomSyntaxAttributeKind::AttachedMacro) {
3137+
} else if (AttrKind == ParameterizedDeclAttributeKind::AttachedMacro) {
31383138
isRoleSupported &= isAttachedMacro(role);
31393139
}
31403140
if (isRoleSupported) {
@@ -3162,7 +3162,7 @@ void CompletionLookup::getAttributeDeclParamCompletions(
31623162
break;
31633163
}
31643164
break;
3165-
case CustomSyntaxAttributeKind::StorageRestrictions: {
3165+
case ParameterizedDeclAttributeKind::StorageRestrictions: {
31663166
bool suggestInitializesLabel = false;
31673167
bool suggestAccessesLabel = false;
31683168
bool suggestArgument = false;
@@ -3295,7 +3295,7 @@ void CompletionLookup::getPrecedenceGroupCompletions(
32953295
void CompletionLookup::getPoundAvailablePlatformCompletions() {
32963296

32973297
// The platform names should be identical to those in @available.
3298-
getAttributeDeclParamCompletions(CustomSyntaxAttributeKind::Available, 0,
3298+
getAttributeDeclParamCompletions(ParameterizedDeclAttributeKind::Available, 0,
32993299
/*HasLabel=*/false);
33003300
}
33013301

lib/Parse/ParseDecl.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ ParserResult<AvailableAttr> Parser::parseExtendedAvailabilitySpecList(
396396
.highlight(SourceRange(ArgumentLoc));
397397
if (Tok.is(tok::code_complete) && CodeCompletionCallbacks) {
398398
CodeCompletionCallbacks->completeDeclAttrParam(
399-
CustomSyntaxAttributeKind::Available, ParamIndex,
399+
ParameterizedDeclAttributeKind::Available, ParamIndex,
400400
/*HasLabel=*/false);
401401
consumeToken(tok::code_complete);
402402
} else {
@@ -737,7 +737,7 @@ bool Parser::parseAvailability(
737737
!(Tok.isAnyOperator() && Tok.getText() == "*")) {
738738
if (Tok.is(tok::code_complete) && CodeCompletionCallbacks) {
739739
CodeCompletionCallbacks->completeDeclAttrParam(
740-
CustomSyntaxAttributeKind::Available, 0, /*HasLabel=*/false);
740+
ParameterizedDeclAttributeKind::Available, 0, /*HasLabel=*/false);
741741
consumeToken(tok::code_complete);
742742
}
743743
diagnose(Tok.getLoc(), diag::attr_availability_platform, AttrName)
@@ -993,7 +993,7 @@ Parser::parseStorageRestrictionsAttribute(SourceLoc AtLoc, SourceLoc Loc) {
993993
}
994994
}
995995
this->CodeCompletionCallbacks->completeDeclAttrParam(
996-
CustomSyntaxAttributeKind::StorageRestrictions,
996+
ParameterizedDeclAttributeKind::StorageRestrictions,
997997
static_cast<int>(completionKind), /*HasLabel=*/false);
998998
}
999999
} else if (parseIdentifier(propertyName, propertyNameLoc,
@@ -1026,7 +1026,7 @@ Parser::parseStorageRestrictionsAttribute(SourceLoc AtLoc, SourceLoc Loc) {
10261026
if (consumeIf(tok::code_complete)) {
10271027
if (this->CodeCompletionCallbacks) {
10281028
this->CodeCompletionCallbacks->completeDeclAttrParam(
1029-
CustomSyntaxAttributeKind::StorageRestrictions,
1029+
ParameterizedDeclAttributeKind::StorageRestrictions,
10301030
static_cast<int>(StorageRestrictionsCompletionKind::Label),
10311031
/*HasLabel=*/false);
10321032
}
@@ -2214,11 +2214,11 @@ std::optional<MacroRole> getMacroRole(StringRef roleName) {
22142214
.Default(std::nullopt);
22152215
}
22162216

2217-
static CustomSyntaxAttributeKind getCustomSyntaxAttributeKind(bool isAttached) {
2217+
static ParameterizedDeclAttributeKind getParameterizedDeclAttributeKind(bool isAttached) {
22182218
if (isAttached) {
2219-
return CustomSyntaxAttributeKind::AttachedMacro;
2219+
return ParameterizedDeclAttributeKind::AttachedMacro;
22202220
} else {
2221-
return CustomSyntaxAttributeKind::FreestandingMacro;
2221+
return ParameterizedDeclAttributeKind::FreestandingMacro;
22222222
}
22232223
}
22242224

@@ -2265,13 +2265,13 @@ Parser::parseMacroRoleAttribute(
22652265
sawRole = true;
22662266
if (this->CodeCompletionCallbacks) {
22672267
this->CodeCompletionCallbacks->completeDeclAttrParam(
2268-
getCustomSyntaxAttributeKind(isAttached), 0,
2268+
getParameterizedDeclAttributeKind(isAttached), 0,
22692269
/*HasLabel=*/false);
22702270
}
22712271
} else if (!sawNames) {
22722272
if (this->CodeCompletionCallbacks) {
22732273
this->CodeCompletionCallbacks->completeDeclAttrParam(
2274-
getCustomSyntaxAttributeKind(isAttached), 1,
2274+
getParameterizedDeclAttributeKind(isAttached), 1,
22752275
/*HasLabel=*/false);
22762276
}
22772277
}
@@ -2373,7 +2373,7 @@ Parser::parseMacroRoleAttribute(
23732373
status.setHasCodeCompletionAndIsError();
23742374
if (this->CodeCompletionCallbacks) {
23752375
this->CodeCompletionCallbacks->completeDeclAttrParam(
2376-
getCustomSyntaxAttributeKind(isAttached), 1, /*HasLabel=*/true);
2376+
getParameterizedDeclAttributeKind(isAttached), 1, /*HasLabel=*/true);
23772377
}
23782378
} else if (parseIdentifier(introducedNameKind, introducedNameKindLoc,
23792379
diag::macro_attribute_unknown_argument_form,

0 commit comments

Comments
 (0)