-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fixes #7673: document symbol responses by language server #7674
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
Fixes #7673: document symbol responses by language server #7674
Conversation
- Fixed range of symbols (using symbol position and not symbol name position) - Removed top level container object - Improved symbol kinds (added enums, enum value/cases, traits as interfaces, and type params/fields) - Added local members - Fixed container names (stripping the module class suffix)
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.
Hello, and thank you for opening this PR! 🎉
All contributors have signed the CLA, thank you! ❤️
Commit Messages
We want to keep history, but for that to actually be useful we have
some rules on how to format our commit messages (relevant xkcd).
Please stick to these guidelines for commit messages:
- Separate subject from body with a blank line
- When fixing an issue, start your commit message with
Fix #<ISSUE-NBR>:
- Limit the subject line to 72 characters
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line ("Add" instead of "Added")
- Wrap the body at 80 characters
- Use the body to explain what and why vs. how
adapted from https://chris.beams.io/posts/git-commit
Have an awesome day! ☀️
There's a few test failures: [error] Failed tests:
[error] dotty.tools.languageserver.WorksheetTest
[error] dotty.tools.languageserver.DocumentSymbolTest You can run one of them from sbt like this: > dotty-language-server/testOnly *WorksheetTest Or to run a single test method: > dotty-language-server/testOnly *WorksheetTest -- *worksheetDocumentSymbol Let me know if you need help updating the tests. |
@smarter Thank you, and apologies for these failures. Indeed, these are expected failures since I didn't change any test (I've run just a plain |
- Fix failing tests in dotty.tools.languageserver.WorksheetTest - Fix failing tests in dotty.tools.languageserver.DocumentSymbolTest - Add tests for top-level decls, enums, type params in DocumentSymbolTest - Remove erroneous trees and empty owner from document symbols
// and erroroneous trees. | ||
val excludeLocalsFromSyntheticSymbols = (n: NameTree) => { | ||
val owner = n.symbol.owner | ||
n.symbol.is(Case) || { |
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 this makes too many assumptions about which trees to include or not, there might be non-synthetic definitions inside synthetic trees in other places than enums. It might not be enough but as a first step maybe we can just exclude type and term parameters of synthetic definitions:
n.symbol.is(Case) || { | |
!n.symbol.is(Param) || { |
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.
Makes sense. I'm going to commit this soon with the change below.
val excludeLocalsFromSyntheticSymbols = (n: NameTree) => { | ||
val owner = n.symbol.owner | ||
n.symbol.is(Case) || { | ||
n.name != StdNames.nme.ERROR && |
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 don't think we ever want to return these ERROR trees, so we could add this check to the ones we do by default in https://github.com/lampepfl/dotty/blob/3a7dfd2c14e1bc146f79faef8fcad42efadcdaeb/compiler/src/dotty/tools/dotc/interactive/Interactive.scala#L187
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'm going to move the condition. I wasn't sure this was the best way to check for an erroneous tree. Can you confirm this? Does this change impact tests other than the language server / worksheets?
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 wasn't sure this was the best way to check for an erroneous tree. Can you confirm this?
It's the best way to deal with the error trees produced by Parser currently, typed error trees should already be handled.
Does this change impact tests other than the language server / worksheets?
I guess we'll have to run the tests and see :).
- Exclude type and term parameters of synthetic definitions - Exclude erroneous trees from Interactive.namedTrees traverser
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.
LGTM, thanks!
As described in #7673, this PR fixes the document symbol responses in the language server.
Screenshot of breadcrumbs working:

As a side modification, we found that in Typer.scala there is a likely missing Synthetic flag for the anon class.