From 0fcae24380f86386ada6b2bb017c2ffe98ecb17e Mon Sep 17 00:00:00 2001 From: alexkravin Date: Sun, 11 Jan 2015 14:13:07 +0400 Subject: [PATCH] Prefixes, modifier, #512 --- .../checks/modifier/ModifierOrderCheck.java | 10 ++--- .../modifier/RedundantModifierCheck.java | 38 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/modifier/ModifierOrderCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/modifier/ModifierOrderCheck.java index bbe2d8296..f740fcab6 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/modifier/ModifierOrderCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/modifier/ModifierOrderCheck.java @@ -82,10 +82,10 @@ public class ModifierOrderCheck } @Override - public void visitToken(DetailAST aAST) + public void visitToken(DetailAST ast) { final List mods = Lists.newArrayList(); - DetailAST modifier = aAST.getFirstChild(); + DetailAST modifier = ast.getFirstChild(); while (modifier != null) { mods.add(modifier); modifier = modifier.getNextSibling(); @@ -114,15 +114,15 @@ public class ModifierOrderCheck * Checks if the modifiers were added in the order suggested * in the Java language specification. * - * @param aModifiers list of modifier AST tokens + * @param modifiers list of modifier AST tokens * @return null if the order is correct, otherwise returns the offending * * modifier AST. */ - DetailAST checkOrderSuggestedByJLS(List aModifiers) + DetailAST checkOrderSuggestedByJLS(List modifiers) { int i = 0; DetailAST modifier; - final Iterator it = aModifiers.iterator(); + final Iterator it = modifiers.iterator(); //No modifiers, no problems if (!it.hasNext()) { return null; diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheck.java index a36ba2831..34363a039 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheck.java @@ -52,11 +52,11 @@ public class RedundantModifierCheck } @Override - public void visitToken(DetailAST aAST) + public void visitToken(DetailAST ast) { - if (TokenTypes.INTERFACE_DEF == aAST.getType()) { + if (TokenTypes.INTERFACE_DEF == ast.getType()) { final DetailAST modifiers = - aAST.findFirstToken(TokenTypes.MODIFIERS); + ast.findFirstToken(TokenTypes.MODIFIERS); if (null != modifiers) { for (final int tokenType : new int[] { TokenTypes.LITERAL_STATIC, @@ -71,8 +71,8 @@ public class RedundantModifierCheck } } } - else if (isInterfaceOrAnnotationMember(aAST)) { - final DetailAST modifiers = aAST.findFirstToken(TokenTypes.MODIFIERS); + else if (isInterfaceOrAnnotationMember(ast)) { + final DetailAST modifiers = ast.findFirstToken(TokenTypes.MODIFIERS); DetailAST modifier = modifiers.getFirstChild(); while (modifier != null) { @@ -83,7 +83,7 @@ public class RedundantModifierCheck final int type = modifier.getType(); if ((type == TokenTypes.LITERAL_PUBLIC) || ((type == TokenTypes.LITERAL_STATIC) - && aAST.getType() != TokenTypes.METHOD_DEF) + && ast.getType() != TokenTypes.METHOD_DEF) || (type == TokenTypes.ABSTRACT) || (type == TokenTypes.FINAL)) { @@ -95,14 +95,14 @@ public class RedundantModifierCheck modifier = modifier.getNextSibling(); } } - else if (aAST.getType() == TokenTypes.METHOD_DEF) { + else if (ast.getType() == TokenTypes.METHOD_DEF) { final DetailAST modifiers = - aAST.findFirstToken(TokenTypes.MODIFIERS); + ast.findFirstToken(TokenTypes.MODIFIERS); // private method? boolean checkFinal = modifiers.branchContains(TokenTypes.LITERAL_PRIVATE); // declared in a final class? - DetailAST parent = aAST.getParent(); + DetailAST parent = ast.getParent(); while (parent != null) { if (parent.getType() == TokenTypes.CLASS_DEF) { final DetailAST classModifiers = @@ -113,7 +113,7 @@ public class RedundantModifierCheck } parent = parent.getParent(); } - if (checkFinal && !isAnnotatedWithSafeVarargs(aAST)) { + if (checkFinal && !isAnnotatedWithSafeVarargs(ast)) { DetailAST modifier = modifiers.getFirstChild(); while (modifier != null) { final int type = modifier.getType(); @@ -130,12 +130,12 @@ public class RedundantModifierCheck /** * Checks if current AST node is member of Interface or Annotation, not of their subnodes. - * @param aAST AST node + * @param ast AST node * @return true or false */ - private static boolean isInterfaceOrAnnotationMember(DetailAST aAST) + private static boolean isInterfaceOrAnnotationMember(DetailAST ast) { - final DetailAST parentTypeDef = aAST.getParent().getParent(); + final DetailAST parentTypeDef = ast.getParent().getParent(); return parentTypeDef.getType() == TokenTypes.INTERFACE_DEF || parentTypeDef.getType() == TokenTypes.ANNOTATION_DEF; } @@ -144,13 +144,13 @@ public class RedundantModifierCheck * Checks if method definition is annotated with * * SafeVarargs annotation - * @param aMethodDef method definition node + * @param methodDef method definition node * @return true or false */ - private static boolean isAnnotatedWithSafeVarargs(DetailAST aMethodDef) + private static boolean isAnnotatedWithSafeVarargs(DetailAST methodDef) { boolean result = false; - final List methodAnnotationsList = getMethodAnnotationsList(aMethodDef); + final List methodAnnotationsList = getMethodAnnotationsList(methodDef); for (DetailAST annotationNode : methodAnnotationsList) { if ("SafeVarargs".equals(annotationNode.getLastChild().getText())) { result = true; @@ -162,13 +162,13 @@ public class RedundantModifierCheck /** * Gets the list of annotations on method definition - * @param aMethodDef method definition node + * @param methodDef method definition node * @return List of annotations */ - private static List getMethodAnnotationsList(DetailAST aMethodDef) + private static List getMethodAnnotationsList(DetailAST methodDef) { final List annotationsList = new ArrayList<>(); - final DetailAST modifiers = aMethodDef.findFirstToken(TokenTypes.MODIFIERS); + final DetailAST modifiers = methodDef.findFirstToken(TokenTypes.MODIFIERS); DetailAST modifier = modifiers.getFirstChild(); while (modifier != null) { if (modifier.getType() == TokenTypes.ANNOTATION) {