-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Search all source trees for a given span #14436
Conversation
34df1d2
to
1c0f0de
Compare
1c0f0de
to
63379fd
Compare
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.
Otherwise LGTM.
@@ -72,7 +72,7 @@ object NavigateAST { | |||
* end point are the same, so this is useful when trying to reconcile | |||
* nodes with source code. | |||
*/ | |||
def pathTo(span: Span, from: Positioned, skipZeroExtent: Boolean = false)(using Context): List[Positioned] = { |
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.
The documentation comment above needs to be slightly tweaked: it says "from node from
" but I guess now it would be "from any node in from
"
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.
Changed. Good catch!
When we create a synthetic companion object, for exmaple for enums, all the value definitions are put into it and the there are actually multiple trees that contain the position we are itnerested in. Now, NavigateAST.pathTo takes in multiple trees since the method is already able to find the best fit.
55ab0ac
to
f33fcb9
Compare
When we create a synthetic companion object, for exmaple for enums, all the value definitions are put into it and the there are actually multiple trees that contain the position we are itnerested in.
I decided to check which path is the longest, which most likely is the most exact. I am open to all ideas as I am not sure this is the best solution.Actually, it dawned on me in the morning that there is already a logic for choosing the best tree and it already works fine.Fixes #8738