use of com.sun.jdi.InterfaceType in project che by eclipse.
the class Evaluator method isAssignable.
private boolean isAssignable(Type from, Type to) {
if (from.equals(to)) {
return true;
}
if (from instanceof BooleanType) {
return to instanceof BooleanType;
}
if (to instanceof BooleanType) {
return false;
}
if (from instanceof PrimitiveType) {
return to instanceof PrimitiveType;
}
if (to instanceof PrimitiveType) {
return false;
}
if (from instanceof ArrayType) {
if (to instanceof ArrayType) {
Type fromArrayComponent;
Type toArrayComponent;
try {
fromArrayComponent = ((ArrayType) from).componentType();
toArrayComponent = ((ArrayType) to).componentType();
} catch (ClassNotLoadedException e) {
return false;
}
if (fromArrayComponent instanceof PrimitiveType) {
return fromArrayComponent.equals(toArrayComponent);
}
return !(toArrayComponent instanceof PrimitiveType) && isAssignable(fromArrayComponent, toArrayComponent);
}
return to.name().equals("java.lang.Object");
}
if (from instanceof ClassType) {
ClassType superClass = ((ClassType) from).superclass();
if (superClass != null && isAssignable(superClass, to)) {
return true;
}
for (InterfaceType interfaceType : ((ClassType) from).interfaces()) {
if (isAssignable(interfaceType, to)) {
return true;
}
}
}
for (InterfaceType interfaceType : ((InterfaceType) from).subinterfaces()) {
if (isAssignable(interfaceType, to)) {
return true;
}
}
return false;
}
use of com.sun.jdi.InterfaceType in project intellij-community by JetBrains.
the class RuntimeTypeEvaluator method getCastableRuntimeType.
@Nullable
public static PsiType getCastableRuntimeType(Project project, Value value) {
Type type = value.type();
PsiType psiType = findPsiType(project, type);
if (psiType != null) {
return psiType;
}
if (type instanceof ClassType) {
ClassType superclass = ((ClassType) type).superclass();
if (superclass != null && !CommonClassNames.JAVA_LANG_OBJECT.equals(superclass.name())) {
psiType = findPsiType(project, superclass);
if (psiType != null) {
return psiType;
}
}
for (InterfaceType interfaceType : ((ClassType) type).interfaces()) {
psiType = findPsiType(project, interfaceType);
if (psiType != null) {
return psiType;
}
}
}
return null;
}
use of com.sun.jdi.InterfaceType in project jdk8u_jdk by JetBrains.
the class InvokableTypeImpl method allMethods.
/**
* Shared implementation of {@linkplain ClassType#allMethods()} and
* {@linkplain InterfaceType#allMethods()}
* @return A list of all methods (recursively)
*/
public final List<Method> allMethods() {
ArrayList<Method> list = new ArrayList<>(methods());
ClassType clazz = superclass();
while (clazz != null) {
list.addAll(clazz.methods());
clazz = clazz.superclass();
}
/*
* Avoid duplicate checking on each method by iterating through
* duplicate-free allInterfaces() rather than recursing
*/
for (InterfaceType interfaze : getAllInterfaces()) {
list.addAll(interfaze.methods());
}
return list;
}
Aggregations