-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please add access to Abstract Syntax Tree #1982
Comments
The AST can't be passed through the web worker as it can only send JSON |
It would be nice to add some API (like plugins or dynamic imports) to the workers, so we can expand the visitors and access their ASTs. I currently have to get the editor content and then parse the AST via JScodeshift (recast). |
@orta Can you expose a method to access AST within the worker context? as shown in updated description of this issue? |
A worker is async background code which you don't really have access to in a general sense from your user-land code. @luminaxster's idea of being able to add your own dynamic import is probably the best option here - perhaps a new function in here: https://github.com/microsoft/monaco-typescript/blob/master/src/tsWorker.ts#L235 which calls |
@orta Yes I know what is background worker, this is the reason the function is passed as a string, which is evaluated in worker and executed. Your recommendation is little longer way to do same thing, and there is no much documentation and sample on how to do it exactly, how to access AST and when and what to do? |
microsoft/monaco-typescript#65 would allow you to create your own webworker which can do AST stuff I the background |
Please expose Abstract Syntax Tree from Language service for TypeScript. It will be of great help to analyze code model rather then reparsing it again (as there is no way to access internal model), I want to access imported modules.
Update
Can you add a method that goes inside worker and can access the model and return the result?
The underlying code simply passed this function as source code, which is executed in worker's context and result is returned either as string or or some JSON.
The text was updated successfully, but these errors were encountered: