Skip to content

Commit

Permalink
fix metadata with parameter, fixes #241 (#242)
Browse files Browse the repository at this point in the history
* fix metadata with parameter, fixes #241
* added testcase, #240
  • Loading branch information
AlexHaxe authored Oct 2, 2018
1 parent 71952ab commit ec93fbd
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Fixed wrapping function signature with long type hint, fixes [#189](https://github.com/HaxeCheckstyle/haxe-formatter/issues/189) ([#239](https://github.com/HaxeCheckstyle/haxe-formatter/issues/239))
- Fixed indentation with comment line, fixes [#237](https://github.com/HaxeCheckstyle/haxe-formatter/issues/237) ([#239](https://github.com/HaxeCheckstyle/haxe-formatter/issues/239))
- Fixed wrapping option keep, fixes [#238](https://github.com/HaxeCheckstyle/haxe-formatter/issues/238) ([#239](https://github.com/HaxeCheckstyle/haxe-formatter/issues/239))
- Fixed handling of metadata parameter, fixes [#241](https://github.com/HaxeCheckstyle/haxe-formatter/issues/241) ([#242](https://github.com/HaxeCheckstyle/haxe-formatter/issues/242))
- Changed default rules for function signature, see [#232](https://github.com/HaxeCheckstyle/haxe-formatter/issues/232) ([#233](https://github.com/HaxeCheckstyle/haxe-formatter/issues/233))
- Refactored marker classes to use a common base class [#239](https://github.com/HaxeCheckstyle/haxe-formatter/issues/239)

Expand Down
3 changes: 2 additions & 1 deletion src/formatter/marker/MarkWrapping.hx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class MarkWrapping extends MarkerBase {
if ((info.whitespaceAfter != Newline) && (info.whitespaceAfter != SpaceOrNewline)) {
whitespace(close, After);
}
case Semicolon, Dot, POpen:
case POpen:
case Semicolon, Dot:
whitespace(close, NoneAfter);
case Binop(OpGt):
whitespace(close, NoneAfter);
Expand Down
25 changes: 25 additions & 0 deletions test/testcases/emptylines/issue_240_class_empty_lines.hxtest
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"emptyLines": {
"classEmptyLines": {
"beginType": 1
},
"afterLeftCurly": "keep"
}
}

---

class Main {
static function main() {
doSomething("");
}
}

---

class Main {

static function main() {
doSomething("");
}
}
22 changes: 22 additions & 0 deletions test/testcases/whitespace/issue_241_metadata_with_parameter.hxtest
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{}


---


class Main {
@:overload(function())
static function main() {
trace(@:privateAccess (X).object);
}
}


---

class Main {
@:overload(function())
static function main() {
trace(@:privateAccess (X).object);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"whitespace": {
"openingParenPolicy": "before"
}
}

---


class Main {
@:overload(function())
static function main() {
trace(@:privateAccess (X).object);
}
}


---

class Main {
@:overload(function ())
static function main () {
trace (@:privateAccess (X).object);
}
}
19 changes: 19 additions & 0 deletions test/testcases/whitespace/whitespace_after_type_parameter.hxtest
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"whitespace": {
"openingParenPolicy": "before"
}
}


---


class Main {
static function main<T>():Array<T> {}
}

---

class Main {
static function main<T> ():Array<T> {}
}

0 comments on commit ec93fbd

Please sign in to comment.