Skip to content

Commit a1b25bc

Browse files
committed
cleanup
1 parent 677f64b commit a1b25bc

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

checkstyle/Checker.hx

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@ import haxeparser.Data.Token;
99

1010
class Checker {
1111

12+
public var file:LintFile;
13+
public var lines:Array<String>;
14+
public var tokens:Array<Token>;
15+
public var ast:Ast;
16+
1217
var checks:Array<Check>;
1318
var reporters:Array<IReporter>;
14-
public var file:LintFile;
19+
var linesIdx:Array<LineIds>;
20+
var lineSeparator:String;
1521

1622
public function new() {
1723
checks = [];
@@ -44,19 +50,13 @@ class Checker {
4450
if (left) linesIdx.push({l:last, r:code.length-1});
4551
}
4652

47-
var linesIdx:Array<{l:Int,r:Int}>;
48-
49-
public function getLinePos(off:Int):{line:Int, ofs:Int} {
53+
public function getLinePos(off:Int):LinePos {
5054
for (i in 0...linesIdx.length) {
51-
if (linesIdx[i].l <= off && linesIdx[i].r >= off) return {line:i,ofs:off-linesIdx[i].l};
55+
if (linesIdx[i].l <= off && linesIdx[i].r >= off) return { line:i,ofs: off-linesIdx[i].l };
5256
}
5357
throw "Bad offset";
5458
}
5559

56-
public var lines:Array<String>;
57-
58-
var lineSeparator:String;
59-
6060
function findLineSeparator() {
6161
var code = file.content;
6262
for (i in 0 ... code.length){
@@ -81,8 +81,6 @@ class Checker {
8181
lines = code.split(lineSeparator);
8282
}
8383

84-
public var tokens:Array<Token>;
85-
8684
function makeTokens() {
8785
var code = file.content;
8886
tokens = [];
@@ -95,8 +93,6 @@ class Checker {
9593
}
9694
}
9795

98-
public var ast:{pack: Array<String>, decls: Array<TypeDecl>};
99-
10096
function makeAST() {
10197
var code = file.content;
10298
var parser = new haxeparser.HaxeParser(byte.ByteData.ofString(code), file.name);
@@ -105,9 +101,7 @@ class Checker {
105101

106102
public function process(files:Array<LintFile>) {
107103
for (reporter in reporters) reporter.start();
108-
109104
for (file in files) run(file);
110-
111105
for (reporter in reporters) reporter.finish();
112106
}
113107

@@ -155,4 +149,19 @@ class Checker {
155149

156150
for (reporter in reporters) reporter.fileFinish(file);
157151
}
152+
}
153+
154+
typedef LinePos = {
155+
var line:Int;
156+
var ofs:Int;
157+
}
158+
159+
typedef LineIds = {
160+
var l:Int;
161+
var r:Int;
162+
}
163+
164+
typedef Ast = {
165+
var pack:Array<String>;
166+
var decls:Array<TypeDecl>;
158167
}

run.n

-213 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)