-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
Support destination pseudo-scopes #1631
Comments
update from meet-up, taking "type" as our running example:
|
Note that the interaction with #1015 is a bit nontrivial because for eg "pour soft type" or "bring air to soft type", we actually want "soft" to apply to the conversion to a destination rather than to the modifier after it. Not sure how to distinguish that from wanting it to apply to the modifier after it 🤔 |
There's also an interesting interaction with the pattern we're proposing in #1742. For the case of (aaa) @bbb @ccc In this case, if you say (aaa) @bbb @ccc
(ddd) @eee If you say (aaa) @eee @eee
(ddd) @eee Which is obviously not desirable. In this case, it seems like the destination Maybe the answer here is that for #1742 we should have them be one target that is the union of their ranges if they're adjacent? They can still use |
The problem
Consider the following code
In this case, there is no type. However, we want the following to work:
"change type"
from within the statement should insert a:
after theaaa
and leave your cursor after the:
"bring bat to type air"
should insert a:
after theaaa
, followed by "bat"The solution
Query language update
In our query language, support
@myScopeType.destination
Could be used as follows:
( (lexical_declaration (variable_declarator name: (_) @type.destination.endOf !type ) ) (#leading-insertion-delimiter! @type.destination ": ") )
How to handle these queries
The naive approach is to create a stub target that only has a
getDestination
method and throws on everything else. Unfortunately the problem is that this would break the following:If you say
"copy type bat"
, you'll get an error, because it will get trapped in the pseudo-scope. Maybe that's fine because it could be confusing to have"copy type bat"
and"change type bat"
refer to different scopes (the latter is legitimately a destination pseudo-scope that allows adding a type tobbb
)The text was updated successfully, but these errors were encountered: