document-symbol: Initial implementation#474
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #474 +/- ##
==========================================
+ Coverage 66.67% 68.33% +1.66%
==========================================
Files 44 45 +1
Lines 5905 6411 +506
==========================================
+ Hits 3937 4381 +444
- Misses 1968 2030 +62
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This commit implements the `textDocument/documentSymbol` LSP feature, which provides structured outline information for Julia source files. The implementation uses a hybrid approach: 1. Surface AST (`st0`) analysis for top-level symbols 2. Scope analysis (`ctx3`) for local symbols within scoped constructs Top-level symbol extraction covers: - Modules (including baremodule) - Functions (both long-form and short-form definitions) - Macros - Structs (with fields and inner constructors) - Abstract and primitive types - Constants and global variables - Top-level assignments (including tuple destructuring) - Let/while/for blocks - Docstrings - Special handling for `@enum` macrocalls For scoped constructs (functions, let blocks, etc.), the implementation performs JuliaLowering's scope analysis to extract local bindings: - Function arguments with type annotations, default values, and varargs - Keyword arguments (including kwsorter scope merging) - Local variables with assignments and type annotations - For loop iterators - Nested functions (recursively extracted as children) - Static type parameters Symbol details provide rich context for editor display: - Short-form functions show `f(x) =` format - Long-form functions show `function f(x)` format - Arguments show their full declaration context - Local variables show their definition context The implementation includes caching with invalidation on document changes, and deduplication logic to handle cases where the same binding appears in multiple scopes.
8b47538 to
1b54251
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit implements the
textDocument/documentSymbolLSP feature, which provides structured outline information for Julia source files.The implementation uses a hybrid approach:
st0) analysis for top-level symbolsctx3) for local symbols within scoped constructsTop-level symbol extraction covers:
@enummacrocallsFor scoped constructs (functions, let blocks, etc.), the implementation performs JuliaLowering's scope analysis to extract local bindings:
Symbol details provide rich context for editor display:
f(x) =formatfunction f(x)formatThe implementation includes caching with invalidation on document changes, and deduplication logic to handle cases where the same binding appears in multiple scopes.