tools icon indicating copy to clipboard operation
tools copied to clipboard

☂️ Symbol/Scope Resolution

Open xunilrj opened this issue 3 years ago • 2 comments

This issue is tracking all the implementation to achieve two tasks:

1 - Allow "go to definition" on the editor; 2 - Allow to warn against "unused Variables" when linting;

See this discussion about the semantic model architecture: https://github.com/rome/tools/discussions/2614 See this discussion about the architecture on how the semantic model is going to be used inside linters: https://github.com/rome/tools/discussions/2603

Steps

This is my suggestion for implementing the two tasks above. It is actually a progressive implementation:

1 - We do not offer a semantic façade at all. "unusedVariables" lint would just consume the parsing tree, and iterate it to find unused variables; 2 - We cache this iteration somehow to make the lint have a decent performance; 3 - We build the "service/context" architecture that will be passed into the lint; 4 - We store the "service/context" inside NodeData; 5 - We create the untyped Semantic Tree; 6 - We change the "unusedVariable" lint rule to use the semantic tree. 7 - We implement the typed Semantic Tree. Probably just the first SemanticJsVariableDeclaration. 8 - We change the "unusedVariable" lint rule to query for the type semantic tree.

Tasks

  • [ ] Parse Microsoft/ts .symbols file (see https://github.com/rome/tools/pull/2588)
    • [x] basic coverage test running
    • [ ] achieve +90% of passess
  • [ ] Generate Symbols Events
    • [ ] DeclarationFound
    • [ ] ReferenceFound
  • [ ] Implement simple Scope resolution
    • [ ] ScopeStarted
    • [ ] ScopeEnded
  • [ ] Support Hoisting
    • [ ] ReferenceSolved
  • [ ] LSP
    • [ ] F12 - go to definition
  • [ ] Lint
    • [ ] lint for "unused variable"

xunilrj avatar Apr 25 '22 08:04 xunilrj

Will this be part of the parsing phase or another another phase after the parsing phase?

ematipico avatar Apr 25 '22 09:04 ematipico

Another pass. The final architecture, we are still discussing (https://github.com/rome/tools/discussions/2603)

So for these tasks, it will actually be another function that will be called manually when testing.

xunilrj avatar Apr 25 '22 09:04 xunilrj

To reach 90% we need to deal with a lot of edge cases that are not relevant for the moment.

xunilrj avatar Oct 04 '22 11:10 xunilrj

"Goto definition" will only be relevant when we run and the only LSP (non vscode).

xunilrj avatar Oct 04 '22 11:10 xunilrj