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
bugfix: Print local type aliases properly #4188
Conversation
// local type aliases | ||
case ValueSignature(tp: s.TypeRef) if tp.symbol.isLocal => | ||
textDocument.symbols.collectFirst { |
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.
what if type alias is defined in other file? It isn't local then.
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.
Then it should work normally, the problem is with printing local type aliases as far as I was able to check. Or do you have a counter example?
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 the test to include a nonlocal type.
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.
Right, non local type was working, my bad.
// local type aliases | ||
case ValueSignature(tp: s.TypeRef) if tp.symbol.isLocal => | ||
textDocument.symbols.collectFirst { |
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.
Right, non local type was working, my bad.
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.
@tgodzik Looks good but I'm wondering why we have this line in printer ?
metals/metals/src/main/scala/scala/meta/internal/decorations/SemanticdbTreePrinter.scala
Line 35 in 869e08a
else if (symbol.startsWith("local")) "_" |
I removed it locally and without it the new test works well without changes in SyntheticDecorationProvider
Previously, we would not print local type names properly and instead just print "_". Now we search for the display name of that local type alias and display it instead. Fixes scalameta#4186
Good catch! I changed that a bit to have |
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.
👍
Previously, we would not print local type names properly and instead just print "_". Now we search for the display name of that local type alias and display it instead.
Fixes #4186