Compare commits

..

7 Commits

Author SHA1 Message Date
Juraj Kirchheim
0680220a77 Release 0.21.1 2020-08-20 13:09:07 +02:00
Juraj Kirchheim
acaedc170a Fix issue with build field retrieval. 2020-08-20 13:08:28 +02:00
Juraj Kirchheim
8b9dbba624 Release 0.21.0 2020-08-20 12:47:53 +02:00
Juraj Kirchheim
f9348d4a46 Release 0.20.2 2020-08-20 12:46:40 +02:00
Juraj Kirchheim
6f4e6b9227 Workaround https://github.com/HaxeFoundation/haxe/issues/9853 2020-08-20 12:45:33 +02:00
Juraj Kirchheim
59135d5cea Release 0.20.1 2020-08-12 23:14:38 +02:00
Juraj Kirchheim
4accf55b41 Avoid messing with typing order. 2020-08-12 23:10:43 +02:00
4 changed files with 27 additions and 11 deletions

View File

@@ -9,8 +9,8 @@
"contributors": [
"back2dos"
],
"version": "0.20.0",
"releasenote": "Add TypedExpr helpers.",
"version": "0.21.1",
"releasenote": "Fix issue with build field retrieval.",
"tags": [
"tink",
"macro",

View File

@@ -54,9 +54,16 @@ class MacroApi {
static public var completionPoint(default, null):Option<{
var file(default, never):String;
var content(default, never):Null<String>;
var pos(default, never):Int;
}>;
static public function getBuildFields():Option<Array<haxe.macro.Expr.Field>>
return switch completionPoint {
case Some(v) if (v.content != null && (v.content.charAt(v.pos - 1) == '@' || (v.content.charAt(v.pos - 1) == ':' && v.content.charAt(v.pos - 2) == '@'))): None;
default: Some(haxe.macro.Context.getBuildFields());
}
static public var args(default, null):Iterable<String>;
static var initialized = initArgs();
@@ -73,12 +80,15 @@ class MacroApi {
params:{
file:String,
offset:Int,
contents:String,
}
} = haxe.Json.parse(arg);
switch payload {
case { jsonrpc: '2.0', method: 'display/completion' }:
Some({
file: payload.params.file,
content: payload.params.contents,
pos: payload.params.offset,
});
default: None;

View File

@@ -23,7 +23,10 @@ class ClassBuilder {
target = Context.getLocalClass().get();
if (fields == null)
fields = Context.getBuildFields();
fields = switch MacroApi.getBuildFields() {
case None: target.pos.error('Impossible to get builds fields now. Possible cause: https://github.com/HaxeFoundation/haxe/issues/9853');
case Some(v): v;
}
this.initializeFrom = fields;
this.target = target;
@@ -192,10 +195,14 @@ class ClassBuilder {
return m;
}
static public function run(plugins:Array<ClassBuilder->Void>, ?verbose) {
var builder = new ClassBuilder();
for (p in plugins)
p(builder);
return builder.export(verbose);
}
static public function run(plugins:Array<ClassBuilder->Void>, ?verbose)
return switch MacroApi.getBuildFields() {
case None: null;
case Some(fields):
var builder = new ClassBuilder(fields);
for (p in plugins)
p(builder);
return builder.export(verbose);
}
}

View File

@@ -258,8 +258,7 @@ class Types {
return if (once) t else reduce(t, false);
return switch type {
case TAbstract(_.get() => { name: 'Null', pack: [] }, [t]): rec(t);
case TLazy(f): rec(f());
case TType(_, _): rec(Context.follow(type, once));
case TLazy(_) | TType(_): rec(Context.follow(type, once));
default: type;
}
}