@Override public int[] getDefaultTokens() { return getRequiredTokens(); }
@Test public void testTokensNotNull() { final IllegalThrowsCheck check = new IllegalThrowsCheck(); Assert.assertNotNull("Acceptable tokens should not be null", check.getAcceptableTokens()); Assert.assertNotNull("Default tokens should not be null", check.getDefaultTokens()); Assert.assertNotNull("Required tokens should not be null", check.getRequiredTokens()); }
@Override public void visitToken(DetailAST detailAST) { final DetailAST methodDef = detailAST.getParent(); // Check if the method with the given name should be ignored. if (!isIgnorableMethod(methodDef)) { DetailAST token = detailAST.getFirstChild(); while (token != null) { if (token.getType() != TokenTypes.COMMA) { final FullIdent ident = FullIdent.createFullIdent(token); if (illegalClassNames.contains(ident.getText())) { log(token, MSG_KEY, ident.getText()); } } token = token.getNextSibling(); } } }
/** * Checks if current method is ignorable due to Check's properties. * @param methodDef {@link TokenTypes#METHOD_DEF METHOD_DEF} * @return true if method is ignorable. */ private boolean isIgnorableMethod(DetailAST methodDef) { return shouldIgnoreMethod(methodDef.findFirstToken(TokenTypes.IDENT).getText()) || ignoreOverriddenMethods && (AnnotationUtil.containsAnnotation(methodDef, "Override") || AnnotationUtil.containsAnnotation(methodDef, "java.lang.Override")); }
@Override public void visitToken(DetailAST detailAST) { final DetailAST methodDef = detailAST.getParent(); // Check if the method with the given name should be ignored. if (!isIgnorableMethod(methodDef)) { DetailAST token = detailAST.getFirstChild(); while (token != null) { if (token.getType() != TokenTypes.COMMA) { final FullIdent ident = FullIdent.createFullIdent(token); if (illegalClassNames.contains(ident.getText())) { log(token, MSG_KEY, ident.getText()); } } token = token.getNextSibling(); } } }
/** * Checks if current method is ignorable due to Check's properties. * @param methodDef {@link TokenTypes#METHOD_DEF METHOD_DEF} * @return true if method is ignorable. */ private boolean isIgnorableMethod(DetailAST methodDef) { return shouldIgnoreMethod(methodDef.findFirstToken(TokenTypes.IDENT).getText()) || ignoreOverriddenMethods && (AnnotationUtil.containsAnnotation(methodDef, "Override") || AnnotationUtil.containsAnnotation(methodDef, "java.lang.Override")); }
@Override public int[] getAcceptableTokens() { return getRequiredTokens(); }
@Override public int[] getDefaultTokens() { return getRequiredTokens(); }
@Override public int[] getAcceptableTokens() { return getRequiredTokens(); }