use of com.sun.jdi.Type in project intellij-community by JetBrains.
the class CreateRendererAction method actionPerformed.
public void actionPerformed(@NotNull final AnActionEvent event) {
final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(event.getDataContext());
final List<JavaValue> values = ViewAsGroup.getSelectedValues(event);
if (values.size() != 1) {
return;
}
final JavaValue javaValue = values.get(0);
final DebugProcessImpl process = debuggerContext.getDebugProcess();
if (process == null) {
return;
}
final Project project = event.getProject();
process.getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) {
public void threadAction() {
Type type = javaValue.getDescriptor().getType();
final String name = type != null ? type.name() : null;
DebuggerUIUtil.invokeLater(() -> {
final UserRenderersConfigurable ui = new UserRenderersConfigurable();
ConfigurableBase<UserRenderersConfigurable, NodeRendererSettings> configurable = new ConfigurableBase<UserRenderersConfigurable, NodeRendererSettings>("reference.idesettings.debugger.typerenderers", DebuggerBundle.message("user.renderers.configurable.display.name"), "reference.idesettings.debugger.typerenderers") {
@NotNull
@Override
protected NodeRendererSettings getSettings() {
return NodeRendererSettings.getInstance();
}
@Override
protected UserRenderersConfigurable createUi() {
return ui;
}
};
SingleConfigurableEditor editor = new SingleConfigurableEditor(project, configurable);
if (name != null) {
NodeRenderer renderer = NodeRendererSettings.getInstance().createCompoundTypeRenderer(name, name, null, null);
renderer.setEnabled(true);
ui.addRenderer(renderer);
}
editor.show();
});
}
});
}
use of com.sun.jdi.Type in project che by eclipse.
the class Evaluator method findMethod.
private Method findMethod(List<Method> methods, List<Value> arguments) {
Method m = null;
for (Method mm : methods) {
List<Type> argumentTypes;
try {
argumentTypes = mm.argumentTypes();
} catch (ClassNotLoadedException e) {
continue;
}
ARGUMENT_MATCHING argumentMatching = argumentsMatching(argumentTypes, arguments);
if (argumentMatching == ARGUMENT_MATCHING.MATCH) {
m = mm;
break;
} else if (argumentMatching == ARGUMENT_MATCHING.ASSIGNABLE) {
if (m == null) {
m = mm;
} else {
throw new ExpressionException("Multiple methods with name " + mm.name() + " matched to specified arguments. ");
}
}
}
return m;
}
use of com.sun.jdi.Type in project che by eclipse.
the class Evaluator method argumentsMatching.
private ARGUMENT_MATCHING argumentsMatching(List<Type> argumentTypes, List<Value> arguments) {
if (argumentTypes.size() == arguments.size()) {
Iterator<Value> argumentIterator = arguments.iterator();
Iterator<Type> argumentTypesIterator = argumentTypes.iterator();
ARGUMENT_MATCHING result = ARGUMENT_MATCHING.MATCH;
while (argumentIterator.hasNext() && result != ARGUMENT_MATCHING.NOT_MATCH) {
Value argumentValue = argumentIterator.next();
Type argumentType = argumentTypesIterator.next();
if (argumentValue == null) {
if (isPrimitive(argumentType)) {
// Null may not be used as value if argument type is primitive.
result = ARGUMENT_MATCHING.NOT_MATCH;
}
} else {
if (!(argumentValue.type().equals(argumentType))) {
result = isAssignable(argumentValue.type(), argumentType) ? ARGUMENT_MATCHING.ASSIGNABLE : ARGUMENT_MATCHING.NOT_MATCH;
}
}
}
return result;
}
return ARGUMENT_MATCHING.NOT_MATCH;
}
use of com.sun.jdi.Type 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.Type 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;
}
Aggregations