HaxeFoundation / HaxeFoundation/haxe

Formalize/design/unit-test IDE-support API for macros.

Open
#10,013 1 comment 6 reactions 0 assignees View on GitHub
discussion enhancement feature-ide
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.