Browse Source

[macro] deprecate some API and see if someone complains

Simon Krajewski 2 years ago
parent
commit
bafc459fba

+ 13 - 8
std/haxe/macro/Compiler.hx

@@ -87,6 +87,7 @@ class Compiler {
 		Removes a (static) field from a given class by name.
 		An error is thrown when `className` or `field` is invalid.
 	**/
+	@:deprecated
 	public static function removeField(className:String, field:String, ?isStatic:Bool) {
 		if (!path.match(className))
 			throw "Invalid " + className;
@@ -103,6 +104,7 @@ class Compiler {
 		Set the type of a (static) field at a given class by name.
 		An error is thrown when `className` or `field` is invalid.
 	**/
+	@:deprecated
 	public static function setFieldType(className:String, field:String, type:String, ?isStatic:Bool) {
 		if (!path.match(className))
 			throw "Invalid " + className;
@@ -119,6 +121,7 @@ class Compiler {
 		Add metadata to a (static) field or class by name.
 		An error is thrown when `className` or `field` is invalid.
 	**/
+	@:deprecated
 	public static function addMetadata(meta:String, className:String, ?field:String, ?isStatic:Bool) {
 		if (!path.match(className))
 			throw "Invalid " + className;
@@ -271,7 +274,8 @@ class Compiler {
 				found = true;
 				for (file in sys.FileSystem.readDirectory(path)) {
 					if (StringTools.endsWith(file, ".hx") && file.substr(0, file.length - 3).indexOf(".") < 0) {
-						if( file == "import.hx" ) continue;
+						if (file == "import.hx")
+							continue;
 						var cl = prefix + file.substr(0, file.length - 3);
 						if (skip(cl))
 							continue;
@@ -481,8 +485,9 @@ class Compiler {
 	**/
 	public static function registerMetadataDescriptionFile(path:String, ?source:String):Void {
 		var f = sys.io.File.getContent(path);
-		var content:Array<MetadataDescription> =  haxe.Json.parse(f);
-		for (m in content) registerCustomMetadata(m, source);
+		var content:Array<MetadataDescription> = haxe.Json.parse(f);
+		for (m in content)
+			registerCustomMetadata(m, source);
 	}
 
 	/**
@@ -491,8 +496,9 @@ class Compiler {
 	**/
 	public static function registerDefinesDescriptionFile(path:String, ?source:String):Void {
 		var f = sys.io.File.getContent(path);
-		var content:Array<DefineDescription> =  haxe.Json.parse(f);
-		for (d in content) registerCustomDefine(d, source);
+		var content:Array<DefineDescription> = haxe.Json.parse(f);
+		for (d in content)
+			registerCustomDefine(d, source);
 	}
 
 	/**
@@ -536,7 +542,6 @@ class Compiler {
 		load("flush_disk_cache", 0)();
 		#end
 	}
-
 	#end
 
 	#if (js || lua || macro)
@@ -551,7 +556,7 @@ class Compiler {
 
 				var f = try sys.io.File.getContent(Context.resolvePath(file)) catch (e:Dynamic) Context.error(Std.string(e), Context.currentPos());
 				var p = Context.currentPos();
-				if(Context.defined("js")) {
+				if (Context.defined("js")) {
 					macro @:pos(p) js.Syntax.plainCode($v{f});
 				} else {
 					macro @:pos(p) untyped __lua__($v{f});
@@ -737,7 +742,7 @@ typedef CompilerConfiguration = {
 
 		For example, the "java" package is "Forbidden" when the target platform is Python.
 	**/
-	final packageRules:Map<String,PackageRule>;
+	final packageRules:Map<String, PackageRule>;
 }
 
 enum PackageRule {

+ 1 - 1
tests/misc/projects/Issue10844/user-defined-define-json-fail.hxml.stderr

@@ -1,3 +1,3 @@
 (unknown) : Uncaught exception Could not read file define.jsno
-$$normPath(::std::)/haxe/macro/Compiler.hx:493: characters 11-39 : Called from here
+$$normPath(::std::)/haxe/macro/Compiler.hx:498: characters 11-39 : Called from here
 (unknown) : Called from here

+ 1 - 1
tests/misc/projects/Issue10844/user-defined-meta-json-fail.hxml.stderr

@@ -1,3 +1,3 @@
 (unknown) : Uncaught exception Could not read file meta.jsno
-$$normPath(::std::)/haxe/macro/Compiler.hx:483: characters 11-39 : Called from here
+$$normPath(::std::)/haxe/macro/Compiler.hx:487: characters 11-39 : Called from here
 (unknown) : Called from here

+ 1 - 1
tests/misc/projects/Issue10844/user-defined-meta-json-indent-fail.hxml.stderr

@@ -1,3 +1,3 @@
 (unknown) : Uncaught exception Could not read file meta.jsno
-  $$normPath(::std::)/haxe/macro/Compiler.hx:483: characters 11-39 : Called from here
+  $$normPath(::std::)/haxe/macro/Compiler.hx:487: characters 11-39 : Called from here
   (unknown) : Called from here

+ 2 - 2
tests/misc/projects/Issue10844/user-defined-meta-json-pretty-fail.hxml.stderr

@@ -2,9 +2,9 @@
 
    | Uncaught exception Could not read file meta.jsno
 
-    ->  $$normPath(::std::)/haxe/macro/Compiler.hx:483: characters 11-39
+    ->  $$normPath(::std::)/haxe/macro/Compiler.hx:487: characters 11-39
 
-    483 |   var f = sys.io.File.getContent(path);
+    487 |   var f = sys.io.File.getContent(path);
         |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         | Called from here