From 40e38839fe4b3d5c601e019fff247f4efc89baf1 Mon Sep 17 00:00:00 2001 From: AlexHaxe Date: Tue, 5 Sep 2023 21:09:52 +0200 Subject: [PATCH] prepared for new release 1.15.0 --- .haxerc | 2 +- CHANGELOG.md | 2 + haxelib.json | 4 +- package-lock.json | 4 +- package.json | 2 +- resources/hxformat-schema.json | 1878 +++++++++++++------------- src/formatter/marker/MarkLineEnds.hx | 2 +- test/TestCaseMacro.hx | 17 + 8 files changed, 965 insertions(+), 946 deletions(-) diff --git a/.haxerc b/.haxerc index dc3cec2..7e4c52f 100644 --- a/.haxerc +++ b/.haxerc @@ -1,4 +1,4 @@ { - "version": "4.3.1", + "version": "4.3.2", "resolveLibs": "scoped" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index e88465a..ae1c8c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## dev branch / next version (1.x.x) +## version 1.15.0 (2023-09-05) + - Added `sameLine.ifElseSemicolonNextLine` to allow breaking `if (true) foo; else foo;`, fixes [#612](https://github.com/HaxeCheckstyle/haxe-formatter/issues/612) ([#668](https://github.com/HaxeCheckstyle/haxe-formatter/issues/668)) - Fixed whitespace before null safety operator - Fixed keeping same line for `macro if` expressions diff --git a/haxelib.json b/haxelib.json index 8e3a429..87ff4ff 100644 --- a/haxelib.json +++ b/haxelib.json @@ -8,8 +8,8 @@ "style" ], "description": "A code formatter for Haxe", - "version": "1.14.6", - "releasenote": "fixed inline call() and inline new issue - see CHANGELOG for details.", + "version": "1.15.0", + "releasenote": " Added sameLine.ifElseSemicolonNextLine - see CHANGELOG for details.", "contributors": [ "AlexHaxe", "Gama11" diff --git a/package-lock.json b/package-lock.json index 00f0106..ee520b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@haxecheckstyle/haxe-formatter", - "version": "1.14.6", + "version": "1.15.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@haxecheckstyle/haxe-formatter", - "version": "1.14.6", + "version": "1.15.0", "license": "MIT", "bin": { "haxe-formatter": "bin/formatter.js" diff --git a/package.json b/package.json index 26e6741..711ab2e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@haxecheckstyle/haxe-formatter", - "version": "1.14.6", + "version": "1.15.0", "description": "A code formatter for Haxe", "repository": { "type": "git", diff --git a/resources/hxformat-schema.json b/resources/hxformat-schema.json index 19389ec..e605673 100644 --- a/resources/hxformat-schema.json +++ b/resources/hxformat-schema.json @@ -1,248 +1,172 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", "definitions": { - "formatter.config.WhitespaceConfig": { - "additionalProperties": false, + "formatter.config.LineEndConfig": { "properties": { - "ternaryPolicy": { - "$ref": "#/definitions/formatter.config.WhitespacePolicy", - "default": "around" - }, - "typeParamClosePolicy": { - "description": "\">\"", - "$ref": "#/definitions/formatter.config.WhitespacePolicy", - "default": "none" - }, - "caseColonPolicy": { - "$ref": "#/definitions/formatter.config.WhitespacePolicy", - "default": "onlyAfter" - }, - "intervalPolicy": { - "$ref": "#/definitions/formatter.config.WhitespacePolicy", - "default": "none" - }, - "commaPolicy": { - "$ref": "#/definitions/formatter.config.WhitespacePolicy", - "default": "onlyAfter" - }, - "typeCheckColonPolicy": { - "$ref": "#/definitions/formatter.config.WhitespacePolicy", - "default": "around" - }, - "typeParamOpenPolicy": { - "description": "\"<\"", - "$ref": "#/definitions/formatter.config.WhitespacePolicy", - "default": "none" - }, - "openingBracketPolicy": { - "description": "\"[\"", - "$ref": "#/definitions/formatter.config.WhitespacePolicy", - "default": "noneAfter" - }, - "closingBracketPolicy": { - "description": "\"]\"", - "$ref": "#/definitions/formatter.config.WhitespacePolicy", - "default": "none" - }, - "bracesConfig": { - "description": "\"{\" + \"}\"", - "$ref": "#/definitions/formatter.config.BracesWhitespaceConfig" - }, - "compressSuccessiveParenthesis": { - "description": "should formatter compress spaces for successive parenthesis `( [ {` vs. `([{`", - "type": "boolean", - "default": true - }, - "functionTypeHaxe3Policy": { - "$ref": "#/definitions/formatter.config.WhitespacePolicy", - "default": "none" - }, - "arrowFunctionsPolicy": { - "$ref": "#/definitions/formatter.config.WhitespacePolicy", - "default": "around" - }, - "doPolicy": { - "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "leftCurly": { + "description": "global left curly line end setting", + "$ref": "#/definitions/formatter.config.LeftCurlyLineEndPolicy", "default": "after" }, - "semicolonPolicy": { - "$ref": "#/definitions/formatter.config.WhitespacePolicy", - "default": "onlyAfter" - }, - "forPolicy": { - "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "caseColon": { + "$ref": "#/definitions/formatter.config.CaseColonLineEndPolicy", "default": "after" }, - "parenConfig": { - "description": "\"(\" + \")\"", - "$ref": "#/definitions/formatter.config.ParenWhitespaceConfig" - }, - "objectFieldColonPolicy": { - "$ref": "#/definitions/formatter.config.WhitespacePolicy", - "default": "after" + "emptyCurly": { + "description": "global empty curlies line end setting", + "$ref": "#/definitions/formatter.config.EmptyCurlyPolicy", + "default": "noBreak" }, - "colonPolicy": { - "$ref": "#/definitions/formatter.config.WhitespacePolicy", - "default": "none" + "rightCurly": { + "description": "global right curly line end setting", + "$ref": "#/definitions/formatter.config.RightCurlyLineEndPolicy", + "default": "both" }, - "dotPolicy": { - "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "metadataVar": { + "$ref": "#/definitions/formatter.config.AtLineEndPolicy", "default": "none" }, - "switchPolicy": { - "$ref": "#/definitions/formatter.config.WhitespacePolicy", - "default": "after" - }, - "formatStringInterpolation": { - "description": "should formatter try to format string interpolation expressions (e.g. '${x+3}' -> '${x + 3}') only applies spaces, no newlines or wrapping", - "type": "boolean", - "default": true + "objectLiteralCurly": { + "description": "line end settings for object literal curlies", + "$ref": "#/definitions/formatter.config.CurlyLineEndPolicy" }, - "typeExtensionPolicy": { - "$ref": "#/definitions/formatter.config.WhitespacePolicy", - "default": "after" + "typedefCurly": { + "description": "line end settings for typedef curlies", + "$ref": "#/definitions/formatter.config.CurlyLineEndPolicy" }, - "whilePolicy": { - "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "sharp": { + "$ref": "#/definitions/formatter.config.SharpLineEndPolicy", "default": "after" }, - "typeHintColonPolicy": { - "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "metadataFunction": { + "$ref": "#/definitions/formatter.config.AtLineEndPolicy", "default": "none" }, - "addLineCommentSpace": { - "description": "ensure a space after '//'", - "type": "boolean", - "default": true + "metadataOther": { + "$ref": "#/definitions/formatter.config.AtLineEndPolicy", + "default": "none" }, - "catchPolicy": { - "$ref": "#/definitions/formatter.config.WhitespacePolicy", - "default": "after" + "metadataType": { + "$ref": "#/definitions/formatter.config.AtLineEndPolicy", + "default": "none" }, - "binopPolicy": { - "$ref": "#/definitions/formatter.config.WhitespacePolicy", - "default": "around" + "blockCurly": { + "description": "line end settings for block curlies", + "$ref": "#/definitions/formatter.config.CurlyLineEndPolicy" }, - "ifPolicy": { - "$ref": "#/definitions/formatter.config.WhitespacePolicy", - "default": "after" + "lineEndCharacter": { + "description": "line end character to use when outputting formatted code", + "$ref": "#/definitions/formatter.config.LineEndCharacter", + "default": "auto" }, - "functionTypeHaxe4Policy": { - "$ref": "#/definitions/formatter.config.WhitespacePolicy", - "default": "around" + "anonTypeCurly": { + "description": "line end settings for anon type curlies", + "$ref": "#/definitions/formatter.config.CurlyLineEndPolicy" }, - "tryPolicy": { - "$ref": "#/definitions/formatter.config.WhitespacePolicy", - "default": "after" + "anonFunctionCurly": { + "description": "line end settings for anon function body curlies", + "$ref": "#/definitions/formatter.config.CurlyLineEndPolicy" } }, + "additionalProperties": false, "type": "object" }, - "formatter.config.WrappingLocation": { - "anyOf": [ - { - "const": "beforeLast" - }, - { - "const": "afterLast" - } - ] - }, "formatter.config.InterfaceFieldsEmptyLinesConfig": { - "additionalProperties": false, "properties": { - "beginType": { - "description": "add empty lines after opening \"{\" of type", - "type": "integer", - "default": 0 - }, - "betweenVars": { - "type": "integer", - "default": 0 - }, "betweenFunctions": { - "type": "integer", - "default": 0 + "default": 0, + "type": "integer" + }, + "endType": { + "description": "add empty lines before closing \"}\" of type", + "default": 0, + "type": "integer" }, "afterVars": { - "type": "integer", - "default": 0 + "default": 0, + "type": "integer" }, "existingBetweenFields": { "$ref": "#/definitions/formatter.config.KeepEmptyLinesPolicy", "default": "keep" }, - "endType": { - "description": "add empty lines before closing \"}\" of type", - "type": "integer", - "default": 0 + "betweenVars": { + "default": 0, + "type": "integer" + }, + "beginType": { + "description": "add empty lines after opening \"{\" of type", + "default": 0, + "type": "integer" } }, + "additionalProperties": false, "type": "object" }, - "formatter.config.ConditionalEmptyLinesConfig": { - "additionalProperties": false, + "formatter.config.WrapRule": { "properties": { - "afterElse": { - "type": "integer", - "default": 0 - }, - "afterIf": { - "type": "integer", - "default": 0 - }, - "beforeElse": { - "type": "integer", - "default": 0 + "additionalIndent": { + "description": "adds indentation to all wrapped lines", + "default": 0, + "type": "integer" }, - "beforeEnd": { - "type": "integer", - "default": 0 + "location": { + "description": "default wrapping location before / after last token", + "$ref": "#/definitions/formatter.config.WrappingLocation", + "default": "afterLast" }, - "beforeError": { - "type": "integer", - "default": 0 + "conditions": { + "description": "list of conditions wrapping selects a rule if all of its conditions evaluate to true", + "items": { + "$ref": "#/definitions/formatter.config.WrapCondition" + }, + "type": "array" }, - "afterError": { - "type": "integer", - "default": 0 + "type": { + "description": "wrapping type", + "$ref": "#/definitions/formatter.config.WrappingType" } }, - "type": "object" - }, - "formatter.config.SharpLineEndPolicy": { - "anyOf": [ - { - "const": "none" - }, - { - "const": "after" - } - ] - }, - "formatter.config.WrapCondition": { + "additionalProperties": false, "required": [ - "cond" + "conditions", + "type" ], - "additionalProperties": false, + "type": "object" + }, + "formatter.config.TypedefFieldsEmptyLinesConfig": { "properties": { - "cond": { - "$ref": "#/definitions/formatter.config.WrapConditionType" + "endType": { + "description": "add empty lines before closing \"}\" of type", + "default": 0, + "type": "integer" }, - "value": { - "type": "integer", - "default": 1 + "betweenFields": { + "default": 0, + "type": "integer" + }, + "existingBetweenFields": { + "$ref": "#/definitions/formatter.config.KeepEmptyLinesPolicy", + "default": "keep" + }, + "beginType": { + "description": "add empty lines after opening \"{\" of type", + "default": 0, + "type": "integer" } }, + "additionalProperties": false, "type": "object" }, - "formatter.config.EmptyCurlyPolicy": { + "formatter.config.LineCommentEmptyLinePolicy": { "anyOf": [ { - "const": "noBreak" + "const": "keep" }, { - "const": "break" + "const": "one" + }, + { + "const": "none" } ] }, @@ -256,1064 +180,1140 @@ } ] }, - "formatter.config.CaseColonLineEndPolicy": { + "formatter.config.WrappingType": { "anyOf": [ { - "const": "none" + "description": "every item in a separate line, including first item", + "const": "onePerLine" }, { - "const": "after" - } - ] - }, - "formatter.config.WrapConfig": { - "additionalProperties": false, - "properties": { - "opBoolChain": { - "description": "OpBool chain wrapping rules", - "$ref": "#/definitions/formatter.config.WrapRules" - }, - "functionSignature": { - "description": "named function signature wrapping rules", - "$ref": "#/definitions/formatter.config.WrapRules" - }, - "anonType": { - "description": "anon types wrapping rules", - "$ref": "#/definitions/formatter.config.WrapRules" - }, - "methodChain": { - "description": "method chaining wrapping rules", - "$ref": "#/definitions/formatter.config.WrapRules" - }, - "arrayWrap": { - "description": "array wrapping rules does not affect array comprehension, use \"sameLine.comprehensionFor\"", - "$ref": "#/definitions/formatter.config.WrapRules" - }, - "maxLineLength": { - "description": "maximum characters per line, formatter will try to wrap code longer than `maxLineLength`", - "type": "integer", - "default": 160 - }, - "callParameter": { - "description": "call parameter wrapping rules", - "$ref": "#/definitions/formatter.config.WrapRules" - }, - "implementsExtends": { - "description": "implements / extends chain wrapping rules", - "$ref": "#/definitions/formatter.config.WrapRules" - }, - "multiVar": { - "description": "chain wrapping rules for OpAdd / OpSub", - "$ref": "#/definitions/formatter.config.WrapRules" - }, - "anonFunctionSignature": { - "description": "anon function signature wrapping rules", - "$ref": "#/definitions/formatter.config.WrapRules" - }, - "casePattern": { - "description": "chain wrapping rules for case patterns", - "$ref": "#/definitions/formatter.config.WrapRules" - }, - "typeParameter": { - "description": "type parameter wrapping rules", - "$ref": "#/definitions/formatter.config.WrapRules" - }, - "opAddSubChain": { - "description": "chain wrapping rules for OpAdd / OpSub", - "$ref": "#/definitions/formatter.config.WrapRules" - }, - "objectLiteral": { - "description": "object literal wrapping rules", - "$ref": "#/definitions/formatter.config.WrapRules" - }, - "metadataCallParameter": { - "description": "metadata call parameter wrapping rules", - "$ref": "#/definitions/formatter.config.WrapRules" - }, - "arrayMatrixWrap": { - "description": "detect arrays in matrix configuration from source noMatrixWrap = no detection matrixWrapNoAlign = detect and format as matrix without alignment matrixWrapWithAlign = detect and format as matrix and align columns", - "$ref": "#/definitions/formatter.config.ArrayMatrixWrap", - "default": "matrixWrapWithAlign" - } - }, - "type": "object" - }, - "formatter.config.ConditionalIndentationPolicy": { - "anyOf": [ - { - "const": "fixedZero" - }, - { - "const": "fixedZeroIncrease" + "description": "every item in a separate line, except first item", + "const": "onePerLineAfterFirst" }, { - "const": "fixedZeroIncreaseBlocks" + "description": "put an equal amount of items per line - not yet implemented", + "const": "equalNumber" }, { - "const": "aligned" + "description": "fill each line until maxLineLength - does not start with a newline", + "const": "fillLine" }, { - "const": "alignedNestedIncrease" + "description": "fill each line until maxLineLength, starts with a newline before first item", + "const": "fillLineWithLeadingBreak" }, { - "const": "alignedIncrease" + "description": "do not wrap items", + "const": "noWrap" }, { - "const": "alignedDecrease" + "description": "use wrapping information from source", + "const": "keep" } ] }, "formatter.config.ImportsEmptyLinesConfig": { - "additionalProperties": false, "properties": { "betweenImports": { "description": "empty lines between two consecutive import/using lines using betweenImportsLevel", - "type": "integer", - "default": 0 + "default": 0, + "type": "integer" + }, + "beforeType": { + "description": "empty lines after import and using section", + "default": 1, + "type": "integer" + }, + "beforeUsing": { + "description": "empty lines between import and using lines", + "default": 1, + "type": "integer" }, "betweenImportsLevel": { "description": "restrict betweenImports setting to a specific level \"all\" - apply betweenImports to all imports/using entries \"firstLevelPackage\" - group imports/using entries using toplevel package names; no empty lines for identical toplevel names \"secondLevelPackage\" - group imports/using entries using top- and secondlevel package names; no empty lines for identical toplevel and secondlevel names \"thirdLevelPackage\" - group imports/using entries using upto thirdlevel package names \"fourthLevelPackage\" - group imports/using entries using upto foruthlevel package names \"fifthLevelPackage\" - group imports/using entries using upto fifthlevel package names \"fullPackage\" - group imports/using entries using full packages; no empty lines for identical package names", "$ref": "#/definitions/formatter.config.BetweenImportsEmptyLinesLevel", "default": "all" + } + }, + "additionalProperties": false, + "type": "object" + }, + "formatter.config.FormatterConfig": { + "properties": { + "emptyLines": { + "$ref": "#/definitions/formatter.config.EmptyLinesConfig" }, - "beforeUsing": { - "description": "empty lines between import and using lines", - "type": "integer", - "default": 1 + "indentation": { + "$ref": "#/definitions/formatter.config.IndentationConfig" }, - "beforeType": { - "description": "empty lines after import and using section", - "type": "integer", - "default": 1 + "wrapping": { + "$ref": "#/definitions/formatter.config.WrapConfig" + }, + "excludes": { + "description": "regular expressions matching files to exclude from formatting default is to exclude any `.haxelib`, `.git` and `node_modules` folder", + "items": { + "type": "string" + }, + "type": "array" + }, + "sameLine": { + "$ref": "#/definitions/formatter.config.SameLineConfig" + }, + "whitespace": { + "$ref": "#/definitions/formatter.config.WhitespaceConfig" + }, + "lineEnds": { + "$ref": "#/definitions/formatter.config.LineEndConfig" + }, + "disableFormatting": { + "description": "turns off formatting for all files in current folder and subfolders unless subfolder contains a `hxformat.json`", + "default": false, + "type": "boolean" } }, + "additionalProperties": false, "type": "object" }, - "formatter.config.SameLinePolicy": { + "formatter.config.EmptyCurlyPolicy": { "anyOf": [ { - "const": "same" - }, - { - "const": "next" + "const": "noBreak" }, { - "const": "keep" + "const": "break" } ] }, - "formatter.config.LeftCurlyLineEndPolicy": { + "formatter.config.ArrayMatrixWrap": { "anyOf": [ { - "const": "none" - }, - { - "const": "after" + "const": "noMatrixWrap" }, { - "const": "before" + "const": "matrixWrapNoAlign" }, { - "const": "both" + "const": "matrixWrapWithAlign" } ] }, - "formatter.config.ClassFieldsEmptyLinesConfig": { - "additionalProperties": false, + "formatter.config.EmptyLinesConfig": { "properties": { - "beginType": { - "description": "add empty lines after opening \"{\" of type", - "type": "integer", - "default": 0 - }, - "afterStaticFunctions": { - "type": "integer", - "default": 1 + "beforePackage": { + "description": "empty lines before package declaration", + "default": 0, + "type": "integer" }, - "betweenStaticFunctions": { - "type": "integer", - "default": 1 + "beforeDocCommentEmptyLines": { + "description": "\"one\" adds one empty line above doc comments \"none\" removes all empty lines above doc comments \"ignore\" respects empty lines set via \"betweenVars\", \"betweenFunctions\", etc.", + "$ref": "#/definitions/formatter.config.CommentEmptyLinesPolicy", + "default": "one" }, - "betweenVars": { - "type": "integer", - "default": 0 + "maxAnywhereInFile": { + "description": "maximum consecutive empty lines anywhere in file - runs last, all empty lines policies are limited to \"maxAnywhereInFile\"", + "default": 1, + "type": "integer" }, - "afterStaticVars": { - "type": "integer", - "default": 1 + "afterBlocks": { + "$ref": "#/definitions/formatter.config.KeepEmptyLinesPolicy", + "default": "remove" }, - "betweenFunctions": { - "type": "integer", - "default": 1 + "classEmptyLines": { + "$ref": "#/definitions/formatter.config.ClassFieldsEmptyLinesConfig" }, - "afterVars": { - "type": "integer", - "default": 1 + "afterPackage": { + "description": "empty lines after package declaration", + "default": 1, + "type": "integer" }, - "afterPrivateFunctions": { - "type": "integer", - "default": 1 + "conditionalsEmptyLines": { + "$ref": "#/definitions/formatter.config.ConditionalEmptyLinesConfig" }, - "existingBetweenFields": { + "afterReturn": { + "description": "Remove or keep empty lines below \"return\"", "$ref": "#/definitions/formatter.config.KeepEmptyLinesPolicy", - "default": "keep" + "default": "remove" }, - "endType": { - "description": "add empty lines before closing \"}\" of type", - "type": "integer", - "default": 0 + "beforeRightCurly": { + "description": "Remove or keep empty lines above \"}\"", + "$ref": "#/definitions/formatter.config.KeepEmptyLinesPolicy", + "default": "remove" }, - "afterPrivateVars": { - "type": "integer", - "default": 1 + "beforeBlocks": { + "$ref": "#/definitions/formatter.config.KeepEmptyLinesPolicy", + "default": "remove" }, - "betweenStaticVars": { - "type": "integer", - "default": 0 - } - }, - "type": "object" - }, - "formatter.config.RightCurlyLineEndPolicy": { - "anyOf": [ - { - "const": "none" + "afterLeftCurly": { + "description": "Remove or keep empty lines below \"{\"", + "$ref": "#/definitions/formatter.config.KeepEmptyLinesPolicy", + "default": "remove" }, - { - "const": "before" + "finalNewline": { + "description": "adds a final newline", + "default": true, + "type": "boolean" }, - { - "const": "after" + "enumAbstractEmptyLines": { + "$ref": "#/definitions/formatter.config.EnumAbstractFieldsEmptyLinesConfig" }, - { - "const": "both" - } - ] - }, - "formatter.config.CommentEmptyLinesPolicy": { - "anyOf": [ - { - "const": "ignore" + "macroClassEmptyLines": { + "$ref": "#/definitions/formatter.config.ClassFieldsEmptyLinesConfig" }, - { - "const": "none" + "enumEmptyLines": { + "$ref": "#/definitions/formatter.config.TypedefFieldsEmptyLinesConfig" }, - { - "const": "one" - } - ] - }, - "formatter.config.LineCommentEmptyLinePolicy": { - "anyOf": [ - { - "const": "keep" + "betweenSingleLineTypes": { + "description": "empty lines between two single line types", + "default": 0, + "type": "integer" }, - { - "const": "one" + "interfaceEmptyLines": { + "$ref": "#/definitions/formatter.config.InterfaceFieldsEmptyLinesConfig" }, - { - "const": "none" - } - ] - }, - "formatter.config.FormatterConfig": { - "additionalProperties": false, - "properties": { - "disableFormatting": { - "description": "turns off formatting for all files in current folder and subfolders unless subfolder contains a `hxformat.json`", - "type": "boolean", - "default": false + "afterFileHeaderComment": { + "description": "Adds empty lines when file starts with a multiline comment", + "default": 1, + "type": "integer" }, - "excludes": { - "description": "regular expressions matching files to exclude from formatting default is to exclude any `.haxelib`, `.git` and `node_modules` folder", - "items": { - "type": "string" - }, - "type": "array" + "externClassEmptyLines": { + "$ref": "#/definitions/formatter.config.InterfaceFieldsEmptyLinesConfig" }, - "indentation": { - "$ref": "#/definitions/formatter.config.IndentationConfig" + "betweenTypes": { + "description": "empty lines between types", + "default": 1, + "type": "integer" }, - "emptyLines": { - "$ref": "#/definitions/formatter.config.EmptyLinesConfig" + "typedefEmptyLines": { + "$ref": "#/definitions/formatter.config.TypedefFieldsEmptyLinesConfig" }, - "lineEnds": { - "$ref": "#/definitions/formatter.config.LineEndConfig" + "lineCommentsBetweenFunctions": { + "description": "empty lines for line comments between functions", + "$ref": "#/definitions/formatter.config.LineCommentEmptyLinePolicy", + "default": "keep" }, - "sameLine": { - "$ref": "#/definitions/formatter.config.SameLineConfig" + "lineCommentsBetweenTypes": { + "description": "empty lines for line comments between types", + "$ref": "#/definitions/formatter.config.LineCommentEmptyLinePolicy", + "default": "keep" }, - "wrapping": { - "$ref": "#/definitions/formatter.config.WrapConfig" + "importAndUsing": { + "description": "empty lines for package, import and using section", + "$ref": "#/definitions/formatter.config.ImportsEmptyLinesConfig" }, - "whitespace": { - "$ref": "#/definitions/formatter.config.WhitespaceConfig" + "betweenMultilineComments": { + "description": "Adds empty lines between two consecutive multiline comments", + "default": 0, + "type": "integer" + }, + "abstractEmptyLines": { + "$ref": "#/definitions/formatter.config.ClassFieldsEmptyLinesConfig" + }, + "afterFieldsWithDocComments": { + "description": "\"one\" adds one empty line after fields with doc comments \"none\" removes all empty lines line fields with doc comments \"ignore\" respects empty lines set via \"betweenVars\", \"betweenFunctions\", etc.", + "$ref": "#/definitions/formatter.config.CommentEmptyLinesPolicy", + "default": "one" } }, + "additionalProperties": false, "type": "object" }, - "formatter.config.CurlyLineEndPolicy": { - "additionalProperties": false, + "formatter.config.IndentationConfig": { "properties": { - "rightCurly": { - "description": "line end options for right curly", - "$ref": "#/definitions/formatter.config.RightCurlyLineEndPolicy", - "default": "both" + "tabWidth": { + "description": "if `character` is set to \"tab\", formatter uses `tabWidth` to calculate absolute line length", + "default": 4, + "type": "integer" }, - "emptyCurly": { - "description": "line end options for empty curlies", - "$ref": "#/definitions/formatter.config.EmptyCurlyPolicy", - "default": "noBreak" + "character": { + "description": "use \"tab\", \" \", \" \", \" \", \" \", etc. to define which character to use", + "default": "tab", + "type": "string" }, - "leftCurly": { - "description": "line end options for left curly", - "$ref": "#/definitions/formatter.config.LeftCurlyLineEndPolicy", - "default": "after" + "indentObjectLiteral": { + "default": true, + "type": "boolean" + }, + "conditionalPolicy": { + "description": "only applies to non inlined conditionals \"fixedZero\" = all conditional statements should start in column 1 \"fixedZeroIncrease\" = indentation for conditionals starts at 0 and increases for every level \"fixedZeroIncreaseBlocks\" = same as \"fixedZeroIncrease\" but increases only inside blocks, outside it's \"fixedZero\" \"aligned\" = conditional statements share indentation of surrounding code \"alignedNestedIncrease\" = conditionals align with surrounding code, but will increase indent when nested \"alignedIncrease\" = same as \"aligned\" but will increase indent by +1 for enclosed code \"alignedDecrease\" = same as \"aligned\" but will decrease indent by -1 for enclosed code", + "$ref": "#/definitions/formatter.config.ConditionalIndentationPolicy", + "default": "aligned" + }, + "indentCaseLabels": { + "description": "indent case / default labels (true) or keep them on same level as switch (false)", + "default": true, + "type": "boolean" + }, + "indentComplexValueExpressions": { + "description": "indent complex value expressions: (true)\t\t\t\t\t\t(false) var a = if (true)\t\t\tvar a = if (true) 10;\t\t\t\t\t\t10; else\t\t\t\t\telse 20;\t\t\tvs.\t\t\t20; return if (true)\t\t\treturn if (true) 10;\t\t\t\t\t\t10; else\t\t\t\t\telse 20;\t\t\t\t\t\t20;", + "default": false, + "type": "boolean" + }, + "trailingWhitespace": { + "description": "adds trailing whitespace to empty lines by copying indentation from preceeding line", + "default": false, + "type": "boolean" } }, + "additionalProperties": false, "type": "object" }, - "formatter.config.WrapConditionType": { - "anyOf": [ - { - "description": "condition matches if item count is larger than or equal n items", - "const": "itemCount >= n" + "formatter.config.ConditionalEmptyLinesConfig": { + "properties": { + "afterError": { + "default": 0, + "type": "integer" }, - { - "description": "condition matches if item count is less than or equal n items", - "const": "itemCount <= n" + "beforeEnd": { + "default": 0, + "type": "integer" }, - { - "description": "condition matches if max item length is larger than or equal n characters", - "const": "anyItemLength >= n" + "beforeError": { + "default": 0, + "type": "integer" }, - { - "description": "condition matches if max item length is less than or equal n characters", - "const": "anyItemLength <= n" + "afterIf": { + "default": 0, + "type": "integer" }, - { - "description": "condition matches if total length of all wrapable items is larger than or equal n characters", - "const": "totalItemLength >= n" + "afterElse": { + "default": 0, + "type": "integer" }, + "beforeElse": { + "default": 0, + "type": "integer" + } + }, + "additionalProperties": false, + "type": "object" + }, + "formatter.config.LineEndCharacter": { + "anyOf": [ { - "description": "condition matches if total length of all wrapable items is less than or equal n characters", - "const": "totalItemLength <= n" + "description": "detect line end character from input (repeated for each input file)", + "const": "auto" }, { - "description": "condition matches lines larger than or equal n characters", - "const": "lineLength >= n" + "description": "output files with \\r line endings", + "const": "CR" }, { - "description": "condition matches lines less than or equal n characters", - "const": "lineLength <= n" + "description": "output files with \\n line endings", + "const": "LF" }, { - "description": "condition value = 1 matches if line contains a multiline token (string literal, block comment) value = 0 matches if no multiline token is present", - "const": "hasMultilineItems" + "description": "output files with \\r\\n line endings", + "const": "CRLF" + } + ] + }, + "formatter.config.SharpLineEndPolicy": { + "anyOf": [ + { + "const": "none" }, { - "description": "condition value = 1 matches if unwrapped line exceeds maxLineLength value = 0 matches unwrapped lines not exceeding maxLineLength", - "const": "exceedsMaxLineLength" + "const": "after" } ] }, - "formatter.config.LineEndConfig": { - "additionalProperties": false, + "formatter.config.WhitespaceConfig": { "properties": { - "typedefCurly": { - "description": "line end settings for typedef curlies", - "$ref": "#/definitions/formatter.config.CurlyLineEndPolicy" - }, - "metadataVar": { - "$ref": "#/definitions/formatter.config.AtLineEndPolicy", - "default": "none" + "caseColonPolicy": { + "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "default": "onlyAfter" }, - "metadataFunction": { - "$ref": "#/definitions/formatter.config.AtLineEndPolicy", - "default": "none" + "typeCheckColonPolicy": { + "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "default": "around" }, - "anonTypeCurly": { - "description": "line end settings for anon type curlies", - "$ref": "#/definitions/formatter.config.CurlyLineEndPolicy" + "parenConfig": { + "description": "\"(\" + \")\"", + "$ref": "#/definitions/formatter.config.ParenWhitespaceConfig" }, - "rightCurly": { - "description": "global right curly line end setting", - "$ref": "#/definitions/formatter.config.RightCurlyLineEndPolicy", - "default": "both" + "dotPolicy": { + "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "default": "none" }, - "caseColon": { - "$ref": "#/definitions/formatter.config.CaseColonLineEndPolicy", + "switchPolicy": { + "$ref": "#/definitions/formatter.config.WhitespacePolicy", "default": "after" }, - "lineEndCharacter": { - "description": "line end character to use when outputting formatted code", - "$ref": "#/definitions/formatter.config.LineEndCharacter", - "default": "auto" + "commaPolicy": { + "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "default": "onlyAfter" }, - "objectLiteralCurly": { - "description": "line end settings for object literal curlies", - "$ref": "#/definitions/formatter.config.CurlyLineEndPolicy" + "whilePolicy": { + "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "default": "after" }, - "anonFunctionCurly": { - "description": "line end settings for anon function body curlies", - "$ref": "#/definitions/formatter.config.CurlyLineEndPolicy" + "formatStringInterpolation": { + "description": "should formatter try to format string interpolation expressions (e.g. '${x+3}' -> '${x + 3}') only applies spaces, no newlines or wrapping", + "default": true, + "type": "boolean" }, - "metadataType": { - "$ref": "#/definitions/formatter.config.AtLineEndPolicy", + "intervalPolicy": { + "$ref": "#/definitions/formatter.config.WhitespacePolicy", "default": "none" }, - "sharp": { - "$ref": "#/definitions/formatter.config.SharpLineEndPolicy", - "default": "after" - }, - "emptyCurly": { - "description": "global empty curlies line end setting", - "$ref": "#/definitions/formatter.config.EmptyCurlyPolicy", - "default": "noBreak" + "binopPolicy": { + "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "default": "around" }, - "leftCurly": { - "description": "global left curly line end setting", - "$ref": "#/definitions/formatter.config.LeftCurlyLineEndPolicy", + "catchPolicy": { + "$ref": "#/definitions/formatter.config.WhitespacePolicy", "default": "after" }, - "blockCurly": { - "description": "line end settings for block curlies", - "$ref": "#/definitions/formatter.config.CurlyLineEndPolicy" + "compressSuccessiveParenthesis": { + "description": "should formatter compress spaces for successive parenthesis `( [ {` vs. `([{`", + "default": true, + "type": "boolean" }, - "metadataOther": { - "$ref": "#/definitions/formatter.config.AtLineEndPolicy", + "functionTypeHaxe3Policy": { + "$ref": "#/definitions/formatter.config.WhitespacePolicy", "default": "none" - } - }, - "type": "object" - }, - "formatter.config.SameLineConfig": { - "additionalProperties": false, - "properties": { - "ifElseSemicolonNextLine": { - "description": "Add new line after `if body` to `if (...) body; else ...` Don't touch `if (...) body else ...` or `if (...) {body} else ...`", - "type": "boolean", - "default": true }, - "tryBody": { - "description": "same line policy for non block body of \"try\" * same = place try and body on same line * next = place body on next line * keep = keep same / next line from source", - "$ref": "#/definitions/formatter.config.SameLinePolicy", - "default": "next" + "functionTypeHaxe4Policy": { + "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "default": "around" }, - "comprehensionFor": { - "$ref": "#/definitions/formatter.config.SameLinePolicy", - "default": "same" + "tryPolicy": { + "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "default": "after" }, - "returnBodySingleLine": { - "description": "same line policy for single line expression return values * same = place return and body on same line * next = place body on next line * keep = keep same / next line from source", - "$ref": "#/definitions/formatter.config.SameLinePolicy", - "default": "same" + "objectFieldColonPolicy": { + "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "default": "after" }, - "ifElse": { - "description": "same line policy for \"else\" part of \"if…else\" * same = place else and body on same line * next = place body on next line * keep = keep same / next line from source", - "$ref": "#/definitions/formatter.config.SameLinePolicy", - "default": "same" + "openingBracketPolicy": { + "description": "\"[\"", + "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "default": "noneAfter" }, - "expressionCase": { - "$ref": "#/definitions/formatter.config.SameLinePolicy", - "default": "keep" + "typeParamOpenPolicy": { + "description": "\"<\"", + "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "default": "none" }, - "expressionTry": { - "$ref": "#/definitions/formatter.config.SameLinePolicy", - "default": "same" + "ifPolicy": { + "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "default": "after" }, - "doWhile": { - "description": "same line policy for \"while\" part in \"do…while\" * same = place while and body on same line * next = place body on next line * keep = keep same / next line from source", - "$ref": "#/definitions/formatter.config.SameLinePolicy", - "default": "same" + "arrowFunctionsPolicy": { + "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "default": "around" }, - "expressionIfWithBlocks": { - "description": "will place if with one expression in a block in one line (requires \"expressionIf\" = \"same\") var foo = if (bar) { \"\"; } else { \"\"; };", - "type": "boolean", - "default": false + "forPolicy": { + "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "default": "after" }, - "catchBody": { - "description": "same line policy for non block body of \"catch\" * same = place catch and body on same line * next = place body on next line * keep = keep same / next line from source", - "$ref": "#/definitions/formatter.config.SameLinePolicy", - "default": "next" + "ternaryPolicy": { + "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "default": "around" }, - "elseIf": { - "description": "same line policy for \"if\" part of \"else if\" * same = place if and body on same line * next = place body on next line * keep = keep same / next line from source", - "$ref": "#/definitions/formatter.config.SameLinePolicy", - "default": "same" + "colonPolicy": { + "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "default": "none" }, - "functionBody": { - "description": "same line policy for non block body of \"function\" * same = place function and body on same line * next = place body on next line * keep = keep same / next line from source", - "$ref": "#/definitions/formatter.config.SameLinePolicy", - "default": "next" + "closingBracketPolicy": { + "description": "\"]\"", + "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "default": "none" }, - "expressionIf": { - "description": "same line policy for non block body of \"if\" in a value place / as expression * same = place if and body on same line * next = place body on next line * keep = keep same / next line from source", - "$ref": "#/definitions/formatter.config.SameLinePolicy", - "default": "same" + "bracesConfig": { + "description": "\"{\" + \"}\"", + "$ref": "#/definitions/formatter.config.BracesWhitespaceConfig" }, - "ifBody": { - "description": "same line policy for non block body of \"if\" * same = place if and body on same line * next = place body on next line * keep = keep same / next line from source", - "$ref": "#/definitions/formatter.config.SameLinePolicy", - "default": "next" + "addLineCommentSpace": { + "description": "ensure a space after '//'", + "default": true, + "type": "boolean" }, - "caseBody": { - "$ref": "#/definitions/formatter.config.SameLinePolicy", - "default": "next" + "semicolonPolicy": { + "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "default": "onlyAfter" }, - "elseBody": { - "description": "same line policy for non block body of \"else\" * same = place else and body on same line * next = place body on next line * keep = keep same / next line from source", - "$ref": "#/definitions/formatter.config.SameLinePolicy", - "default": "next" + "typeExtensionPolicy": { + "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "default": "after" }, - "tryCatch": { - "description": "same line policy for \"catch\" part of \"try…catch\" * same = place function and body on same line * next = place body on next line * keep = keep same / next line from source", - "$ref": "#/definitions/formatter.config.SameLinePolicy", - "default": "same" + "typeParamClosePolicy": { + "description": "\">\"", + "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "default": "none" }, - "doWhileBody": { - "description": "same line policy for non block body of \"do…while\" * same = place function and body on same line * next = place body on next line * keep = keep same / next line from source", - "$ref": "#/definitions/formatter.config.SameLinePolicy", - "default": "next" + "typeHintColonPolicy": { + "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "default": "none" }, - "returnBody": { - "description": "same line policy for multiline expression return values * same = place return and body on same line * next = place body on next line * keep = keep same / next line from source", - "$ref": "#/definitions/formatter.config.SameLinePolicy", - "default": "same" + "doPolicy": { + "$ref": "#/definitions/formatter.config.WhitespacePolicy", + "default": "after" + } + }, + "additionalProperties": false, + "type": "object" + }, + "formatter.config.ParenWhitespaceConfig": { + "properties": { + "whileConditionParens": { + "description": "parens used for while conditions", + "$ref": "#/definitions/formatter.config.OpenClosePolicy" }, - "untypedBody": { - "description": "same line policy for untyped {…} as a body * same = place return and body on same line * next = place body on next line * keep = keep same / next line from source", - "$ref": "#/definitions/formatter.config.SameLinePolicy", - "default": "same" + "anonFuncParamParens": { + "description": "parens used for anon function parameters", + "$ref": "#/definitions/formatter.config.OpenClosePolicy" }, - "anonFunctionBody": { - "description": "same line policy for non block body of anon \"function\" * same = place function and body on same line * next = place body on next line * keep = keep same / next line from source", - "$ref": "#/definitions/formatter.config.SameLinePolicy", - "default": "same" + "funcParamParens": { + "description": "parens used for function parameters", + "$ref": "#/definitions/formatter.config.OpenClosePolicy" }, - "forBody": { - "description": "same line policy for non block body of \"for\" * same = place function and body on same line * next = place body on next line * keep = keep same / next line from source", - "$ref": "#/definitions/formatter.config.SameLinePolicy", - "default": "next" + "ifConditionParens": { + "description": "parens used for if conditions", + "$ref": "#/definitions/formatter.config.OpenClosePolicy" }, - "whileBody": { - "description": "same line policy for non block body of \"while\" (not \"do…while\") * same = place while and body on same line * next = place body on next line * keep = keep same / next line from source", - "$ref": "#/definitions/formatter.config.SameLinePolicy", - "default": "next" + "catchParens": { + "description": "parens used for catch", + "$ref": "#/definitions/formatter.config.OpenClosePolicy" + }, + "sharpConditionParens": { + "description": "parens used for sharp conditions", + "$ref": "#/definitions/formatter.config.OpenClosePolicy" + }, + "callParens": { + "description": "parens used for calls", + "$ref": "#/definitions/formatter.config.OpenClosePolicy" + }, + "conditionParens": { + "description": "parens used for conditions", + "$ref": "#/definitions/formatter.config.OpenClosePolicy" + }, + "expressionParens": { + "description": "parens used for expressions", + "$ref": "#/definitions/formatter.config.OpenClosePolicy" + }, + "metadataParens": { + "description": "parens used for metadata", + "$ref": "#/definitions/formatter.config.OpenClosePolicy" + }, + "forLoopParens": { + "description": "parens used for for loops", + "$ref": "#/definitions/formatter.config.OpenClosePolicy" + }, + "switchConditionParens": { + "description": "parens used for switch conditions", + "$ref": "#/definitions/formatter.config.OpenClosePolicy" } }, + "additionalProperties": false, "type": "object" }, - "formatter.config.EmptyLinesConfig": { - "additionalProperties": false, - "properties": { - "beforeRightCurly": { - "description": "Remove or keep empty lines above \"}\"", - "$ref": "#/definitions/formatter.config.KeepEmptyLinesPolicy", - "default": "remove" - }, - "afterLeftCurly": { - "description": "Remove or keep empty lines below \"{\"", - "$ref": "#/definitions/formatter.config.KeepEmptyLinesPolicy", - "default": "remove" + "formatter.config.ConditionalIndentationPolicy": { + "anyOf": [ + { + "const": "fixedZero" }, - "afterReturn": { - "description": "Remove or keep empty lines below \"return\"", - "$ref": "#/definitions/formatter.config.KeepEmptyLinesPolicy", - "default": "remove" + { + "const": "fixedZeroIncrease" }, - "afterPackage": { - "description": "empty lines after package declaration", - "type": "integer", - "default": 1 + { + "const": "fixedZeroIncreaseBlocks" }, - "macroClassEmptyLines": { - "$ref": "#/definitions/formatter.config.ClassFieldsEmptyLinesConfig" + { + "const": "aligned" }, - "betweenMultilineComments": { - "description": "Adds empty lines between two consecutive multiline comments", - "type": "integer", - "default": 0 + { + "const": "alignedNestedIncrease" }, - "afterFieldsWithDocComments": { - "description": "\"one\" adds one empty line after fields with doc comments \"none\" removes all empty lines line fields with doc comments \"ignore\" respects empty lines set via \"betweenVars\", \"betweenFunctions\", etc.", - "$ref": "#/definitions/formatter.config.CommentEmptyLinesPolicy", - "default": "one" + { + "const": "alignedIncrease" }, - "finalNewline": { - "description": "adds a final newline", - "type": "boolean", - "default": true + { + "const": "alignedDecrease" + } + ] + }, + "formatter.config.WhitespacePolicy": { + "anyOf": [ + { + "const": "none" }, - "importAndUsing": { - "description": "empty lines for package, import and using section", - "$ref": "#/definitions/formatter.config.ImportsEmptyLinesConfig" + { + "const": "before" }, - "beforeBlocks": { - "$ref": "#/definitions/formatter.config.KeepEmptyLinesPolicy", - "default": "remove" + { + "const": "noneBefore" }, - "betweenSingleLineTypes": { - "description": "empty lines between two single line types", - "type": "integer", - "default": 0 + { + "const": "onlyBefore" }, - "conditionalsEmptyLines": { - "$ref": "#/definitions/formatter.config.ConditionalEmptyLinesConfig" + { + "const": "after" }, - "afterBlocks": { - "$ref": "#/definitions/formatter.config.KeepEmptyLinesPolicy", - "default": "remove" + { + "const": "onlyAfter" }, - "enumEmptyLines": { - "$ref": "#/definitions/formatter.config.TypedefFieldsEmptyLinesConfig" + { + "const": "noneAfter" }, - "externClassEmptyLines": { - "$ref": "#/definitions/formatter.config.InterfaceFieldsEmptyLinesConfig" + { + "const": "around" + } + ] + }, + "formatter.config.RightCurlyLineEndPolicy": { + "anyOf": [ + { + "const": "none" }, - "betweenTypes": { - "description": "empty lines between types", - "type": "integer", - "default": 1 + { + "const": "before" }, - "maxAnywhereInFile": { - "description": "maximum consecutive empty lines anywhere in file - runs last, all empty lines policies are limited to \"maxAnywhereInFile\"", - "type": "integer", - "default": 1 + { + "const": "after" }, - "typedefEmptyLines": { - "$ref": "#/definitions/formatter.config.TypedefFieldsEmptyLinesConfig" + { + "const": "both" + } + ] + }, + "formatter.config.WrappingLocation": { + "anyOf": [ + { + "const": "beforeLast" }, - "enumAbstractEmptyLines": { - "$ref": "#/definitions/formatter.config.EnumAbstractFieldsEmptyLinesConfig" + { + "const": "afterLast" + } + ] + }, + "formatter.config.CurlyLineEndPolicy": { + "properties": { + "leftCurly": { + "description": "line end options for left curly", + "$ref": "#/definitions/formatter.config.LeftCurlyLineEndPolicy", + "default": "after" }, - "lineCommentsBetweenTypes": { - "description": "empty lines for line comments between types", - "$ref": "#/definitions/formatter.config.LineCommentEmptyLinePolicy", - "default": "keep" + "emptyCurly": { + "description": "line end options for empty curlies", + "$ref": "#/definitions/formatter.config.EmptyCurlyPolicy", + "default": "noBreak" }, - "abstractEmptyLines": { - "$ref": "#/definitions/formatter.config.ClassFieldsEmptyLinesConfig" + "rightCurly": { + "description": "line end options for right curly", + "$ref": "#/definitions/formatter.config.RightCurlyLineEndPolicy", + "default": "both" + } + }, + "additionalProperties": false, + "type": "object" + }, + "formatter.config.SameLinePolicy": { + "anyOf": [ + { + "const": "same" }, - "beforePackage": { - "description": "empty lines before package declaration", - "type": "integer", - "default": 0 + { + "const": "next" }, - "classEmptyLines": { - "$ref": "#/definitions/formatter.config.ClassFieldsEmptyLinesConfig" + { + "const": "keep" + } + ] + }, + "formatter.config.BracesWhitespaceConfig": { + "properties": { + "anonTypeBraces": { + "description": "braces for anon types", + "$ref": "#/definitions/formatter.config.OpenClosePolicy" }, - "beforeDocCommentEmptyLines": { - "description": "\"one\" adds one empty line above doc comments \"none\" removes all empty lines above doc comments \"ignore\" respects empty lines set via \"betweenVars\", \"betweenFunctions\", etc.", - "$ref": "#/definitions/formatter.config.CommentEmptyLinesPolicy", - "default": "one" + "unknownBraces": { + "description": "unknown braces", + "$ref": "#/definitions/formatter.config.OpenClosePolicy" }, - "interfaceEmptyLines": { - "$ref": "#/definitions/formatter.config.InterfaceFieldsEmptyLinesConfig" + "objectLiteralBraces": { + "description": "braces for object literals", + "$ref": "#/definitions/formatter.config.OpenClosePolicy" }, - "afterFileHeaderComment": { - "description": "Adds empty lines when file starts with a multiline comment", - "type": "integer", - "default": 1 + "blockBraces": { + "description": "braces for blocks", + "$ref": "#/definitions/formatter.config.OpenClosePolicy" }, - "lineCommentsBetweenFunctions": { - "description": "empty lines for line comments between functions", - "$ref": "#/definitions/formatter.config.LineCommentEmptyLinePolicy", - "default": "keep" + "typedefBraces": { + "description": "braces for typdefs", + "$ref": "#/definitions/formatter.config.OpenClosePolicy" } }, + "additionalProperties": false, "type": "object" }, - "formatter.config.BetweenImportsEmptyLinesLevel": { + "formatter.config.LeftCurlyLineEndPolicy": { "anyOf": [ { - "const": "all" + "const": "none" }, { - "const": "firstLevelPackage" + "const": "after" }, { - "const": "secondLevelPackage" + "const": "before" }, { - "const": "thirdLevelPackage" + "const": "both" + } + ] + }, + "formatter.config.AtLineEndPolicy": { + "anyOf": [ + { + "const": "none" }, { - "const": "fourthLevelPackage" + "const": "after" }, { - "const": "fifthLevelPackage" + "const": "afterLast" }, { - "const": "fullPackage" + "const": "forceAfterLast" } ] }, - "formatter.config.EnumAbstractFieldsEmptyLinesConfig": { - "additionalProperties": false, + "formatter.config.WrapRules": { "properties": { - "beginType": { - "description": "add empty lines after opening \"{\" of type", - "type": "integer", - "default": 0 - }, - "betweenVars": { - "type": "integer", - "default": 0 + "defaultLocation": { + "description": "default wrapping location before / after last token", + "$ref": "#/definitions/formatter.config.WrappingLocation", + "default": "afterLast" }, - "betweenFunctions": { - "type": "integer", - "default": 1 + "defaultAdditionalIndent": { + "description": "adds indentation to all wrapped lines when applying defaultWrap", + "default": 0, + "type": "integer" }, - "afterVars": { - "type": "integer", - "default": 1 + "rules": { + "description": "list of wrapping rules wrapping uses only the first rule whose conditions evaluates to true", + "items": { + "$ref": "#/definitions/formatter.config.WrapRule" + }, + "type": "array" }, - "existingBetweenFields": { - "$ref": "#/definitions/formatter.config.KeepEmptyLinesPolicy", - "default": "keep" + "defaultWrap": { + "description": "default wrapping type when no rule applies", + "$ref": "#/definitions/formatter.config.WrappingType", + "default": "noWrap" + } + }, + "additionalProperties": false, + "type": "object" + }, + "formatter.config.WrapCondition": { + "properties": { + "cond": { + "$ref": "#/definitions/formatter.config.WrapConditionType" }, - "endType": { - "description": "add empty lines before closing \"}\" of type", - "type": "integer", - "default": 0 + "value": { + "default": 1, + "type": "integer" } }, + "additionalProperties": false, + "required": [ + "cond" + ], "type": "object" }, - "formatter.config.WrappingType": { + "formatter.config.WrapConditionType": { "anyOf": [ { - "description": "every item in a separate line, including first item", - "const": "onePerLine" + "description": "condition matches if item count is larger than or equal n items", + "const": "itemCount >= n" }, { - "description": "every item in a separate line, except first item", - "const": "onePerLineAfterFirst" + "description": "condition matches if item count is less than or equal n items", + "const": "itemCount <= n" }, { - "description": "put an equal amount of items per line - not yet implemented", - "const": "equalNumber" + "description": "condition matches if max item length is larger than or equal n characters", + "const": "anyItemLength >= n" }, { - "description": "fill each line until maxLineLength - does not start with a newline", - "const": "fillLine" + "description": "condition matches if max item length is less than or equal n characters", + "const": "anyItemLength <= n" }, { - "description": "fill each line until maxLineLength, starts with a newline before first item", - "const": "fillLineWithLeadingBreak" + "description": "condition matches if total length of all wrapable items is larger than or equal n characters", + "const": "totalItemLength >= n" }, { - "description": "do not wrap items", - "const": "noWrap" + "description": "condition matches if total length of all wrapable items is less than or equal n characters", + "const": "totalItemLength <= n" }, { - "description": "use wrapping information from source", - "const": "keep" - } - ] - }, - "formatter.config.ParenWhitespaceConfig": { - "additionalProperties": false, - "properties": { - "sharpConditionParens": { - "description": "parens used for sharp conditions", - "$ref": "#/definitions/formatter.config.OpenClosePolicy" - }, - "metadataParens": { - "description": "parens used for metadata", - "$ref": "#/definitions/formatter.config.OpenClosePolicy" + "description": "condition matches lines larger than or equal n characters", + "const": "lineLength >= n" }, - "whileConditionParens": { - "description": "parens used for while conditions", - "$ref": "#/definitions/formatter.config.OpenClosePolicy" + { + "description": "condition matches lines less than or equal n characters", + "const": "lineLength <= n" }, - "catchParens": { - "description": "parens used for catch", - "$ref": "#/definitions/formatter.config.OpenClosePolicy" + { + "description": "condition value = 1 matches if line contains a multiline token (string literal, block comment) value = 0 matches if no multiline token is present", + "const": "hasMultilineItems" }, - "switchConditionParens": { - "description": "parens used for switch conditions", - "$ref": "#/definitions/formatter.config.OpenClosePolicy" + { + "description": "condition value = 1 matches if unwrapped line exceeds maxLineLength value = 0 matches unwrapped lines not exceeding maxLineLength", + "const": "exceedsMaxLineLength" + } + ] + }, + "formatter.config.CommentEmptyLinesPolicy": { + "anyOf": [ + { + "const": "ignore" }, - "callParens": { - "description": "parens used for calls", - "$ref": "#/definitions/formatter.config.OpenClosePolicy" + { + "const": "none" }, - "ifConditionParens": { - "description": "parens used for if conditions", - "$ref": "#/definitions/formatter.config.OpenClosePolicy" + { + "const": "one" + } + ] + }, + "formatter.config.EnumAbstractFieldsEmptyLinesConfig": { + "properties": { + "betweenFunctions": { + "default": 1, + "type": "integer" }, - "forLoopParens": { - "description": "parens used for for loops", - "$ref": "#/definitions/formatter.config.OpenClosePolicy" + "endType": { + "description": "add empty lines before closing \"}\" of type", + "default": 0, + "type": "integer" }, - "anonFuncParamParens": { - "description": "parens used for anon function parameters", - "$ref": "#/definitions/formatter.config.OpenClosePolicy" + "afterVars": { + "default": 1, + "type": "integer" }, - "conditionParens": { - "description": "parens used for conditions", - "$ref": "#/definitions/formatter.config.OpenClosePolicy" + "existingBetweenFields": { + "$ref": "#/definitions/formatter.config.KeepEmptyLinesPolicy", + "default": "keep" }, - "expressionParens": { - "description": "parens used for expressions", - "$ref": "#/definitions/formatter.config.OpenClosePolicy" + "betweenVars": { + "default": 0, + "type": "integer" }, - "funcParamParens": { - "description": "parens used for function parameters", - "$ref": "#/definitions/formatter.config.OpenClosePolicy" + "beginType": { + "description": "add empty lines after opening \"{\" of type", + "default": 0, + "type": "integer" } }, + "additionalProperties": false, "type": "object" }, - "formatter.config.IndentationConfig": { - "additionalProperties": false, + "formatter.config.SameLineConfig": { "properties": { - "indentObjectLiteral": { - "type": "boolean", - "default": true + "tryBody": { + "description": "same line policy for non block body of \"try\" * same = place try and body on same line * next = place body on next line * keep = keep same / next line from source", + "$ref": "#/definitions/formatter.config.SameLinePolicy", + "default": "next" }, - "indentCaseLabels": { - "description": "indent case / default labels (true) or keep them on same level as switch (false)", - "type": "boolean", - "default": true + "returnBodySingleLine": { + "description": "same line policy for single line expression return values * same = place return and body on same line * next = place body on next line * keep = keep same / next line from source", + "$ref": "#/definitions/formatter.config.SameLinePolicy", + "default": "same" }, - "character": { - "description": "use \"tab\", \" \", \" \", \" \", \" \", etc. to define which character to use", - "type": "string", - "default": "tab" + "expressionCase": { + "$ref": "#/definitions/formatter.config.SameLinePolicy", + "default": "keep" }, - "conditionalPolicy": { - "description": "only applies to non inlined conditionals \"fixedZero\" = all conditional statements should start in column 1 \"fixedZeroIncrease\" = indentation for conditionals starts at 0 and increases for every level \"fixedZeroIncreaseBlocks\" = same as \"fixedZeroIncrease\" but increases only inside blocks, outside it's \"fixedZero\" \"aligned\" = conditional statements share indentation of surrounding code \"alignedNestedIncrease\" = conditionals align with surrounding code, but will increase indent when nested \"alignedIncrease\" = same as \"aligned\" but will increase indent by +1 for enclosed code \"alignedDecrease\" = same as \"aligned\" but will decrease indent by -1 for enclosed code", - "$ref": "#/definitions/formatter.config.ConditionalIndentationPolicy", - "default": "aligned" + "elseBody": { + "description": "same line policy for non block body of \"else\" * same = place else and body on same line * next = place body on next line * keep = keep same / next line from source", + "$ref": "#/definitions/formatter.config.SameLinePolicy", + "default": "next" }, - "tabWidth": { - "description": "if `character` is set to \"tab\", formatter uses `tabWidth` to calculate absolute line length", - "type": "integer", - "default": 4 + "untypedBody": { + "description": "same line policy for untyped {…} as a body * same = place return and body on same line * next = place body on next line * keep = keep same / next line from source", + "$ref": "#/definitions/formatter.config.SameLinePolicy", + "default": "same" }, - "trailingWhitespace": { - "description": "adds trailing whitespace to empty lines by copying indentation from preceeding line", - "type": "boolean", - "default": false + "comprehensionFor": { + "$ref": "#/definitions/formatter.config.SameLinePolicy", + "default": "same" }, - "indentComplexValueExpressions": { - "description": "indent complex value expressions: (true)\t\t\t\t\t\t(false) var a = if (true)\t\t\tvar a = if (true) 10;\t\t\t\t\t\t10; else\t\t\t\t\telse 20;\t\t\tvs.\t\t\t20; return if (true)\t\t\treturn if (true) 10;\t\t\t\t\t\t10; else\t\t\t\t\telse 20;\t\t\t\t\t\t20;", - "type": "boolean", - "default": false - } - }, - "type": "object" - }, - "formatter.config.LineEndCharacter": { - "anyOf": [ - { - "description": "detect line end character from input (repeated for each input file)", - "const": "auto" + "catchBody": { + "description": "same line policy for non block body of \"catch\" * same = place catch and body on same line * next = place body on next line * keep = keep same / next line from source", + "$ref": "#/definitions/formatter.config.SameLinePolicy", + "default": "next" + }, + "expressionIfWithBlocks": { + "description": "will place if with one expression in a block in one line (requires \"expressionIf\" = \"same\") var foo = if (bar) { \"\"; } else { \"\"; };", + "default": false, + "type": "boolean" + }, + "expressionTry": { + "$ref": "#/definitions/formatter.config.SameLinePolicy", + "default": "same" + }, + "anonFunctionBody": { + "description": "same line policy for non block body of anon \"function\" * same = place function and body on same line * next = place body on next line * keep = keep same / next line from source", + "$ref": "#/definitions/formatter.config.SameLinePolicy", + "default": "same" + }, + "ifBody": { + "description": "same line policy for non block body of \"if\" * same = place if and body on same line * next = place body on next line * keep = keep same / next line from source", + "$ref": "#/definitions/formatter.config.SameLinePolicy", + "default": "next" + }, + "tryCatch": { + "description": "same line policy for \"catch\" part of \"try…catch\" * same = place function and body on same line * next = place body on next line * keep = keep same / next line from source", + "$ref": "#/definitions/formatter.config.SameLinePolicy", + "default": "same" + }, + "doWhile": { + "description": "same line policy for \"while\" part in \"do…while\" * same = place while and body on same line * next = place body on next line * keep = keep same / next line from source", + "$ref": "#/definitions/formatter.config.SameLinePolicy", + "default": "same" }, - { - "description": "output files with \\r line endings", - "const": "CR" + "expressionIf": { + "description": "same line policy for non block body of \"if\" in a value place / as expression * same = place if and body on same line * next = place body on next line * keep = keep same / next line from source", + "$ref": "#/definitions/formatter.config.SameLinePolicy", + "default": "same" }, - { - "description": "output files with \\n line endings", - "const": "LF" + "elseIf": { + "description": "same line policy for \"if\" part of \"else if\" * same = place if and body on same line * next = place body on next line * keep = keep same / next line from source", + "$ref": "#/definitions/formatter.config.SameLinePolicy", + "default": "same" }, - { - "description": "output files with \\r\\n line endings", - "const": "CRLF" - } - ] - }, - "formatter.config.BracesWhitespaceConfig": { - "additionalProperties": false, - "properties": { - "objectLiteralBraces": { - "description": "braces for object literals", - "$ref": "#/definitions/formatter.config.OpenClosePolicy" + "doWhileBody": { + "description": "same line policy for non block body of \"do…while\" * same = place function and body on same line * next = place body on next line * keep = keep same / next line from source", + "$ref": "#/definitions/formatter.config.SameLinePolicy", + "default": "next" }, - "unknownBraces": { - "description": "unknown braces", - "$ref": "#/definitions/formatter.config.OpenClosePolicy" + "ifElse": { + "description": "same line policy for \"else\" part of \"if…else\" * same = place else and body on same line * next = place body on next line * keep = keep same / next line from source", + "$ref": "#/definitions/formatter.config.SameLinePolicy", + "default": "same" }, - "blockBraces": { - "description": "braces for blocks", - "$ref": "#/definitions/formatter.config.OpenClosePolicy" + "returnBody": { + "description": "same line policy for multiline expression return values * same = place return and body on same line * next = place body on next line * keep = keep same / next line from source", + "$ref": "#/definitions/formatter.config.SameLinePolicy", + "default": "same" }, - "typedefBraces": { - "description": "braces for typdefs", - "$ref": "#/definitions/formatter.config.OpenClosePolicy" + "caseBody": { + "$ref": "#/definitions/formatter.config.SameLinePolicy", + "default": "next" }, - "anonTypeBraces": { - "description": "braces for anon types", - "$ref": "#/definitions/formatter.config.OpenClosePolicy" - } - }, - "type": "object" - }, - "formatter.config.WrapRule": { - "required": [ - "conditions", - "type" - ], - "additionalProperties": false, - "properties": { - "conditions": { - "description": "list of conditions wrapping selects a rule if all of its conditions evaluate to true", - "items": { - "$ref": "#/definitions/formatter.config.WrapCondition" - }, - "type": "array" + "whileBody": { + "description": "same line policy for non block body of \"while\" (not \"do…while\") * same = place while and body on same line * next = place body on next line * keep = keep same / next line from source", + "$ref": "#/definitions/formatter.config.SameLinePolicy", + "default": "next" }, - "additionalIndent": { - "description": "adds indentation to all wrapped lines", - "type": "integer", - "default": 0 + "forBody": { + "description": "same line policy for non block body of \"for\" * same = place function and body on same line * next = place body on next line * keep = keep same / next line from source", + "$ref": "#/definitions/formatter.config.SameLinePolicy", + "default": "next" }, - "location": { - "description": "default wrapping location before / after last token", - "$ref": "#/definitions/formatter.config.WrappingLocation", - "default": "afterLast" + "functionBody": { + "description": "same line policy for non block body of \"function\" * same = place function and body on same line * next = place body on next line * keep = keep same / next line from source", + "$ref": "#/definitions/formatter.config.SameLinePolicy", + "default": "next" }, - "type": { - "description": "wrapping type", - "$ref": "#/definitions/formatter.config.WrappingType" + "ifElseSemicolonNextLine": { + "description": "Add new line after `if body` to `if (...) body; else ...` Don't touch `if (...) body else ...` or `if (...) {body} else ...`", + "default": true, + "type": "boolean" } }, + "additionalProperties": false, "type": "object" }, "formatter.config.OpenClosePolicy": { - "additionalProperties": false, "properties": { "closingPolicy": { "description": "\")\"", "$ref": "#/definitions/formatter.config.WhitespacePolicy", "default": "onlyAfter" }, - "removeInnerWhenEmpty": { - "description": "\"()\" or \"( )\" - if `openingPolicy` contains `After` or `closingPolicy` contains `Before`", - "type": "boolean", - "default": true - }, "openingPolicy": { "description": "\"(\"", "$ref": "#/definitions/formatter.config.WhitespacePolicy", "default": "none" + }, + "removeInnerWhenEmpty": { + "description": "\"()\" or \"( )\" - if `openingPolicy` contains `After` or `closingPolicy` contains `Before`", + "default": true, + "type": "boolean" } }, + "additionalProperties": false, "type": "object" }, - "formatter.config.WrapRules": { - "additionalProperties": false, + "formatter.config.ClassFieldsEmptyLinesConfig": { "properties": { - "defaultWrap": { - "description": "default wrapping type when no rule applies", - "$ref": "#/definitions/formatter.config.WrappingType", - "default": "noWrap" + "afterPrivateFunctions": { + "default": 1, + "type": "integer" }, - "defaultLocation": { - "description": "default wrapping location before / after last token", - "$ref": "#/definitions/formatter.config.WrappingLocation", - "default": "afterLast" + "afterPrivateVars": { + "default": 1, + "type": "integer" }, - "defaultAdditionalIndent": { - "description": "adds indentation to all wrapped lines when applying defaultWrap", - "type": "integer", - "default": 0 + "betweenStaticFunctions": { + "default": 1, + "type": "integer" }, - "rules": { - "description": "list of wrapping rules wrapping uses only the first rule whose conditions evaluates to true", - "items": { - "$ref": "#/definitions/formatter.config.WrapRule" - }, - "type": "array" - } - }, - "type": "object" - }, - "formatter.config.TypedefFieldsEmptyLinesConfig": { - "additionalProperties": false, - "properties": { - "beginType": { - "description": "add empty lines after opening \"{\" of type", - "type": "integer", - "default": 0 + "betweenFunctions": { + "default": 1, + "type": "integer" }, - "betweenFields": { - "type": "integer", - "default": 0 + "endType": { + "description": "add empty lines before closing \"}\" of type", + "default": 0, + "type": "integer" + }, + "afterStaticVars": { + "default": 1, + "type": "integer" + }, + "afterVars": { + "default": 1, + "type": "integer" }, "existingBetweenFields": { "$ref": "#/definitions/formatter.config.KeepEmptyLinesPolicy", "default": "keep" }, - "endType": { - "description": "add empty lines before closing \"}\" of type", - "type": "integer", - "default": 0 + "afterStaticFunctions": { + "default": 1, + "type": "integer" + }, + "betweenVars": { + "default": 0, + "type": "integer" + }, + "betweenStaticVars": { + "default": 0, + "type": "integer" + }, + "beginType": { + "description": "add empty lines after opening \"{\" of type", + "default": 0, + "type": "integer" } }, + "additionalProperties": false, "type": "object" }, - "formatter.config.AtLineEndPolicy": { + "formatter.config.BetweenImportsEmptyLinesLevel": { "anyOf": [ { - "const": "none" + "const": "all" }, { - "const": "after" + "const": "firstLevelPackage" }, { - "const": "afterLast" + "const": "secondLevelPackage" }, { - "const": "forceAfterLast" - } - ] - }, - "formatter.config.ArrayMatrixWrap": { - "anyOf": [ + "const": "thirdLevelPackage" + }, { - "const": "noMatrixWrap" + "const": "fourthLevelPackage" }, { - "const": "matrixWrapNoAlign" + "const": "fifthLevelPackage" }, { - "const": "matrixWrapWithAlign" + "const": "fullPackage" } ] }, - "formatter.config.WhitespacePolicy": { + "formatter.config.CaseColonLineEndPolicy": { "anyOf": [ { "const": "none" }, { - "const": "before" + "const": "after" + } + ] + }, + "formatter.config.WrapConfig": { + "properties": { + "anonFunctionSignature": { + "description": "anon function signature wrapping rules", + "$ref": "#/definitions/formatter.config.WrapRules" }, - { - "const": "noneBefore" + "callParameter": { + "description": "call parameter wrapping rules", + "$ref": "#/definitions/formatter.config.WrapRules" }, - { - "const": "onlyBefore" + "arrayMatrixWrap": { + "description": "detect arrays in matrix configuration from source noMatrixWrap = no detection matrixWrapNoAlign = detect and format as matrix without alignment matrixWrapWithAlign = detect and format as matrix and align columns", + "$ref": "#/definitions/formatter.config.ArrayMatrixWrap", + "default": "matrixWrapWithAlign" }, - { - "const": "after" + "anonType": { + "description": "anon types wrapping rules", + "$ref": "#/definitions/formatter.config.WrapRules" }, - { - "const": "onlyAfter" + "implementsExtends": { + "description": "implements / extends chain wrapping rules", + "$ref": "#/definitions/formatter.config.WrapRules" }, - { - "const": "noneAfter" + "methodChain": { + "description": "method chaining wrapping rules", + "$ref": "#/definitions/formatter.config.WrapRules" }, - { - "const": "around" + "multiVar": { + "description": "chain wrapping rules for OpAdd / OpSub", + "$ref": "#/definitions/formatter.config.WrapRules" + }, + "maxLineLength": { + "description": "maximum characters per line, formatter will try to wrap code longer than `maxLineLength`", + "default": 160, + "type": "integer" + }, + "functionSignature": { + "description": "named function signature wrapping rules", + "$ref": "#/definitions/formatter.config.WrapRules" + }, + "typeParameter": { + "description": "type parameter wrapping rules", + "$ref": "#/definitions/formatter.config.WrapRules" + }, + "objectLiteral": { + "description": "object literal wrapping rules", + "$ref": "#/definitions/formatter.config.WrapRules" + }, + "opBoolChain": { + "description": "OpBool chain wrapping rules", + "$ref": "#/definitions/formatter.config.WrapRules" + }, + "opAddSubChain": { + "description": "chain wrapping rules for OpAdd / OpSub", + "$ref": "#/definitions/formatter.config.WrapRules" + }, + "casePattern": { + "description": "chain wrapping rules for case patterns", + "$ref": "#/definitions/formatter.config.WrapRules" + }, + "metadataCallParameter": { + "description": "metadata call parameter wrapping rules", + "$ref": "#/definitions/formatter.config.WrapRules" + }, + "arrayWrap": { + "description": "array wrapping rules does not affect array comprehension, use \"sameLine.comprehensionFor\"", + "$ref": "#/definitions/formatter.config.WrapRules" } - ] + }, + "additionalProperties": false, + "type": "object" } }, - "$ref": "#/definitions/formatter.config.FormatterConfig" + "$ref": "#/definitions/formatter.config.FormatterConfig", + "$schema": "http://json-schema.org/draft-07/schema#" } \ No newline at end of file diff --git a/src/formatter/marker/MarkLineEnds.hx b/src/formatter/marker/MarkLineEnds.hx index 40a58d7..f1ce725 100644 --- a/src/formatter/marker/MarkLineEnds.hx +++ b/src/formatter/marker/MarkLineEnds.hx @@ -329,7 +329,7 @@ class MarkLineEnds extends MarkerBase { return; } switch (nextToken.token.tok) { - case PClose: + case PClose | BkClose: case Dot: case Comma: case Semicolon: diff --git a/test/TestCaseMacro.hx b/test/TestCaseMacro.hx index 57b4792..5b2e8ad 100644 --- a/test/TestCaseMacro.hx +++ b/test/TestCaseMacro.hx @@ -1,6 +1,7 @@ import haxe.io.Path; import haxe.macro.Context; import haxe.macro.Expr; +import haxe.macro.Type.ClassType; import sys.FileSystem; import sys.io.File; @@ -8,6 +9,11 @@ class TestCaseMacro { #if macro public macro static function build(folder:String):Array { var fields:Array = Context.getBuildFields(); + var cls:ClassType = Context.getLocalClass().get(); + + if (!shouldApply(cls, ":testcases")) { + return fields; + } var testCases:Array = collectAllFileNames(folder); var singleRun:TestSingleRun = new TestSingleRun(); for (testCase in testCases) { @@ -23,6 +29,17 @@ class TestCaseMacro { return fields; } + public static function shouldApply(cls:ClassType, what:String):Bool { + if (cls.meta.has(what)) { + return false; + } + + if (cls.superClass == null) { + return true; + } + return shouldApply(cls.superClass.t.get(), what); + } + static function buildTestCaseField(fileName:String):Field { var content:String = sys.io.File.getContent(fileName); var nl = "\r?\n";