/** * Perform processing for an import token. * @param ast the import token */ private void processImport(DetailAST ast) { final FullIdent name = FullIdent.createFullIdentBelow(ast); // Note: different from UnusedImportsCheck.processImport(), // '.*' imports are also added here imports.add(name); }
/** * Collects the details of imports. * @param ast node containing the import details */ private void processImport(DetailAST ast) { final FullIdent name = FullIdent.createFullIdentBelow(ast); imports.add(name.getText()); }
/** * Collects the details of imports. * @param ast node containing the import details */ private void processImport(DetailAST ast) { final FullIdent name = FullIdent.createFullIdentBelow(ast); if (!name.getText().endsWith(STAR_IMPORT_SUFFIX)) { imports.add(name); } }
/** * Get name of instance whose method is called. * @param methodCallAst * DetailAST of METHOD_CALL. * @return name of instance. */ private static String getInstanceName(DetailAST methodCallAst) { final String methodCallName = FullIdent.createFullIdentBelow(methodCallAst).getText(); final int lastDotIndex = methodCallName.lastIndexOf('.'); String instanceName = ""; if (lastDotIndex != -1) { instanceName = methodCallName.substring(0, lastDotIndex); } return instanceName; }
/** * Collects the details of imports. * * @param aAST node containing the import details */ private void processImport( DetailAST aAST ) { final FullIdent name = FullIdent.createFullIdentBelow(aAST); if ((name != null) && !name.getText().endsWith(".*")) { imports.add(name); } }
/** * Determines if an AST is a formal param of type Object. * @param paramNode the AST to check * @return true if firstChild is a parameter of an Object type. */ private static boolean isObjectParam(DetailAST paramNode) { final DetailAST typeNode = paramNode.findFirstToken(TokenTypes.TYPE); final FullIdent fullIdent = FullIdent.createFullIdentBelow(typeNode); final String name = fullIdent.getText(); return "Object".equals(name) || "java.lang.Object".equals(name); }
/** * Tests whether a method's first parameter is an Object. * @param methodDefAst the method definition AST to test. * Precondition: ast is a TokenTypes.METHOD_DEF node. * @return true if ast has first parameter of type Object. */ private static boolean isFirstParameterObject(DetailAST methodDefAst) { final DetailAST paramsNode = methodDefAst.findFirstToken(TokenTypes.PARAMETERS); // parameter type "Object"? final DetailAST paramNode = paramsNode.findFirstToken(TokenTypes.PARAMETER_DEF); final DetailAST typeNode = paramNode.findFirstToken(TokenTypes.TYPE); final FullIdent fullIdent = FullIdent.createFullIdentBelow(typeNode); final String name = fullIdent.getText(); return "Object".equals(name) || "java.lang.Object".equals(name); }
/** * Returns import text. * @param ast ast node that represents import * @return String that represents importing class */ private static String getImportText(DetailAST ast) { final FullIdent imp; if (ast.getType() == TokenTypes.IMPORT) { imp = FullIdent.createFullIdentBelow(ast); } else { // know it is a static import imp = FullIdent.createFullIdent(ast .getFirstChild().getNextSibling()); } return imp.getText(); }
/** * Process type params (if any) for given class, enum or method. * @param ast class, enum or method to process. */ private void processTypeParams(DetailAST ast) { final DetailAST params = ast.findFirstToken(TokenTypes.TYPE_PARAMETERS); final Map<String, AbstractClassInfo> paramsMap = new HashMap<>(); typeParams.push(paramsMap); if (params != null) { for (DetailAST child = params.getFirstChild(); child != null; child = child.getNextSibling()) { if (child.getType() == TokenTypes.TYPE_PARAMETER) { final DetailAST bounds = child.findFirstToken(TokenTypes.TYPE_UPPER_BOUNDS); if (bounds != null) { final FullIdent name = FullIdent.createFullIdentBelow(bounds); final AbstractClassInfo classInfo = createClassInfo(new Token(name), currentClassName); final String alias = child.findFirstToken(TokenTypes.IDENT).getText(); paramsMap.put(alias, classInfo); } } } } }
final FullIdent imp = FullIdent.createFullIdentBelow(ast); if (isFromPackage(imp.getText(), "java.lang")) { log(ast, MSG_LANG, imp.getText());
@Override public void visitToken(DetailAST ast) { final FullIdent imp; if (ast.getType() == TokenTypes.IMPORT) { imp = FullIdent.createFullIdentBelow(ast); } else { imp = FullIdent.createFullIdent( ast.getFirstChild().getNextSibling()); } if (isIllegalImport(imp.getText())) { log(ast, MSG_KEY, imp.getText()); } }
ident = FullIdent.createFullIdentBelow(ast); isStatic = false;
@Override public void visitToken( DetailAST aAST ) { final FullIdent imp; if (aAST.getType() == TokenTypes.IMPORT) { imp = FullIdent.createFullIdentBelow(aAST); } else { // handle case of static imports of method names imp = FullIdent.createFullIdent(aAST.getFirstChild().getNextSibling()); } final String text = imp.getText(); if (isIllegalImport(text)) { final String message = buildError(text); log(aAST.getLineNo(), aAST.getColumnNo(), message, text); } }
/** * Perform processing for an import token. * @param ast the import token */ private void processImport(DetailAST ast) { final FullIdent name = FullIdent.createFullIdentBelow(ast); // Note: different from UnusedImportsCheck.processImport(), // '.*' imports are also added here imports.add(name); }
/** * Collects the details of imports. * @param ast node containing the import details */ private void processImport(DetailAST ast) { final FullIdent name = FullIdent.createFullIdentBelow(ast); imports.add(name.getText()); }
/** * Collects the details of imports. * @param ast node containing the import details */ private void processImport(DetailAST ast) { final FullIdent name = FullIdent.createFullIdentBelow(ast); if (!name.getText().endsWith(STAR_IMPORT_SUFFIX)) { imports.add(name); } }
/** * Collects the details of imports. * * @param aAST node containing the import details */ private void processImport( DetailAST aAST ) { final FullIdent name = FullIdent.createFullIdentBelow(aAST); if ((name != null) && !name.getText().endsWith(".*")) { imports.add(name); } }
/** * Determines if an AST is a formal param of type Object. * @param paramNode the AST to check * @return true if firstChild is a parameter of an Object type. */ private static boolean isObjectParam(DetailAST paramNode) { final DetailAST typeNode = paramNode.findFirstToken(TokenTypes.TYPE); final FullIdent fullIdent = FullIdent.createFullIdentBelow(typeNode); final String name = fullIdent.getText(); return "Object".equals(name) || "java.lang.Object".equals(name); }
private static String getParamTypeSimpleName(DetailAST paramNode) { DetailAST typeNode = paramNode.findFirstToken(TokenTypes.TYPE); return FullIdent.createFullIdentBelow(typeNode).getText(); }
@Override public void visitToken( DetailAST aAST ) { final FullIdent imp; if (aAST.getType() == TokenTypes.IMPORT) { imp = FullIdent.createFullIdentBelow(aAST); } else { // handle case of static imports of method names imp = FullIdent.createFullIdent(aAST.getFirstChild().getNextSibling()); } final String text = imp.getText(); if (isIllegalImport(text)) { final String message = buildError(text); log(aAST.getLineNo(), aAST.getColumnNo(), message, text); } }