Refine search
/** * Checks if current generic end ('>') is located after * {@link TokenTypes#METHOD_REF method reference operator}. * @param genericEnd {@link TokenTypes#GENERIC_END} * @return true if '>' follows after method reference. */ private static boolean isAfterMethodReference(DetailAST genericEnd) { return genericEnd.getParent().getParent().getType() == TokenTypes.METHOD_REF; }
/** * Checks if logical operator is part of constructor or method call. * @param logicalOperator logical operator * @return true if logical operator is part of constructor or method call */ private static boolean isPassedInParameter(DetailAST logicalOperator) { return logicalOperator.getParent().getParent().getType() == TokenTypes.ELIST; }
/** * If variable definition is a type field. * @param variableDef variable definition. * @return true variable definition is a type field. */ private static boolean isTypeField(DetailAST variableDef) { final int parentType = variableDef.getParent().getParent().getType(); return parentType == TokenTypes.CLASS_DEF; }
/** * Get node that owns {@link TokenTypes#ARRAY_DECLARATOR ARRAY_DECLARATOR} sequence. * @param ast * , {@link TokenTypes#ARRAY_DECLARATOR ARRAY_DECLARATOR} node. * @return owner node. */ private static DetailAST getFirstNonArrayDeclaratorParent(DetailAST ast) { DetailAST parent = ast.getParent(); while (parent.getType() == TokenTypes.ARRAY_DECLARATOR) { parent = parent.getParent(); } return parent; }
/** * Is generic before method reference. * @param ast ast * @return true if generic before a method ref */ private static boolean isGenericBeforeMethod(DetailAST ast) { return ast.getParent().getParent().getType() == TokenTypes.DOT && ast.getParent().getParent().getParent().getType() == TokenTypes.METHOD_CALL || isAfterMethodReference(ast); }
/** * Checks if a variable is the loop's one. * @param variableDef variable definition. * @return true if a variable is the loop's one. */ private static boolean isForLoopVariable(DetailAST variableDef) { final int parentType = variableDef.getParent().getType(); return parentType == TokenTypes.FOR_INIT || parentType == TokenTypes.FOR_EACH_CLAUSE; }
/** * Checks if {@link TokenTypes#BOR binary OR} is applied to exceptions * in * <a href="https://docs.oracle.com/javase/specs/jls/se8/html/jls-14.html#jls-14.20"> * multi-catch</a> (pipe-syntax). * @param binaryOr {@link TokenTypes#BOR binary or} * @return true if binary or is applied to exceptions in multi-catch. */ private static boolean isPipeOperator(DetailAST binaryOr) { return binaryOr.getParent().getType() == TokenTypes.TYPE; }
/** * Checks if ast is in an annotation field. * @param ast ast to test. * @return true if current ast is part of an annotation field. */ private static boolean isInAnnotationField(DetailAST ast) { boolean isDefaultInAnnotation = false; if (ast.getParent().getType() == TokenTypes.ANNOTATION_FIELD_DEF) { isDefaultInAnnotation = true; } return isDefaultInAnnotation; }
/** * Determines whether enhanced for-loop variable should be checked or not. * @param ast The ast to compare. * @return true if enhanced for-loop variable should be checked. */ private boolean shouldCheckEnhancedForLoopVariable(DetailAST ast) { return validateEnhancedForLoopVariable || ast.getParent().getType() != TokenTypes.FOR_EACH_CLAUSE; }
/** * Checks if current variable definition is definition of an anonymous class. * @param variableDef {@link TokenTypes#VARIABLE_DEF VARIABLE_DEF} * @return true if current variable definition is definition of an anonymous class. */ private static boolean isAnonymousClassVariable(DetailAST variableDef) { return variableDef.getParent().getType() != TokenTypes.OBJBLOCK; }
/** * Returns type of parent node. * @param commentBlock child node. * @return parent type. */ private static int getParentType(DetailAST commentBlock) { final DetailAST parentNode = commentBlock.getParent(); int type = parentNode.getType(); if (type == TokenTypes.TYPE || type == TokenTypes.MODIFIERS) { type = parentNode.getParent().getType(); } return type; }
/** * Checks that block comment is on specified token with modifiers. * @param blockComment block comment start DetailAST * @param tokenType parent token type * @return true if block comment is on specified token with modifiers */ private static boolean isOnTokenWithModifiers(DetailAST blockComment, int tokenType) { return blockComment.getParent() != null && blockComment.getParent().getType() == TokenTypes.MODIFIERS && blockComment.getParent().getParent().getType() == tokenType && getPrevSiblingSkipComments(blockComment) == null; }
/** * Checks if current AST node is member of Interface or Annotation, not of their subnodes. * @param ast AST node * @return true or false */ private static boolean isInterfaceOrAnnotationMember(DetailAST ast) { DetailAST parentTypeDef = ast.getParent(); if (parentTypeDef != null) { parentTypeDef = parentTypeDef.getParent(); } return parentTypeDef != null && (parentTypeDef.getType() == TokenTypes.INTERFACE_DEF || parentTypeDef.getType() == TokenTypes.ANNOTATION_DEF); }