The problem of coming up with a high-quality, standard way for editor tools to query source code is tricky stuff that takes time to get right. This post is about just a piece of that puzzle.
One main piece of info that IDE tools need is a project-wide map of module info (exports, types, locations, etc.) I’m aware this is something that’s still being worked out.
But an area I don’t think anyone is working on, and that I think the community could greatly benefit from is a smaller, specialized parser for dealing with incomplete/invalid syntax as a user is typing. The idea being that unlike the compiler which bails on errors, you’d try to recover from errors and keep filling out as much of the AST as possible.
It would enable editor features like:
- completions, usages, and type info for locally scoped definitions
- “as you type” linting that can reason about incomplete code, making errors more relevant and less distracting
- allowing elm-format to still work in the presence of errors
- type-directed autocomplete
I imagine this tool operating in a fine-grained manner on single declarations as they change in an open file. It could work alongside other tools that produce more coarse structured output.
I’m interested in taking on a project like this. It would require me to learn more advanced parsing techniques, but I’m up for the challenge.
Before I go further I’d like hear what others think of this and how it fits in with the larger picture.