-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
Migrate java scopes #2038
Migrate java scopes #2038
Conversation
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.
Looks good! Left a few minor comments
consequence: (block) @branch.end @condition.domain.end | ||
) @dummy | ||
(#not-parent-type? @dummy "if_statement") | ||
(#child-range! @condition 0 -1 true true) |
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.
This includes any whitespace surrounding the condition inside the parens. Probably fine. Def makes sense for removal range. Prob good enough for content range
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 think so. Otherwise I definitely think that we need a trim predicate here.
consequence: (_) @branch | ||
) @condition.domain | ||
(ternary_expression | ||
alternative: (_) @branch |
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.
Do we have a way to define a scope multiple places in the same pattern?
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.
unfortunately not. The problem is that then things like .leading
, .start
, etc become ambiguous. I guess we could allow it if we don't see any of those things in the pattern? 🤔 cc/ @josharian
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 have now forgotten all of the details but last time I tried playing games like that I ended up in a tangled mess of code. I will generally choose clear over clever/concise, personally.
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.
Couldn't we number the scopes?
(ternary_expression
consequence: (_) @branch1
alternative: (_) @branch2
)
If we can't use actual numbers we could use letters or roman numerals? :D
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 an interesting idea. Or @branch.1
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.
Yeah probably even better
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.
Ok I didn't look super closely, as it's been awhile since my java days, we have lots of tests, and you're using it day-to-day so will notice oddnesses. I left a few comments. In addition, the following looked weird to me for "value"
![image](https://private-user-images.githubusercontent.com/755842/284972692-b6325544-de34-479c-9ecd-2ed74f6e5ea1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyOTIwNDYsIm5iZiI6MTczOTI5MTc0NiwicGF0aCI6Ii83NTU4NDIvMjg0OTcyNjkyLWI2MzI1NTQ0LWRlMzQtNDc5Yy05ZWNkLTJlZDc0ZjZlNWVhMS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjExJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxMVQxNjM1NDZaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1lMmFkN2FjNGE0YmY4MDExN2U3ZDNmZjg4MDdhYTUwMmNjNDgwNjUxNTY0YThmYWUyYTNiMGFhNTkzMjQ5M2ExJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.jOpV6BA5paTrghUv7pMABc62h-2tHe5Ln-BXQ94nawQ)
domain should include ;
above; might be same issue I point out in inline comment
![image](https://private-user-images.githubusercontent.com/755842/284972771-d4cfcdc2-7fab-428f-8292-b4f62b9b7d07.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyOTIwNDYsIm5iZiI6MTczOTI5MTc0NiwicGF0aCI6Ii83NTU4NDIvMjg0OTcyNzcxLWQ0Y2ZjZGMyLTdmYWItNDI4Zi04MjkyLWI0ZjYyYjliN2QwNy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjExJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxMVQxNjM1NDZaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zN2Q2NjY3MzhmYWVlNTE1OWU3MzBjNDFlMGQwM2M0MTc2NjhiY2E3NmMyYzNkN2I0NDAyNGM0MjhkMDhmN2VlJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.wzyoLlLu9jXCjT18KoBVXanVr7P1dLYxQB-2N0MjI0M)
these should be values
consequence: (_) @branch | ||
) @condition.domain | ||
(ternary_expression | ||
alternative: (_) @branch |
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.
unfortunately not. The problem is that then things like .leading
, .start
, etc become ambiguous. I guess we could allow it if we don't see any of those things in the pattern? 🤔 cc/ @josharian
@pokey Updated. |
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.
Better; left one more minor comment and I think we're good to go
queries/java.scm
Outdated
(local_variable_declaration | ||
(variable_declarator | ||
name: (_) @name @value.removal.start.endOf | ||
value: (_)? @value @value.removal.end | ||
) | ||
) @_.domain | ||
(field_declaration | ||
(variable_declarator | ||
name: (_) @name @value.removal.start.endOf | ||
value: (_)? @value @value.removal.end | ||
) | ||
) @_.domain | ||
|
||
;;!! value = 1; | ||
;;! ^ | ||
;;! xxxx | ||
;;! ---------- | ||
(_ | ||
(assignment_expression | ||
left: (_) @value.removal.start.endOf | ||
right: (_) @value @value.removal.end | ||
) @_.domain.start | ||
";"? @_.domain.end | ||
) |
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'd argue for using leading / trailing instead of removal for all of these
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.
If you prefer I could do that. Personally I don't think I have every used leading and trailing for anything else than whitespaces, but I'm not against it.
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.
fixed
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.
Ha yeah was kind of thinking the same thing in the back of my mind 😅. Better to be consistent tho I guess 🤷♂️
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.
👍👍
#Fixes #1926
Checklist