Analyzer method analyze will potentially contain more functionality to support src/features/*, by storing relevant context in it's analyzedDocumenttype.
Analyzer definition should be able to accomplish the same functionality it currently supports, while becoming significantly smaller. Thanks to everyone who provided contributions to make this possible!
This PR's goal is to remove most, if not all, of the remaining currently defined fragile components in the lsp.
[!IMPORTANT]
Refactoring src/analyzer.ts will change various components within the project, and allow for more features to be supported by the server. Features like code-actions, quickfixes, and context specific diagnostics might be included in this PR.
This rewrite of the analyzer will include improvements for supporting edge cases specifically related to the various methods fish provides to define variables (with proper scope) including:
[x] clarifyanalyzer.ts scope, for easier maintaince. Prior to this PR, the analyzer's structure is difficult to extend (at best). Multiple methods on the Analyzer could be moved to a more appropriate location.
[x] create a file named symbols.ts to handle building symbol list, and converting DocumentSymbol[] to WorkspaceSymbol[]
[x] removegeneric-tree.ts. This file has become less useful, and overall adds clutter to places that need such an algorithm.
[x] add sourcing files (source ~/.config/fish/some_file.fish) support to our per-document analysis, provided during the analyzer.analyze stage of incremental document indexing
[x] add utilities with matching tests to new symbol.ts file.
[x] build composite nodes FishDocumentSymbol[] from LspDocument
[x] support flattening any symbol (FishDocumentSymbol[] or FishWorkspaceSymbol[]) efficiently
FishWorkspaceSymbol, WorkspaceSymbol, or SymbolInformation do not support nested children properties. In the current definition, these global types already expect a flat array.
[x] support translation operation between symbols.
[x] support finding FishWorkspaceSymbol[] from documents
FishDocumentSymbol[], symbols which are globally scoped (including, autoloading, explicit definitions, etc.)
[x] filtering a nested Symbol for connecting child nodes with parents, that could possibly not be directly related.
[x] proper test coverage, in symbol.test.ts to ensure future changes match
expected behavior
[x] remove local CompletionItem related files from src/utils/completions/. Local symbols will be resolved by the new syntax below:
Potentially needs to make use of utilities for Symbol[], like flattenSymbols()
const allSymbols: FishDocumentSymbol[] = [] // getAllSymbols()
/* const currentSymbol = getCurrentSymbol() */
const currentScope = currentSymbol.scope.parent;
/** lookup & store symbols that are closest to the current scope */
const result = allFilter.filter(symbol => symbol.range.isWithin(currentScope.range))
/* use `result` to build local Completions, Signatures, Hovers, etc... */
High-Level Summary
Analyzer
methodanalyze
will potentially contain more functionality to supportsrc/features/*
, by storing relevant context in it'sanalyzedDocument
type.Analyzer
definition should be able to accomplish the same functionality it currently supports, while becoming significantly smaller. Thanks to everyone who provided contributions to make this possible!This PR's goal is to remove most, if not all, of the remaining currently defined fragile components in the lsp.
Tasks
[ ] refactor analyzer.ts structure (replace with analyzer-future.ts once completed)
Analyzer
could be moved to a more appropriate location.Analyzer
to be defined in src/utils/tree-sitter.tsAnalyzer
class[x] provide a single data structure for
DocumentSymbol
&WorkspaceSymbol
DocumentSymbol[]
toWorkspaceSymbol[]
[x] remove generic-tree.ts. This file has become less useful, and overall adds clutter to places that need such an algorithm.
[x] add sourcing files (
source ~/.config/fish/some_file.fish
) support to our per-document analysis, provided during theanalyzer.analyze
stage of incremental document indexing[ ] rework workspace.ts to reflect changes towards analyzer structure
[x] add utilities with matching tests to new symbol.ts file.
FishDocumentSymbol[]
fromLspDocument
FishDocumentSymbol[]
orFishWorkspaceSymbol[]
) efficientlyFishWorkspaceSymbol[]
from documentsFishDocumentSymbol[]
, symbols which are globally scoped (including, autoloading, explicit definitions, etc.)Symbol
for connecting child nodes with parents, that could possibly not be directly related.WorkspaceSymbol
utilities like findDefinitionSymbol, getReferenceLocation, removeLocalSymbols & findGlobalLocationsthis.analyzer
insrc/server.ts
usagethis.analyzer
insrc/server.ts
usage[x] remove local
CompletionItem
related files from src/utils/completions/. Local symbols will be resolved by the new syntax below: