HaxeFoundation / HaxeFoundation/haxe

ClassType.constructor.expr() breaks completion

Open
#8,327 2 comments 0 reactions 0 assignees View on GitHub
bug feature-ide
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

For a long time I could not understand why my macro breaks the completion of code in the class. There were no errors and messages from the compiler. As a result, I learned that everything happens because of a single line. Here is a minimal example:

```haxe
package;

class Foo {
public function new(arg1:Int, arg2:Int) {}

public function field(arg1:Int, arg2:Int) {}
}
```

```haxe
package;

@:build(Macros.build())
class BuildMe {
public function new() {
//code completion does not work here
}
}
```

```haxe
package;

import haxe.macro.Expr.Field;
import haxe.macro.Context;

using haxe.macro.Tools;

class Macros {
public static macro function build():Array {
var cls = Context.getType('Foo').getClass();
var constr = cls.constructor.get();
var tExpr = constr.expr().expr; // this line breaks the completion server
// var tExpr = cls.fields.get()[0].expr().expr; //works fine
return Context.getBuildFields();
}
}
```

Haxe 4.0.0-rc.2+77068e10c
VS Code 1.34.0
vshaxe 2.11.0

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.