/**
   * Checks type of given method, parameter or variable.
   *
   * @param aAST node to check.
   */
  private void checkClassName(DetailAST aAST) {
    final DetailAST type = aAST.findFirstToken(TokenTypes.TYPE);
    final FullIdent ident = CheckUtils.createFullType(type);

    if (isMatchingClassName(ident.getText())) {
      log(ident.getLineNo(), ident.getColumnNo(), "illegal.type", ident.getText());
    }
  }
예제 #2
0
 /**
  * Decides whether the number of an AST is in the ignore list of this check.
  *
  * @param ast the AST to check
  * @return true if the number of ast is in the ignore list of this check.
  */
 private boolean inIgnoreList(DetailAST ast) {
   double value = CheckUtils.parseDouble(ast.getText(), ast.getType());
   final DetailAST parent = ast.getParent();
   if (parent.getType() == TokenTypes.UNARY_MINUS) {
     value = -1 * value;
   }
   return Arrays.binarySearch(ignoreNumbers, value) >= 0;
 }
예제 #3
0
 /**
  * Finds next token after the given one.
  *
  * @param ast the given node.
  * @return the token which represents next lexical item.
  */
 private static DetailAST getNextToken(DetailAST ast) {
   DetailAST next = null;
   DetailAST parent = ast;
   while (parent != null && next == null) {
     next = parent.getNextSibling();
     parent = parent.getParent();
   }
   return CheckUtils.getFirstNode(next);
 }
 /**
  * @param expr node to check.
  * @return true if given node contains numeric constant for zero.
  */
 private boolean isZero(DetailAST expr) {
   final int type = expr.getType();
   switch (type) {
     case TokenTypes.NUM_FLOAT:
     case TokenTypes.NUM_DOUBLE:
     case TokenTypes.NUM_INT:
     case TokenTypes.NUM_LONG:
       final String text = expr.getText();
       return 0 == CheckUtils.parseFloat(text, type);
     default:
       return false;
   }
 }
 /**
  * Visits type.
  *
  * @param aAST type to process.
  */
 public void visitType(DetailAST aAST) {
   final String className = CheckUtils.createFullType(aAST).getText();
   mContext.addReferencedClassName(className);
 }
 /**
  * Checks whether the current method/variable definition type is "Boolean".
  *
  * @param aNode - current method or variable definition node.
  * @return "true" if current method or variable has a Boolean type.
  */
 public final boolean isBooleanType(final DetailAST aNode) {
   return mBOOLEAN.equals(
       CheckUtils.createFullType(aNode.findFirstToken(TokenTypes.TYPE)).getText());
 }