savoirfairelinux / vscode-bitbake

Bitbake language support for Visual Studio Code (Forked from EugenWiens)
https://marketplace.visualstudio.com/items?itemName=yocto-project.yocto-bitbake
Other
9 stars 0 forks source link

Implement and optimize symbol scanner in Analyzer #99

Closed WilsonZiweiWang closed 11 months ago

WilsonZiweiWang commented 11 months ago

What SymbolScanner was doing:

  1. Associate a new instance of it to the file when it is opened or has content changed.
  2. Scan for the file in directives (include, inherit and require) and get the file paths, then store the file paths and their content.
  3. Recursively repeat the step 2 for each file scanned.
  4. When the scan is complete, Loop the stored file paths and content in step 2 to get the symbols (Declared variables and exported variables. e.g. VAR = 'var' and export VAR = '123') using RegEx.

What I am trying to do here:

  1. Without changing the goal of the original SymbolScanner, use the tree-sitter instead of the RegEx.
  2. Move all implementations to the analyzer.
  3. Optimized the file reading since SymbolScanner was doing a lot of the reads while the file didn't change.
  4. Extract the symbols right after reading a file instead of getting all the files first and then looping each file to extract them.

How I do recursive reading on files: image

Note that the analyze action inside the sourceIncludeFiles() will invoke file read on disk.

This PR also includes using those symbols for the completion feature.

WilsonZiweiWang commented 11 months ago

Sample result without filtering: image

WilsonZiweiWang commented 11 months ago

Provide go to definition for variables if they also exist in the files in the directive statements (inherit, include and require) image