Allon Mureinik has posted comments on this change.
Change subject: build: checkstyle to disallow final members
......................................................................
Patch Set 2: (2 inline comments)
....................................................
File
build-tools-root/ovirt-checkstyle-extension/src/main/java/checks/NoFinalMemberCheck.java
Line 22: public void visitToken(DetailAST aAST) {
Line 23: if (run) {
Line 24: if (aAST.getType() == TokenTypes.VARIABLE_DEF // A variable
Line 25: && aAST.getParent().getType() ==
TokenTypes.OBJBLOCK // which is a class variable
Line 26: && aAST.getParent().getParent().getType() !=
TokenTypes.ENUM_DEF // and not in an enum
Nope, see
http://checkstyle.sourceforge.net/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CLASS_DEF
The parent of a member variable in OBJBLOCK, and its parent is the CLASSDEF.
Line 27: ) {
Line 28:
Line 29: // find the modifiers
Line 30: DetailAST child = aAST.getFirstChild();
Line 31: while (child != null) {
Line 32: // final is only allowed for statics (i.e.,
constants)
Line 33: if (child.branchContains(TokenTypes.FINAL) &&
Line 34:
!child.branchContains(TokenTypes.LITERAL_STATIC)) {
Line 35: log(child.getLineNo(), child.getColumnNo(),
"non-static final member variables are not allowed");
Couldn't figure out an elegant way to get the member's name, but this prints
the exact line and column where the problem is.
If I have several problematic members in a class - I'd want to get a message
about each.
Line 36: }
Line 37: child = child.getNextSibling();
Line 38: }
Line 39: }
--
To view, visit http://gerrit.ovirt.org/16252
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I809e7f670cf86b47dbd7ae1fc6f73eff9837a129
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Allon Mureinik <[email protected]>
Gerrit-Reviewer: Alissa Bonas <[email protected]>
Gerrit-Reviewer: Allon Mureinik <[email protected]>
Gerrit-Reviewer: Daniel Erez <[email protected]>
Gerrit-Reviewer: Tal Nisan <[email protected]>
Gerrit-Reviewer: Vojtech Szocs <[email protected]>
Gerrit-Reviewer: Yair Zaslavsky <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches