/** * Sets current package. * @param packageDef node for package definition */ private void visitPackageDef(DetailAST packageDef) { packageName = FullIdent.createFullIdent(packageDef.getLastChild() .getPreviousSibling()); }
/** * Perform processing for an package token. * @param ast the package token */ private void processPackageDef(DetailAST ast) { final DetailAST packageNameAST = ast.getLastChild() .getPreviousSibling(); final FullIdent packageIdent = FullIdent.createFullIdent(packageNameAST); pkgName = packageIdent.getText(); }
/** * Creates a new FullIdent starting from the child of the specified node. * @param ast the parent node from where to start from * @return a {@code FullIdent} value */ public static FullIdent createFullIdentBelow(DetailAST ast) { return createFullIdent(ast.getFirstChild()); }
/** * If not inner class then change current class name. * @param classDef node for class definition */ private void visitClassDef(DetailAST classDef) { // we are not use inner classes because they can not // have static methods if (classDepth == 0) { final DetailAST ident = classDef.findFirstToken(TokenTypes.IDENT); currentClass = packageName.getText() + "." + ident.getText(); classDepth++; } }
/** * Creates {@code FullIdent} for given type node. * @param typeAST a type node. * @return {@code FullIdent} for given type. */ public static FullIdent createFullType(final DetailAST typeAST) { DetailAST ast = typeAST; // ignore array part of type while (ast.findFirstToken(TokenTypes.ARRAY_DECLARATOR) != null) { ast = ast.findFirstToken(TokenTypes.ARRAY_DECLARATOR); } return FullIdent.createFullIdent(ast.getFirstChild()); }
/** * Forms import full path. * @param token * current token. * @return full path or null. */ private static String getFullImportIdent(DetailAST token) { String ident = ""; if (token != null) { ident = FullIdent.createFullIdent(token.findFirstToken(TokenTypes.DOT)).getText(); } return ident; }
/** * Extracts the name of an ast. * @param ast to extract the name * @return the text content of the inner {@code TokenTypes.IDENT} node */ private static String getName(DetailAST ast) { return ast.findFirstToken(TokenTypes.IDENT).getText(); }
@Override public void visitToken(DetailAST ast) { final FileContents contents = getFileContents(); final int lineNo = ast.getLineNo(); final TextBlock cmt = contents.getJavadocBefore(lineNo); if (cmt == null) { log(lineNo, MSG_MISSING_TAG, tag); } else { checkTag(lineNo, cmt.getText()); } }
/** * Checks whether a methods is native. * @param ast method definition token. * @return true if a methods is native. */ private static boolean isNativeMethod(DetailAST ast) { final DetailAST mods = ast.findFirstToken(TokenTypes.MODIFIERS); return mods.findFirstToken(TokenTypes.LITERAL_NATIVE) != null; }
/** * Register custom types of JDK like URI and Checkstyle specific classes to use with BeanUtils. * None of these types should be found in the {@code java.lang} package. * @param cub * Instance of {@link ConvertUtilsBean} to register types with. */ private static void registerCustomTypes(ConvertUtilsBean cub) { cub.register(new PatternConverter(), Pattern.class); cub.register(new SeverityLevelConverter(), SeverityLevel.class); cub.register(new ScopeConverter(), Scope.class); cub.register(new UriConverter(), URI.class); cub.register(new RelaxedAccessModifierArrayConverter(), AccessModifier[].class); }
/** Notify all listeners about the audit end. */ private void fireAuditFinished() { final AuditEvent event = new AuditEvent(this); for (final AuditListener listener : listeners) { listener.auditFinished(event); } }
/** Notify all listeners about the audit start. */ private void fireAuditStarted() { final AuditEvent event = new AuditEvent(this); for (final AuditListener listener : listeners) { listener.auditStarted(event); } }
/** * Returns an unmodifiable map instance containing the custom messages * for this configuration. * @return unmodifiable map containing custom messages */ protected Map<String, String> getCustomMessages() { return getConfiguration().getMessages(); }
@Override public void reportSingleLineComment(String type, int startLineNo, int startColNo) { reportSingleLineComment(startLineNo, startColNo); }
/** * Return the message associated to the event. * @return the event message */ public String getMessage() { return localizedMessage.getMessage(); }
/** * Gets the audit event severity level. * @return the audit event severity level */ public SeverityLevel getSeverityLevel() { SeverityLevel severityLevel = SeverityLevel.INFO; if (localizedMessage != null) { severityLevel = localizedMessage.getSeverityLevel(); } return severityLevel; }
/** * Adds a before execution file filter to the end of the event chain. * @param filter the additional filter */ public void addBeforeExecutionFileFilter(BeforeExecutionFileFilter filter) { beforeExecutionFileFilters.addBeforeExecutionFileFilter(filter); }
/** * Returns package text. * @param ast PACKAGE_DEF ast node * @return String that represents full package name */ private static String getPackageText(DetailAST ast) { final DetailAST nameAST = ast.getLastChild().getPreviousSibling(); return FullIdent.createFullIdent(nameAST).getText(); }
/** * Collects the details of a package. * @param ast node containing the package details */ private void processPackage(DetailAST ast) { final DetailAST nameAST = ast.getLastChild().getPreviousSibling(); packageFullIdent = FullIdent.createFullIdent(nameAST); }