Skip to content

Commit 0b052e5

Browse files
francoisvnGama11
authored andcommitted
Fix/multiline file boundary issue (#277)
1 parent 9d30630 commit 0b052e5

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/checkstyle/checks/whitespace/LineCheckBase.hx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ class LineCheckBase extends Check {
1616
multilineStringStart = false;
1717
}
1818

19+
override public function run(checker:Checker):Array<CheckMessage> {
20+
multilineStringStart = false;
21+
return super.run(checker);
22+
}
23+
1924
function isMultineString(line:String):Bool {
2025
if (!multilineStringStart && quotesRE.match(line)) {
2126
var matched = quotesRE.matched(0);

src/checkstyle/token/TokenStream.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class TokenStream {
5353
public inline function error(s:String) {
5454
throw formatCurrentPos() + ": " + s;
5555
}
56-
56+
5757
function formatCurrentPos():String {
5858
var pos = tokens[current].pos;
5959
return new Position(pos.file, pos.min, pos.max).format(bytes);

test/checks/whitespace/IndentationCharacterCheckTest.hx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ class IndentationCharacterCheckTest extends CheckTestCase<IndentationCheckTests>
3030
check.severity = SeverityLevel.INFO;
3131
assertNoMsg(check, TEST4);
3232
}
33+
34+
public function testFileBoundaryIndentation() {
35+
var check = new IndentationCharacterCheck();
36+
check.severity = SeverityLevel.INFO;
37+
assertNoMsg(check, TEST5_1);
38+
assertMsg(check, TEST5_2, "Wrong indentation character (should be tab)");
39+
}
3340
}
3441

3542
@:enum
@@ -60,4 +67,18 @@ abstract IndentationCheckTests(String) to String {
6067
}
6168
}
6269
}";
70+
71+
var TEST5_1 =
72+
"class Test {
73+
public function new() {
74+
// breaking comment with quote '
75+
}
76+
}";
77+
78+
var TEST5_2 =
79+
"class Test {
80+
public function new() {
81+
// bad indentation here
82+
}
83+
}";
6384
}

0 commit comments

Comments
 (0)