-
Notifications
You must be signed in to change notification settings - Fork 440
[SwiftLexicalLookup] Add dollar identifier, better extension handling and more ASTScope
related fixes
#2877
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
[SwiftLexicalLookup] Add dollar identifier, better extension handling and more ASTScope
related fixes
#2877
Conversation
…d type generic parameters and where clause handling.
@swift-ci Please test |
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.
Just a couple of minor comments, these are great improvements.
+ [.lookInGenericParametersOfExtendedType(self)] | ||
+ defaultLookupImplementation(identifier, at: lookUpPosition, with: config, propagateToParent: false) | ||
+ [.lookInMembers(self)] | ||
+ lookupInParent(identifier, at: lookUpPosition, with: config) |
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.
That's a lot of array concatenation, but I like how it very clearly shows each of the necessary lookup steps in the appropriate order. (No action needed)
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.
I also like how it shows the steps, but I think we could try to improve readability here a bit. I think I’d like to try to rewrite it to some kind of result builder method at some point in the future when we have a good suite of integration and unit tests (I think I’ve mentioned it once during a meeting). I was thinking about something like this:
return lookupResult(identifier, at: lookupPosition, with: config)
.implicitSelf()
.lookInGenericParametersOfExtendedType()
.defaultLookup()
.lookInMembers()
.lookupInParent()
Each of the methods could also take an optional if: bool
parameter that would conditionally include that step. This way we could basically remove all those complicated if … else if … else
statements from lookup
methods. Additionally, we could try to enforce some pre/post conditions related to config
in those functions (like LookupConfig.finishInSequentialScope
being checked inside .lookupInParent()
call for all sequential scopes).
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.
That does look nice! I don't know whether it's "worth" the effort of doing (vs. other things we've talked about for this library), but the result would be cleaner code in this part of the library.
@swift-ci please test Windows |
@swift-ci Please test |
@swift-ci please test Windows |
@swift-ci please test Windows |
This PR brings more
ASTScope
related fixes toSwiftLexicalLookup
. Those include:LookupResult.lookInGenericParametersOfExtendedType
.LookupResult.mightIntroduceDollarIdentifiers
result kind when looking up foridentifier = nil
and more explicitLookupName.dollarIdentifier
when looking up for a particular dollar identifier.where
clauses.