Skip to content
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

Use the compiler to drive as many language services as possible #11

Open
josephjclark opened this issue Jan 6, 2025 · 2 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@josephjclark
Copy link
Collaborator

josephjclark commented Jan 6, 2025

For example, can we use the compiler to detect State and lazy state references and top level operations

This requires a big compiler change

  • instead of detecting and transforming structures, we split the compiler into two phases
  • Phase 1 traverses the AST, detects key structures (operation, lazy state reference) and annotates the AST
  • Phase 2 finds the annotated nodes and transforms them, just as it does today.

If we have this compiler architecture, then VSC only needs to run phase 1, not phase 2, and we can re-use the logic.

Can we swap out VSC's in built compiler and use our own? Rather than parsing twice? The dream implementation is that we would control the first ast compilation that VSC does, annotate extra stuff, and then pass the esprima API syntax tree down to VSC.

Alternatively, we extract the esprima tree from VSC and pass that into the compiler (rather than compiling ourselves with acorn).

Either of these solutions prevents a duplication of work. But it's not essential!

@doc-han
Copy link
Collaborator

doc-han commented Feb 6, 2025

Other things the compiler needs to do

  1. Provide hover information for tokens that aren't adaptor functions
  2. Assist in function signature. That's knowing the nth argument of a function & erroring when a function is provided more than required arguments
  3. Warn users when they don't return state in a job.

@doc-han doc-han self-assigned this Feb 6, 2025
@doc-han doc-han added the enhancement New feature or request label Feb 6, 2025
@josephjclark
Copy link
Collaborator Author

Yeah I was thinking about this late at night: we have been thinking about logging warnings in the compiler for various things, but it feels like it's too late to do it at runtime.

But if we're using the compiler for static analysis, we can generate those warnings and report them back to the editor at build time. Should work great in VSC and Monaco!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants