/** * Notify checks that we are about to begin walking a tree. * @param rootAST the root of the tree. * @param contents the contents of the file the AST was generated from. * @param astState state of AST. */ private void notifyBegin(DetailAST rootAST, FileContents contents, AstState astState) { final Set<AbstractCheck> checks; if (astState == AstState.WITH_COMMENTS) { checks = commentChecks; } else { checks = ordinaryChecks; } for (AbstractCheck check : checks) { check.setFileContents(contents); check.clearMessages(); check.beginTree(rootAST); } }
@Test public void testGetLine() throws Exception { final AbstractCheck check = new AbstractCheck() { @Override public int[] getDefaultTokens() { return CommonUtil.EMPTY_INT_ARRAY; } @Override public int[] getAcceptableTokens() { return getDefaultTokens(); } @Override public int[] getRequiredTokens() { return getDefaultTokens(); } }; check.setFileContents(new FileContents(new FileText( new File(getPath("InputAbstractCheckTestFileContents.java")), Charset.defaultCharset().name()))); Assert.assertEquals("Invalid line content", " * I'm a javadoc", check.getLine(3)); }
/** * Notify checks that we are about to begin walking a tree. * @param rootAST the root of the tree. * @param contents the contents of the file the AST was generated from. * @param astState state of AST. */ private void notifyBegin(DetailAST rootAST, FileContents contents, AstState astState) { final Set<AbstractCheck> checks; if (astState == AstState.WITH_COMMENTS) { checks = commentChecks; } else { checks = ordinaryChecks; } for (AbstractCheck check : checks) { check.setFileContents(contents); check.clearMessages(); check.beginTree(rootAST); } }
@Override public void beginTree(DetailAST rootAST) { this.check.setFileContents(getFileContents()); this.check.clearMessages(); this.check.beginTree(rootAST); }