@Override public void scanFile(JavaFileScannerContext context) { this.context = context; isEnumConstantBody = false; scan(context.getTree()); }
@Override public void visitNewClass(NewClassTree tree) { if (tree.classBody() != null && !isEnumConstantBody) { int lines = getNumberOfLines(tree.classBody()); if (lines > max) { context.addIssue(tree, this, "Reduce this anonymous class number of lines from " + lines + " to at most " + max + ", or make it a named class."); } } isEnumConstantBody = false; super.visitNewClass(tree); }
@Override public void visitLambdaExpression(LambdaExpressionTree lambdaExpressionTree) { int lines = getNumberOfLines(((JavaTree) lambdaExpressionTree.body()).getAstNode()); if (lines > max) { context.addIssue(lambdaExpressionTree, this, "Reduce this lambda expression number of lines from " + lines + " to at most " + max + "."); } super.visitLambdaExpression(lambdaExpressionTree); }
@Override public void visitLambdaExpression(LambdaExpressionTree lambdaExpressionTree) { int lines = getNumberOfLines(lambdaExpressionTree); if (lines > max) { SyntaxToken firstToken = lambdaExpressionTree.firstToken(); SyntaxToken lastSyntaxToken = lambdaExpressionTree.lastToken(); JavaFileScannerContext.Location lastTokenLocation = new JavaFileScannerContext.Location(lines + " lines", lastSyntaxToken); context.reportIssue(this, firstToken, lambdaExpressionTree.arrowToken(), "Reduce this lambda expression number of lines from " + lines + " to at most " + max + ".", Lists.newArrayList(lastTokenLocation), null); } super.visitLambdaExpression(lambdaExpressionTree); }
@Override public void scanFile(JavaFileScannerContext context) { this.context = context; isEnumConstantBody = false; scan(context.getTree()); }
@Override public void visitLambdaExpression(LambdaExpressionTree lambdaExpressionTree) { int lines = getNumberOfLines(lambdaExpressionTree); if (lines > max) { SyntaxToken firstToken = lambdaExpressionTree.firstToken(); SyntaxToken lastSyntaxToken = lambdaExpressionTree.lastToken(); JavaFileScannerContext.Location lastTokenLocation = new JavaFileScannerContext.Location(lines + " lines", lastSyntaxToken); context.reportIssue(this, firstToken, lambdaExpressionTree.arrowToken(), "Reduce this lambda expression number of lines from " + lines + " to at most " + max + ".", Lists.newArrayList(lastTokenLocation), null); } super.visitLambdaExpression(lambdaExpressionTree); }
@Override public void scanFile(JavaFileScannerContext context) { this.context = context; isEnumConstantBody = false; scan(context.getTree()); }
@Override public void visitNewClass(NewClassTree tree) { if (tree.classBody() != null && !isEnumConstantBody) { int lines = getNumberOfLines(tree.classBody()); if (lines > max) { context.reportIssue(this, tree.newKeyword(), tree.identifier(), "Reduce this anonymous class number of lines from " + lines + " to at most " + max + ", or make it a named class."); } } isEnumConstantBody = false; super.visitNewClass(tree); }
@Override public void visitNewClass(NewClassTree tree) { if (tree.classBody() != null && !isEnumConstantBody) { int lines = getNumberOfLines(tree.classBody()); if (lines > max) { context.reportIssue(this, tree.newKeyword(), tree.identifier(), "Reduce this anonymous class number of lines from " + lines + " to at most " + max + ", or make it a named class."); } } isEnumConstantBody = false; super.visitNewClass(tree); }