HaxeFoundation / HaxeFoundation/haxe

[ide] poor/no completion for expression macro arguments

Open
#9,421 3 comments 3 reactions 0 assignees View on GitHub
feature-ide haxe-foundation-partner platform-macro
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

> #7885 seems related, but i think we should do _something_ here for better IDE support of macro methods:

Consider this situation:
```haxe
class Main {
#if !macro
static function main() {
f(|
}
#end

static macro function f(a, b) {
trace("call", a, b);
return macro null;
}
}
```

Invoking toplevel completion will NOT call the macro, thus we can't wrap given `EDisplay` into some typecheck to trigger completion.

If we now type the first argument, e.g. `f(1,|` and invoke toplevel completion, the macro will be called and will receive `EConst(1), EDisplay(DKMarked)`.

So it is only possible to provide completion for the last argument, unless we use rest macro arguments (`Array`), in which case it will correctly pass all of the arguments (but that's extra work for the macro authors and it still shows ugly in signature help, so it's not really an option)

Maybe we could always call the macro but pass missing arguments as `EDisplay(DKMissing)` or something?

*PS It's not super high priority, but I'm still labeling it with hf-partner, because I want to have a simple macro method with 3 arguments and I want IDE features to work for it :)*

Contributor guide

Open the contributing guide

Research direction

Reproduce the example with a three-argument macro and compare toplevel completion before and after the first argument is entered. Trace how missing expression macro arguments are represented, then verify that completion works for each argument without requiring rest macro arguments and that signature help remains usable.

Written by the indexing model from the issue text.

Assessment

Domain
compilers, developer-experience
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.