private static void handleNewClass(Set<Symbol> out, Symbol.MethodSymbol methodSymbol, NewClassTree element) { ClassTree body = element.classBody(); if (body != null) { out.addAll(getUsedLocalVarInSubTree(body, methodSymbol)); } }
private static void handleNewClass(Set<Symbol> out, Symbol.MethodSymbol methodSymbol, NewClassTree element) { ClassTree body = element.classBody(); if (body != null) { out.addAll(getUsedLocalVarInSubTree(body, methodSymbol)); } }
private static boolean isAnonymousClass(ExpressionTree initializeTree) { return initializeTree.is(Tree.Kind.NEW_CLASS) && ((NewClassTree) initializeTree).classBody() != null; }
@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 visitNewClass(NewClassTree tree) { super.visitNewClass(tree); if (tree.classBody() != null) { List<Tree> members = tree.classBody().members(); if (!useThisIdentifier(tree.classBody()) && !enumConstants.contains(tree.identifier()) && members.size() == 1 && members.get(0).is(Tree.Kind.METHOD)) { context.addIssue(tree.identifier(), this, "Make this anonymous inner class a lambda"); } } }
@Override public void visitNode(Tree tree) { ClassTree classBody = ((NewClassTree) tree).classBody(); if (classBody != null) { List<Tree> members = classBody.members(); if (members.size() == 1 && members.get(0).is(Tree.Kind.INITIALIZER)) { reportIssue(classBody, "Use another way to initialize this instance."); } } }
@Override public void visitEnumConstant(EnumConstantTree tree) { scan(tree.initializer().classBody()); }
@Override public void visitNode(Tree tree) { ClassTree classBody = ((NewClassTree) tree).classBody(); if (classBody != null) { List<Tree> members = classBody.members(); if (members.size() == 1 && members.get(0).is(Tree.Kind.INITIALIZER)) { reportIssue(classBody, "Use another way to initialize this instance."); } } }
@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); }
@Override public void visitNewClass(NewClassTree tree) { if (tree.classBody() != null && tree.symbolType().isSubtypeOf(type)) { isExtended = true; } super.visitNewClass(tree); } }
@Override public void visitNewClass(NewClassTree tree) { if (tree.classBody() != null && tree.symbolType().isSubtypeOf(type)) { isExtended = true; } super.visitNewClass(tree); } }
@Override public void visitNewClass(NewClassTree tree) { super.visitNewClass(tree); ClassTree classBody = tree.classBody(); if (classBody != null) { TypeTree identifier = tree.identifier(); if (!useThisInstance(classBody) && !enumConstants.contains(identifier) && isSAM(classBody)) { context.reportIssue(this, identifier, "Make this anonymous inner class a lambda" + context.getJavaVersion().java8CompatibilityMessage()); } } }
@Override public void visitNewClass(NewClassTree tree) { super.visitNewClass(tree); ClassTree classBody = tree.classBody(); if (classBody != null) { TypeTree identifier = tree.identifier(); if (!useThisInstance(classBody) && !enumConstants.contains(identifier) && isSAM(classBody)) { context.reportIssue(this, identifier, "Make this anonymous inner class a lambda" + context.getJavaVersion().java8CompatibilityMessage()); } } }
@Override public void visitNewClass(NewClassTree tree) { ClassTree classBody = tree.classBody(); if (classBody != null && tree.arguments().closeParenToken() != null) { checkTokens(tree.arguments().closeParenToken(), classBody.openBraceToken()); } super.visitNewClass(tree); }
@Override public void visitNewClass(NewClassTree tree) { ClassTree classBody = tree.classBody(); if (classBody != null && tree.arguments().closeParenToken() != null) { checkTokens(tree.arguments().closeParenToken(), classBody.openBraceToken()); } super.visitNewClass(tree); }
@Override public void visitNewClass(NewClassTree tree) { scan(tree.enclosingExpression()); scan(tree.identifier()); scan(tree.typeArguments()); scan(tree.arguments()); scan(tree.classBody()); }
@Override public void visitNewClass(NewClassTree tree) { scan(tree.enclosingExpression()); scan(tree.identifier()); scan(tree.typeArguments()); scan(tree.arguments()); scan(tree.classBody()); }
@Override public void visitNewClass(NewClassTree tree) { scan(tree.enclosingExpression()); scan(tree.identifier()); scan(tree.typeArguments()); scan(tree.arguments()); scan(tree.classBody()); }
@Override public void visitNewClass(NewClassTree tree) { scan(tree.enclosingExpression()); scan(tree.identifier()); scan(tree.typeArguments()); scan(tree.arguments()); scan(tree.classBody()); }