HaxeFoundation / HaxeFoundation/haxe
Formalize/design/unit-test IDE-support API for macros.
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
At the moment nobody really understands how to add support for completion, go-to-definition and other IDE services in a macro. There are things like `EDisplay` and `Context.containsDisplayPosition`, but currently they more or less feel like just leaked internals without any documentation or reliably specified behaviour.
For example, I just [added some go-to-definition support to tink_hxx](https://github.com/haxetink/tink_hxx/pull/49), but I have no idea if this is really correct or whether it will break with one of the next haxe updates.
This makes creating and, more importantly, using macro-powered DSLs rather painful and I think we could improve the situation, so I'm creating this issue in hope to get some discussion going and gather ideas.
Some initial thoughts:
- `EDisplay` node generally makes sense to me, although I think it could contain exact cursor position. This seems useful in cases when we have `EDisplay(EString("some unknown DSL"))` and we want to know exactly where to insert a new `EDisplay` from a macro when generating expressions.
- Maybe we should have macro API to directly "raise" display results instead of adding `EDisplay` values to be processed by the typer.
- For DSLs we often want to generate custom syntax (e.g. `` in HXX), we need some way for a macro to return a list of those, but I'm not sure how structured should it be.
- ~What's `EDisplayNew`? Seems like a leftover that we should remove to avoid confusion.~
Contributor guide
Assessment
This issue has not been assessed yet.