Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access AST of active file in VS Code extension?

From my extension, how can I access the abstract syntax tree that VS Code has for the active file? I have been looking through the API docs but haven't been able to find anything. I also came across this SO question but both the question and answer are pretty opaque to me.

like image 802
maxedison Avatar asked Jun 22 '18 19:06

maxedison


People also ask

How do I access VS Code extensions?

Where can I find extension settings?# In general, VS Code extensions store their settings in your user or workspaces settings files and they are available through the Settings editor UI (Preferences: Open Settings (UI)) or via IntelliSense in your settings.json file (Preferences: Open Settings (JSON)).

Where are VS Code plugins stored?

Extensions are installed in a per user extensions folder. Depending on your platform, the location is in the following folder: Windows %USERPROFILE%\.vscode\extensions. macOS ~/.vscode/extensions.


1 Answers

There's no thing like a common AST for files loaded into an editor. In fact, many file aren't even parsed at all, unless an extension is installed which does that.

The linked answer describes a way to implement language support (via a language server), which is not the same as getting a fictional AST from vscode.

like image 84
Mike Lischke Avatar answered Nov 15 '22 09:11

Mike Lischke