public static String getclassName(NewClassTree newClasstree) {
   if (newClasstree.identifier().is(Tree.Kind.MEMBER_SELECT)) {
     return ((MemberSelectExpressionTree) newClasstree.identifier()).identifier().name();
   } else if (newClasstree.identifier().is(Tree.Kind.IDENTIFIER)) {
     return ((IdentifierTree) newClasstree.identifier()).name();
   }
   return null;
 }
Ejemplo n.º 2
0
 @Override
 public void visitNode(Tree tree) {
   NewClassTree newClassTree = (NewClassTree) tree;
   TypeTree newTypeTree = newClassTree.identifier();
   if (newClassTree.classBody() == null && isParameterizedType(newTypeTree)) {
     TypeTree type = getTypeFromExpression(tree.parent());
     if (type != null && isParameterizedType(type)) {
       reportIssue(
           ((ParameterizedTypeTree) newTypeTree).typeArguments(),
           "Replace the type specification in this constructor call with the diamond operator (\"<>\")."
               + JavaVersionHelper.java7CompatibilityMessage(context.getJavaVersion()));
     }
   }
 }