Search code examples
visual-studio-codeabstract-syntax-treevscode-extensions

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.


Solution

  • 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.