Ver código fonte

[vscode] add JSON schemas for define.ml and meta.ml

In theory, the JSON files could even be validated against these on CI. For now, it just makes for a much nicer editing experience in VSCode.

Also found a typo and an unused property in the files this way.
Jens Fischer 6 anos atrás
pai
commit
e8bdb34300

+ 59 - 0
.vscode/schemas/define.schema.json

@@ -0,0 +1,59 @@
+{
+	"$schema": "http://json-schema.org/draft-07/schema#",
+	"type": "array",
+	"items": {
+		"type": "object",
+		"additionalProperties": false,
+		"properties": {
+			"name": {
+				"type": "string",
+				"markdownDescription": "OCaml name of the define."
+			},
+			"define": {
+				"type": "string",
+				"markdownDescription": "Actual name of the define as it's used in `-D` on the CLI and in Haxe code."
+			},
+			"doc": {
+				"type": "string",
+				"markdownDescription": "Documentation for the define that is shown in `--help-defines`."
+			},
+			"platforms": {
+				"type": "array",
+				"markdownDescription": "Platforms on which this define has an effect.",
+				"minItems": 1,
+				"items": {
+					"enum": [
+						"js",
+						"lua",
+						"neko",
+						"flash",
+						"php",
+						"cpp",
+						"cs",
+						"java",
+						"python",
+						"hl",
+						"eval"
+					]
+				}
+			},
+			"params": {
+				"type": "array",
+				"markdownDescription": "Parameters this define takes.",
+				"minItems": 1,
+				"items": {
+					"type": "string"
+				}
+			},
+			"devcomment": {
+				"type": "string",
+				"markdownDescription": "Internal comment that is not exposed."
+			}
+		},
+		"required": [
+			"name",
+			"define",
+			"doc"
+		]
+	}
+}

+ 81 - 0
.vscode/schemas/meta.schema.json

@@ -0,0 +1,81 @@
+{
+	"$schema": "http://json-schema.org/draft-07/schema#",
+	"type": "array",
+	"items": {
+		"type": "object",
+		"additionalProperties": false,
+		"properties": {
+			"name": {
+				"type": "string",
+				"markdownDescription": "OCaml name of the meta."
+			},
+			"metadata": {
+				"type": "string",
+				"markdownDescription": "Actual name of the meta as it's used in Haxe code."
+			},
+			"doc": {
+				"type": "string",
+				"markdownDescription": "Documentation for the meta that is shown in `--help-metas` and IDE hints."
+			},
+			"platforms": {
+				"type": "array",
+				"markdownDescription": "Platforms on which this meta has an effect.",
+				"minItems": 1,
+				"items": {
+					"enum": [
+						"js",
+						"lua",
+						"neko",
+						"flash",
+						"php",
+						"cpp",
+						"cs",
+						"java",
+						"python",
+						"hl",
+						"eval"
+					]
+				}
+			},
+			"params": {
+				"type": "array",
+				"markdownDescription": "Parameters this meta takes.",
+				"minItems": 1,
+				"items": {
+					"type": "string"
+				}
+			},
+			"devcomment": {
+				"type": "string",
+				"markdownDescription": "Internal comment that is not exposed."
+			},
+			"internal": {
+				"type": "boolean",
+				"markdownDescription": "Whether this define is for internal use only, in which case it is not exposed to the CLI and the `--display` protocol."
+			},
+			"targets": {
+				"type": "array",
+				"markdownDescription": "On what the meta can be used.",
+				"minItems": 1,
+				"items": {
+					"enum": [
+						"TClass",
+						"TClassField",
+						"TAbstract",
+						"TAbstractField",
+						"TEnum",
+						"TTypedef",
+						"TExpr",
+						"TTypeParameter",
+						"TAnyField"
+					]
+				}
+			}
+		},
+		"required": [
+			"name",
+			"metadata",
+			"doc"
+		]
+	}
+}

+ 18 - 2
.vscode/settings.json

@@ -10,7 +10,23 @@
 	"files.exclude": {
 		"**/_build": true
 	},
-	"reason.server.languages": ["ocaml"],
+	"reason.server.languages": [
+		"ocaml"
+	],
 	"haxe.diagnosticsPathFilter": "${workspaceRoot}/std",
-	"npm.autoDetect": "off"
+	"npm.autoDetect": "off",
+	"json.schemas": [
+		{
+			"fileMatch": [
+				"src-json/define.json"
+			],
+			"url": "./.vscode/schemas/define.schema.json"
+		},
+		{
+			"fileMatch": [
+				"src-json/meta.json"
+			],
+			"url": "./.vscode/schemas/meta.schema.json"
+		}
+	]
 }

+ 1 - 1
src-json/define.json

@@ -263,7 +263,7 @@
 		"define": "js_es",
 		"doc": "Generate JS compliant with given ES standard version (default 5)",
 		"platforms": ["js"],
-		"params:": ["version number"]
+		"params": ["version number"]
 	},
 	{
 		"name": "JsEnumsAsArrays",

+ 0 - 1
src-json/meta.json

@@ -508,7 +508,6 @@
 	},
 	{
 		"name": "InlineConstructorArgument",
-		"matchUnderscore": true,
 		"metadata": ":inlineConstructorArgument",
 		"doc": "Internally used to mark expressions that were passed as arguments of an inlined constructor",
 		"internal": true