-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #144 from adireddy/refactor-exclude
ArrayAccessCheck & Refactor exclude
- Loading branch information
Showing
20 changed files
with
189 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package checkstyle.checks.coding; | ||
|
||
import haxe.macro.Expr; | ||
import checkstyle.utils.ExprUtils; | ||
|
||
@name("ArrayAccess") | ||
@desc("Spacing check on array access") | ||
class ArrayAccessCheck extends Check { | ||
|
||
public var spaceBefore:Bool; | ||
public var spaceInside:Bool; | ||
|
||
public function new() { | ||
super(AST); | ||
spaceBefore = false; | ||
spaceInside = false; | ||
} | ||
|
||
override function actualRun() { | ||
var lastExpr = null; | ||
|
||
ExprUtils.walkFile(checker.ast, function(e:Expr) { | ||
if (lastExpr == null) { | ||
lastExpr = e; | ||
return; | ||
} | ||
|
||
switch (e.expr) { | ||
case EArray(e1, e2): | ||
if (!spaceBefore) { | ||
var e1length = e1.pos.max - e1.pos.min; | ||
var eString = checker.getString(e.pos.min, e.pos.max); | ||
if (eString.substr(e1length, 1) == " ") logPos('Space between array and [', e.pos); | ||
} | ||
|
||
if (!spaceInside) { | ||
var eString = checker.getString(e.pos.min, e.pos.max); | ||
if (checker.file.content.substr(e2.pos.min - 1, 1) == " ") logPos('Space between [ and index', e.pos); | ||
if (checker.file.content.substr(e2.pos.max, 1) == " ") logPos('Space between index and ]', e.pos); | ||
} | ||
default: | ||
} | ||
|
||
lastExpr = e; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.