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