/** * {@inheritDoc} */ @Override public void visitNode(AstNode astNode) { getContext().addSourceCode(callback.createSourceCode(getContext().peekSourceCode(), astNode)); }
@Override public AstScanner<G> build() { super.withSquidAstVisitor(new SquidAstVisitor<G>() { @Override public void leaveFile(@Nullable AstNode astNode) { progressReport.nextFile(); } }); return new ProgressAstScanner<G>(this); }
/** * {@inheritDoc} */ @Override public void leaveNode(AstNode astNode) { getContext().popSourceCode(); }
@Override public void visitFile(AstNode astNode) { SourceFile sourceFile = createSourceFile(getContext().getFile()); getContext().addSourceCode(sourceFile); }
/** * {@inheritDoc} */ @Override public void createLineViolation(CodeCheck check, String message, int line, Object... messageParameters) { CheckMessage checkMessage = new CheckMessage((Object) check, message, messageParameters); if (line > 0) { checkMessage.setLine(line); } log(checkMessage); }
@Override public AstScanner<Grammar> build() { super.withSquidAstVisitor(new SquidAstVisitor<Grammar>() { @Override public void visitFile(@Nullable AstNode astNode) { progressReport.nextFile(getContext().getFile()); } }); return new ProgressAstScanner(this); }
@Override public void visitNode(AstNode node) { if (hasStringLiteralOperand(node)) { getContext().createLineViolation( this, "Replace \"==\" and \"!=\" by \"equals()\" and \"!equals()\" respectively to compare these strings.", node); } }
public void processRecognitionException(RecognitionException e) { for (JavaFileScanner scanner : scanners) { if (scanner instanceof AstScannerExceptionHandler) { ((AstScannerExceptionHandler) scanner).processRecognitionException(e); } } }
protected void popTillSourceProject() { while (!(peekSourceCode() instanceof SourceProject)) { popSourceCode(); } }
/** * {@inheritDoc} */ @Override public void createFileViolation(CodeCheck check, String message, Object... messageParameters) { createLineViolation(check, message, -1, messageParameters); }
@Override public void init() { for (AstNodeType astNodeType : astNodeTypes) { subscribeTo(astNodeType); } }
public static <G extends Grammar> Builder<G> builder(SquidAstVisitorContextImpl<G> context) { return new Builder<G>(context); }
@Override public AstScanner<LexerlessGrammar> build() { super.withSquidAstVisitor(new SquidAstVisitor<LexerlessGrammar>() { @Override public void visitFile(@Nullable AstNode astNode) { progressReport.nextFile(getContext().getFile()); } }); return new ProgressAstScanner(this); }
@Override public void visitNode(AstNode astNode) { if (isConditionABooleanLiteral(astNode)) { getContext().createLineViolation(this, "Remove this \"if\" statement.", astNode); } }
@Override public void visitNode(AstNode astNode) { if (!isElseIf(astNode)) { nestingLevel++; if (nestingLevel == getMax() + 1) { getContext().createLineViolation(this, "Refactor this code to not nest more than {0} if/for/while/switch statements.", astNode, getMax()); } } }