diff --git a/.haxerc b/.haxerc index ec50a4f..bb6b658 100644 --- a/.haxerc +++ b/.haxerc @@ -1,4 +1,4 @@ { - "version": "651ecf3", + "version": "779b005", "resolveLibs": "scoped" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bd3ab1..f064135 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## dev branch / next version (1.x.x) +## version 1.14.0 (2022-08-27) + +- Added support for inline markup, fixes [#523](https://github.com/HaxeCheckstyle/haxe-formatter/issues/523) + [#624](https://github.com/HaxeCheckstyle/haxe-formatter/issues/624) ([#655](https://github.com/HaxeCheckstyle/haxe-formatter/issues/655)) + ## version 1.13.1 (2022-04-26) - Fixed conditional line ends / wrapping ([#654](https://github.com/HaxeCheckstyle/haxe-formatter/issues/654)) diff --git a/haxe_libraries/tokentree.hxml b/haxe_libraries/tokentree.hxml index ea3e15c..cd40b7e 100644 --- a/haxe_libraries/tokentree.hxml +++ b/haxe_libraries/tokentree.hxml @@ -1,3 +1,3 @@ -# @install: lix --silent download "haxelib:/tokentree#1.1.2" into tokentree/1.1.2/haxelib --cp ${HAXE_LIBCACHE}/tokentree/1.1.2/haxelib/src --D tokentree=1.1.2 \ No newline at end of file +# @install: lix --silent download "haxelib:/tokentree#1.2.0" into tokentree/1.2.0/haxelib +-cp ${HAXE_LIBCACHE}/tokentree/1.2.0/haxelib/src +-D tokentree=1.2.0 \ No newline at end of file diff --git a/haxelib.json b/haxelib.json index 9dccc49..b1931d3 100644 --- a/haxelib.json +++ b/haxelib.json @@ -8,8 +8,8 @@ "style" ], "description": "A code formatter for Haxe", - "version": "1.13.1", - "releasenote": "fixed conditional line ends / wrapping, fixed whitespace after from/to with arrow functions - see CHANGELOG for details.", + "version": "1.14.0", + "releasenote": "added support for inline markup - see CHANGELOG for details.", "contributors": [ "AlexHaxe", "Gama11" diff --git a/package-lock.json b/package-lock.json index 7b672ad..051e295 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@haxecheckstyle/haxe-formatter", - "version": "1.13.1", + "version": "1.14.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@haxecheckstyle/haxe-formatter", - "version": "1.13.1", + "version": "1.14.0", "license": "MIT", "bin": { "haxe-formatter": "bin/formatter.js" diff --git a/package.json b/package.json index 25de582..f5c3a4e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@haxecheckstyle/haxe-formatter", - "version": "1.13.1", + "version": "1.14.0", "description": "A code formatter for Haxe", "repository": { "type": "git", diff --git a/src/formatter/codedata/ParsedCode.hx b/src/formatter/codedata/ParsedCode.hx index fa8f229..fecca49 100644 --- a/src/formatter/codedata/ParsedCode.hx +++ b/src/formatter/codedata/ParsedCode.hx @@ -72,6 +72,15 @@ class ParsedCode { skipCount = 1; case Binop(OpGte): skipCount = 1; + case Const(CMarkup(_)): + var skipIndex = index + 1; + while (true) { + if (tokens[skipIndex].pos.min >= token.pos.max) { + break; + } + skipCount++; + skipIndex++; + } case Const(CInt(v)): if (v.startsWith("-")) { skipCount = 1; diff --git a/src/formatter/import.hx b/src/formatter/import.hx index 4f05fad..ef92f20 100644 --- a/src/formatter/import.hx +++ b/src/formatter/import.hx @@ -1,9 +1,9 @@ package formatter; #if (tokentree && !macro) -import byte.ByteData; import haxe.io.Bytes; import haxe.macro.Expr; +import byte.ByteData; import haxeparser.Data; import tokentree.TokenTree; import tokentree.TokenTreeAccessHelper; diff --git a/test/TestCaseMacro.hx b/test/TestCaseMacro.hx index a249a3a..57b4792 100644 --- a/test/TestCaseMacro.hx +++ b/test/TestCaseMacro.hx @@ -1,8 +1,8 @@ -import haxe.macro.Expr; -import haxe.macro.Context; import haxe.io.Path; -import sys.io.File; +import haxe.macro.Context; +import haxe.macro.Expr; import sys.FileSystem; +import sys.io.File; class TestCaseMacro { #if macro diff --git a/test/testcases/other/inline_markup.hxtest b/test/testcases/other/inline_markup.hxtest new file mode 100644 index 0000000..509e5c7 --- /dev/null +++ b/test/testcases/other/inline_markup.hxtest @@ -0,0 +1,76 @@ +{} + +--- + +function inline_markup() { + + + static var SRC = + + @exampleText("!") + + + ; + + super (); + super (); + + ; + ; + ; + +
; + $${x < foo ? "a" : "b"}; + + ; + ; + + ; + ; + + static var SRC = + for( x in arr ) + + for( y in arr ) { + + + } + +} + +--- + +function inline_markup() { + + + static var SRC = + @exampleText("!") + + + ; + + super(); + super(); + + ; + ; + ; + +
; + $${x < foo ? "a" : "b"}; + + ; + ; + + ; + ; + + static var SRC = + for( x in arr ) + + for( y in arr ) { + + + } + +} diff --git a/test/testcases/other/issue_523_inline_markup.hxtest b/test/testcases/other/issue_523_inline_markup.hxtest new file mode 100644 index 0000000..3fb33df --- /dev/null +++ b/test/testcases/other/issue_523_inline_markup.hxtest @@ -0,0 +1,50 @@ +{ + "indentation": { + "character": " " + }, + "sameLine": { + "ifBody": "keep", + "elseIf": "keep", + "elseBody": "keep", + "forBody": "keep", + "whileBody": "keep" + } +} + +--- + +class Test { + function main() { + final user = "usr"; + + XmlTools.toString( + + + + ${user} + + + + + + ); + } +} + +--- + +class Test { + function main() { + final user = "usr"; + + XmlTools.toString( + + + ${user} + + + + + ); + } +} diff --git a/test/testcases/other/issue_624_inline_markup.hxtest b/test/testcases/other/issue_624_inline_markup.hxtest new file mode 100644 index 0000000..719df75 --- /dev/null +++ b/test/testcases/other/issue_624_inline_markup.hxtest @@ -0,0 +1,33 @@ +{} + +--- + +// https://heaps.io/documentation/domkit.html +class SampleView extends h2d.Flow implements h2d.domkit.Object { + + static var SRC = + + Hello World! + + + + public function new(tile:h2d.Tile,?parent) { + super(parent); + initComponent(); + } +} + +--- + +// https://heaps.io/documentation/domkit.html +class SampleView extends h2d.Flow implements h2d.domkit.Object { + static var SRC = + Hello World! + + + + public function new(tile:h2d.Tile, ?parent) { + super(parent); + initComponent(); + } +}