1616 */
1717package org .sonar .java .model ;
1818
19- import java .util .Arrays ;
2019import java .util .Collections ;
2120import java .util .HashSet ;
2221import java .util .LinkedHashSet ;
2625import java .util .Set ;
2726import java .util .stream .Collectors ;
2827import javax .annotation .Nullable ;
29- import org .eclipse .jdt .core .dom .ITypeBinding ;
3028import org .sonar .plugins .java .api .semantic .Symbol ;
3129import org .sonar .plugins .java .api .semantic .SymbolMetadata ;
3230import org .sonar .plugins .java .api .semantic .Type ;
@@ -67,19 +65,7 @@ public static Type wrapTypeIfPrimitive(Type type) {
6765 }
6866
6967 public static boolean isIntersectionType (Type type ) {
70- return !type .isUnknown () && ((JType ) type ).typeBinding .isIntersectionType ();
71- }
72-
73- public static void collectSuperTypes (Set <Type > result , JSema sema , ITypeBinding typeBinding ) {
74- ITypeBinding s = typeBinding .getSuperclass ();
75- if (s != null ) {
76- result .add (sema .type (s ));
77- collectSuperTypes (result , sema , s );
78- }
79- Arrays .stream (typeBinding .getInterfaces ()).forEach (i -> {
80- result .add (sema .type (i ));
81- collectSuperTypes (result , sema , i );
82- });
68+ return !type .isUnknown () && type .isIntersectionType ();
8369 }
8470
8571 public static Symbol getPackage (Symbol symbol ) {
@@ -94,7 +80,7 @@ public static Object defaultValue(Symbol.MethodSymbol method) {
9480 if (method .isUnknown ()) {
9581 return null ;
9682 }
97- return (( JMethodSymbol ) method ). methodBinding (). getDefaultValue ();
83+ return method . defaultValue ();
9884 }
9985
10086 /**
@@ -161,16 +147,7 @@ public static Set<Type> directSuperTypes(Type type) {
161147 if (type .isUnknown ()) {
162148 return Collections .emptySet ();
163149 }
164- Set <Type > result = new HashSet <>();
165- JType t = (JType ) type ;
166- ITypeBinding superclass = t .typeBinding .getSuperclass ();
167- if (superclass != null ) {
168- result .add (t .sema .type (superclass ));
169- }
170- Arrays .stream (t .typeBinding .getInterfaces ())
171- .map (t .sema ::type )
172- .forEach (result ::add );
173- return result ;
150+ return type .directSuperTypes ();
174151 }
175152
176153 @ Nullable
0 commit comments