private Set<Type> interfacesWithSubstitution(Symbol.TypeSymbol symbol, TypeSubstitution substitution) { return symbol.interfaces().stream() .flatMap(interfaceType -> supertypes(applySubstitution(interfaceType, substitution)).stream()) .collect(Collectors.toSet()); }
private Set<Type> interfacesWithSubstitution(Symbol.TypeSymbol symbol, TypeSubstitution substitution) { return symbol.interfaces().stream() .flatMap(interfaceType -> supertypes(applySubstitution(interfaceType, substitution)).stream()) .collect(Collectors.toSet()); }
private static boolean noAbstractMethodInParentInterfaces(List<Type> interfaces) { return interfaces.stream() .map(Type::symbol) .noneMatch(symbol -> numberOfAbstractMethod(symbol) > 0 || !noAbstractMethodInParentInterfaces(symbol.interfaces())); }
private static boolean hasOneAbstractMethod(Symbol.TypeSymbol symbol) { return numberOfAbstractMethod(symbol) == 1 && noAbstractMethodInParentInterfaces(symbol.interfaces()); }
private static boolean noAbstractMethodInParentInterfaces(List<Type> interfaces) { return interfaces.stream() .map(Type::symbol) .noneMatch(symbol -> numberOfAbstractMethod(symbol) > 0 || !noAbstractMethodInParentInterfaces(symbol.interfaces())); }
@Override public void visitNode(Tree tree) { ClassTree classTree = (ClassTree) tree; if (hasSemantic()) { Symbol.TypeSymbol classSymbol = classTree.symbol(); checkSuperType(classTree, classSymbol.superClass()); for (Type interfaceType : classSymbol.interfaces()) { checkSuperType(classTree, interfaceType); } } }
private static boolean superTypesHaveOnlyStaticMethods(Symbol.TypeSymbol newClassTypeSymbol) { Type superClass = newClassTypeSymbol.superClass(); if (superClass != null && !superClass.is("java.lang.Object") && !hasOnlyStaticMethodsAndFields(superClass.symbol())) { return false; } for (Type superInterface : newClassTypeSymbol.interfaces()) { if (!hasOnlyStaticMethodsAndFields(superInterface.symbol())) { return false; } } return true; }
private static String getAnonymousClassTypeName(Symbol.TypeSymbol symbol) { if (symbol.interfaces().isEmpty()) { return getTypeName(symbol.superClass()); } return getTypeName(symbol.interfaces().get(0)); }
private boolean checkInterfaces(String type, Symbol.TypeSymbol symbol) { for (Type interfaceType : symbol.interfaces()) { if (type.equals(interfaceType.fullyQualifiedName()) || checkInterfaces(type, interfaceType.symbol())) { return true; } } return false; }
private boolean directlyImplementsSerializable(Symbol.TypeSymbol symbol) { for (org.sonar.plugins.java.api.semantic.Type type : symbol.interfaces()) { if (type.is("java.io.Serializable")) { return true; } } return false; }
private static boolean isComparable(ClassTree tree) { for (Type type : tree.symbol().interfaces()) { if (type.is("java.lang.Comparable")) { return true; } } return false; }
private boolean isComparable(ClassTree tree) { for (Type type : tree.symbol().interfaces()) { if (type.is("java.lang.Comparable")) { return true; } } return false; }
@Override public void visitNode(Tree tree) { ClassTree classTree = (ClassTree) tree; if (hasSemantic()) { Symbol.TypeSymbol classSymbol = classTree.symbol(); checkSuperType(classTree, classSymbol.superClass()); for (Type interfaceType : classSymbol.interfaces()) { checkSuperType(classTree, interfaceType); } } }
private String getAnonymousClassTypeName(Symbol.TypeSymbol symbol) { String name = ""; if (symbol.interfaces().isEmpty()) { name = getTypeName(symbol.superClass()); } else { name = getTypeName(symbol.interfaces().get(0)); } return name; }
@Override public void visitNode(Tree tree) { ClassTree classTree = (ClassTree) tree; if (hasSemantic()) { Symbol.TypeSymbol classSymbol = classTree.symbol(); checkSuperType(classTree, classSymbol.superClass()); for (Type interfaceType : classSymbol.interfaces()) { checkSuperType(classTree, interfaceType); } } }
private static List<Symbol> retrieveMembers(Symbol.TypeSymbol classSymbol) { List<Symbol> results = Lists.newLinkedList(); results.addAll(extractMembers(classSymbol, false)); for (Type parentInterface : classSymbol.interfaces()) { results.addAll(extractMembers(parentInterface.symbol(), true)); } Type superClass = classSymbol.superClass(); if (superClass != null) { results.addAll(extractMembers(superClass.symbol(), true)); } return results; }
private static String getAnonymousClassTypeName(Symbol.TypeSymbol symbol) { if (symbol.interfaces().isEmpty()) { return getTypeName(symbol.superClass()); } return getTypeName(symbol.interfaces().get(0)); }
private static boolean isComparable(ClassTree tree) { for (Type type : tree.symbol().interfaces()) { if (type.is("java.lang.Comparable")) { return true; } } return false; }
private static List<Symbol> retrieveMembers(Symbol.TypeSymbol classSymbol) { List<Symbol> results = Lists.newLinkedList(); results.addAll(extractMembers(classSymbol, false)); for (Type parentInterface : classSymbol.interfaces()) { results.addAll(extractMembers(parentInterface.symbol(), true)); } Type superClass = classSymbol.superClass(); if (superClass != null) { results.addAll(extractMembers(superClass.symbol(), true)); } return results; }
private static boolean superTypesHaveOnlyStaticMethods(Symbol.TypeSymbol newClassTypeSymbol) { Type superClass = newClassTypeSymbol.superClass(); if (superClass != null && !superClass.is("java.lang.Object") && !hasOnlyStaticMethodsAndFields(superClass.symbol())) { return false; } for (Type superInterface : newClassTypeSymbol.interfaces()) { if (!hasOnlyStaticMethodsAndFields(superInterface.symbol())) { return false; } } return true; }