Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

LSP: Handle textDocument/documentSymbol #548

Merged
merged 1 commit into from
Jan 30, 2025
Merged

LSP: Handle textDocument/documentSymbol #548

merged 1 commit into from
Jan 30, 2025

Conversation

kengorab
Copy link
Owner

This change allows the LSP to provide a list of symbols for the current document, which includes a nested hierarchical view of types and their fields, enums and their variants, instance and static methods for each, as well as top-level variables and functions.

Doing this caused a few bugs and gaps to surface, which are also fixed as part of this changeset. These include:

Lexer: Consider a \t as a whitespace character when previously it wasn't.

Typechecker: When adding a TypedModule to the Project, make sure to use the normalized path name, with /a/b/../c resolved to /a/c (previously this wasn't the case).

Language service: If the TypedModule isn't currently present in the project, pre-emptively typecheck the current module rather than waiting for a save. This is helpful because it allows for more seamless go-to-definition and hover commands, but also because I think if the symbols aren't resolved correctly when the file first opens, vscode will ignore subsequent symbols provided by textDocument/documentSymbol. I also cleaned up residual "virtual file system" changes which had been commented out but which can now be disregarded because I don't think I'm going to be doing that any time soon.

This change allows the LSP to provide a list of symbols for the current
document, which includes a nested hierarchical view of types and their
fields, enums and their variants, instance and static methods for each,
as well as top-level variables and functions.

Doing this caused a few bugs and gaps to surface, which are also fixed
as part of this changeset. These include:

Lexer: Consider a \t as a whitespace character when previously it
wasn't.

Typechecker: When adding a TypedModule to the Project, make sure to use
the normalized path name, with `/a/b/../c` resolved to `/a/c`
(previously this wasn't the case).

Language service: If the TypedModule isn't currently present in the
project, pre-emptively typecheck the current module rather than waiting
for a save. This is helpful because it allows for more seamless
go-to-definition and hover commands, but also because I think if the
symbols aren't resolved correctly when the file first opens, vscode will
ignore subsequent symbols provided by `textDocument/documentSymbol`. I
also cleaned up residual "virtual file system" changes which had been
commented out but which can now be disregarded because I don't think I'm
going to be doing that any time soon.
@kengorab kengorab added bug Something isn't working enhancement New feature lsp labels Jan 30, 2025
@kengorab kengorab merged commit c4fb57f into master Jan 30, 2025
1 check passed
@kengorab kengorab deleted the lsp-symbols branch January 30, 2025 01:41
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working enhancement New feature lsp
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant