Compare commits
8 Commits
0.20.0
...
isAbstract
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
59d7407d1b | ||
|
|
0680220a77 | ||
|
|
acaedc170a | ||
|
|
8b9dbba624 | ||
|
|
f9348d4a46 | ||
|
|
6f4e6b9227 | ||
|
|
59135d5cea | ||
|
|
4accf55b41 |
@@ -9,8 +9,8 @@
|
|||||||
"contributors": [
|
"contributors": [
|
||||||
"back2dos"
|
"back2dos"
|
||||||
],
|
],
|
||||||
"version": "0.20.0",
|
"version": "0.21.1",
|
||||||
"releasenote": "Add TypedExpr helpers.",
|
"releasenote": "Fix issue with build field retrieval.",
|
||||||
"tags": [
|
"tags": [
|
||||||
"tink",
|
"tink",
|
||||||
"macro",
|
"macro",
|
||||||
|
|||||||
@@ -54,9 +54,16 @@ class MacroApi {
|
|||||||
|
|
||||||
static public var completionPoint(default, null):Option<{
|
static public var completionPoint(default, null):Option<{
|
||||||
var file(default, never):String;
|
var file(default, never):String;
|
||||||
|
var content(default, never):Null<String>;
|
||||||
var pos(default, never):Int;
|
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 public var args(default, null):Iterable<String>;
|
||||||
static var initialized = initArgs();
|
static var initialized = initArgs();
|
||||||
|
|
||||||
@@ -73,12 +80,15 @@ class MacroApi {
|
|||||||
params:{
|
params:{
|
||||||
file:String,
|
file:String,
|
||||||
offset:Int,
|
offset:Int,
|
||||||
|
contents:String,
|
||||||
}
|
}
|
||||||
} = haxe.Json.parse(arg);
|
} = haxe.Json.parse(arg);
|
||||||
|
|
||||||
switch payload {
|
switch payload {
|
||||||
case { jsonrpc: '2.0', method: 'display/completion' }:
|
case { jsonrpc: '2.0', method: 'display/completion' }:
|
||||||
Some({
|
Some({
|
||||||
file: payload.params.file,
|
file: payload.params.file,
|
||||||
|
content: payload.params.contents,
|
||||||
pos: payload.params.offset,
|
pos: payload.params.offset,
|
||||||
});
|
});
|
||||||
default: None;
|
default: None;
|
||||||
|
|||||||
@@ -23,7 +23,10 @@ class ClassBuilder {
|
|||||||
target = Context.getLocalClass().get();
|
target = Context.getLocalClass().get();
|
||||||
|
|
||||||
if (fields == null)
|
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.initializeFrom = fields;
|
||||||
this.target = target;
|
this.target = target;
|
||||||
@@ -192,10 +195,14 @@ class ClassBuilder {
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function run(plugins:Array<ClassBuilder->Void>, ?verbose) {
|
static public function run(plugins:Array<ClassBuilder->Void>, ?verbose)
|
||||||
var builder = new ClassBuilder();
|
return switch MacroApi.getBuildFields() {
|
||||||
for (p in plugins)
|
case None: null;
|
||||||
p(builder);
|
case Some(fields):
|
||||||
return builder.export(verbose);
|
var builder = new ClassBuilder(fields);
|
||||||
}
|
for (p in plugins)
|
||||||
|
p(builder);
|
||||||
|
return builder.export(verbose);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,6 +172,9 @@ class Types {
|
|||||||
#if haxe4
|
#if haxe4
|
||||||
isExtern: field.isExtern,
|
isExtern: field.isExtern,
|
||||||
isFinal: field.isFinal,
|
isFinal: field.isFinal,
|
||||||
|
#if (haxe >= version("4.2.0-rc.1"))
|
||||||
|
isAbstract: field.isAbstract,
|
||||||
|
#end
|
||||||
#end
|
#end
|
||||||
}:ClassField)
|
}:ClassField)
|
||||||
]);
|
]);
|
||||||
@@ -258,8 +261,7 @@ class Types {
|
|||||||
return if (once) t else reduce(t, false);
|
return if (once) t else reduce(t, false);
|
||||||
return switch type {
|
return switch type {
|
||||||
case TAbstract(_.get() => { name: 'Null', pack: [] }, [t]): rec(t);
|
case TAbstract(_.get() => { name: 'Null', pack: [] }, [t]): rec(t);
|
||||||
case TLazy(f): rec(f());
|
case TLazy(_) | TType(_): rec(Context.follow(type, once));
|
||||||
case TType(_, _): rec(Context.follow(type, once));
|
|
||||||
default: type;
|
default: type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user