-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[CodeCompletion] Add fake type annotation to custom attributes #67806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CodeCompletion] Add fake type annotation to custom attributes #67806
Conversation
59c1c86
to
d7f41eb
Compare
@swift-ci Please smoke test |
lib/IDE/CompletionLookup.cpp
Outdated
@@ -1822,9 +1886,13 @@ void CompletionLookup::addMacroExpansion(const MacroDecl *MD, | |||
Builder.addRightParen(); | |||
} | |||
|
|||
if (!MD->getResultInterfaceType()->isVoid()) { | |||
auto roles = MD->getMacroRoles(); | |||
if (roles.containsOnly(MacroRole::Extension)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to handle extension macros specially here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a typo of Expression 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, expression makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool!
lib/IDE/CompletionLookup.cpp
Outdated
if (attrRoleStrs.size() == 0) | ||
return attrRoleStrs[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be attrRoleStrs.size() == 1
?
lib/IDE/CompletionLookup.cpp
Outdated
if (roles.contains(MacroRole::Extension)) | ||
roleStrs.push_back("Extension Macro"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look like this case is duplicated from above?
lib/IDE/CompletionLookup.cpp
Outdated
if (attrRoleStrs.size() == 0) | ||
return attrRoleStrs[0]; | ||
|
||
stash.clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of clearing, would it be better to assert that it's empty? As otherwise, callers relying on a StringRef may be surprised that calling again could potentially empty it out.
Macros and custom attribute types (i.e. `@resultBuilder`, `@propertyWrapper`, and `@globalActor`) now have fake type annotations. This would be useful to recognize which candidates are actually usable in code completions after `@`. rdar://109062582
d7f41eb
to
fcaae5c
Compare
@swift-ci Please smoke test |
1 similar comment
@swift-ci Please smoke test |
Macros and custom attribute types (i.e.
@resultBuilder
,@propertyWrapper
, and@globalActor
) now have fake type annotations. This would be useful to recognize which candidates are actually usable in code completions after@
.rdar://109062582