File tree Expand file tree Collapse file tree 3 files changed +33
-2
lines changed Expand file tree Collapse file tree 3 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -3058,6 +3058,10 @@ class alignas(1 << AttrAlignInBits) TypeAttribute
3058
3058
// / Return the name (like "autoclosure") for an attribute ID.
3059
3059
static const char *getAttrName (TypeAttrKind kind);
3060
3060
3061
+ // / Returns whether the given attribute is considered "user inaccessible",
3062
+ // / which affects e.g whether it shows up in code completion.
3063
+ static bool isUserInaccessible (TypeAttrKind DK);
3064
+
3061
3065
static TypeAttribute *createSimple (const ASTContext &context,
3062
3066
TypeAttrKind kind,
3063
3067
SourceLoc atLoc,
Original file line number Diff line number Diff line change @@ -146,6 +146,24 @@ const char *TypeAttribute::getAttrName(TypeAttrKind kind) {
146
146
llvm_unreachable (" unknown type attribute kind" );
147
147
}
148
148
149
+ bool TypeAttribute::isUserInaccessible (TypeAttrKind DK) {
150
+ // Currently we can base this off whether it is underscored or for SIL.
151
+ // TODO: We could introduce a similar options scheme to DECL_ATTR if we ever
152
+ // need a user-inaccessible non-underscored attribute.
153
+ switch (DK) {
154
+ // SIL attributes are always considered user-inaccessible.
155
+ #define SIL_TYPE_ATTR (SPELLING, C ) \
156
+ case TypeAttrKind::C: \
157
+ return true ;
158
+ // For non-SIL attributes, check whether the spelling is underscored.
159
+ #define TYPE_ATTR (SPELLING, C ) \
160
+ case TypeAttrKind::C: \
161
+ return StringRef (#SPELLING).starts_with (" _" );
162
+ #include " swift/AST/TypeAttr.def"
163
+ }
164
+ llvm_unreachable (" unhandled case in switch!" );
165
+ }
166
+
149
167
TypeAttribute *TypeAttribute::createSimple (const ASTContext &context,
150
168
TypeAttrKind kind,
151
169
SourceLoc atLoc,
Original file line number Diff line number Diff line change @@ -3138,12 +3138,21 @@ void CompletionLookup::getTypeAttributeKeywordCompletions() {
3138
3138
CodeCompletionResultKind::Keyword, SemanticContextKind::None);
3139
3139
Builder.addAttributeKeyword (Name, " Type Attribute" );
3140
3140
};
3141
- addTypeAttr (" autoclosure" );
3141
+
3142
+ // Add simple user-accessible attributes.
3143
+ #define SIL_TYPE_ATTR (SPELLING, C )
3144
+ #define SIMPLE_SIL_TYPE_ATTR (SPELLING, C )
3145
+ #define SIMPLE_TYPE_ATTR (SPELLING, C ) \
3146
+ if (!TypeAttribute::isUserInaccessible (TypeAttrKind::C)) \
3147
+ addTypeAttr (#SPELLING);
3148
+ #include " swift/AST/TypeAttr.def"
3149
+
3150
+ // Add non-simple cases.
3142
3151
addTypeAttr (" convention(swift)" );
3143
3152
addTypeAttr (" convention(block)" );
3144
3153
addTypeAttr (" convention(c)" );
3145
3154
addTypeAttr (" convention(thin)" );
3146
- addTypeAttr (" escaping " );
3155
+ addTypeAttr (" isolated(any) " );
3147
3156
}
3148
3157
3149
3158
void CompletionLookup::collectPrecedenceGroups () {
You can’t perform that action at this time.
0 commit comments