use of com.intellij.debugger.engine.JavaValue in project intellij-community by JetBrains.
the class FieldDescriptorImpl method getModifier.
@Override
public XValueModifier getModifier(JavaValue value) {
return new JavaValueModifier(value) {
@Override
protected void setValueImpl(@NotNull String expression, @NotNull XModificationCallback callback) {
final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(getProject()).getContext();
FieldDescriptorImpl fieldDescriptor = FieldDescriptorImpl.this;
final Field field = fieldDescriptor.getField();
if (!field.isStatic()) {
final ObjectReference object = fieldDescriptor.getObject();
if (object != null) {
set(expression, callback, debuggerContext, new SetValueRunnable() {
public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException, InvalidTypeException, EvaluateException {
object.setValue(field, preprocessValue(evaluationContext, newValue, field.type()));
update(debuggerContext);
}
public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException, ClassNotLoadedException, IncompatibleThreadStateException, InvalidTypeException, EvaluateException {
return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, field.declaringType().classLoader());
}
});
}
} else {
// field is static
ReferenceType refType = field.declaringType();
if (refType instanceof ClassType) {
final ClassType classType = (ClassType) refType;
set(expression, callback, debuggerContext, new SetValueRunnable() {
public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException, InvalidTypeException, EvaluateException {
classType.setValue(field, preprocessValue(evaluationContext, newValue, field.type()));
update(debuggerContext);
}
public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException, ClassNotLoadedException, IncompatibleThreadStateException, InvalidTypeException, EvaluateException {
return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, field.declaringType().classLoader());
}
});
}
}
}
};
}
use of com.intellij.debugger.engine.JavaValue in project intellij-community by JetBrains.
the class ArrayElementDescriptorImpl method getModifier.
@Override
public XValueModifier getModifier(JavaValue value) {
return new JavaValueModifier(value) {
@Override
protected void setValueImpl(@NotNull String expression, @NotNull XModificationCallback callback) {
final ArrayElementDescriptorImpl elementDescriptor = ArrayElementDescriptorImpl.this;
final ArrayReference array = elementDescriptor.getArray();
if (array != null) {
if (VirtualMachineProxyImpl.isCollected(array)) {
// will only be the case if debugger does not use ObjectReference.disableCollection() because of Patches.IBM_JDK_DISABLE_COLLECTION_BUG
Messages.showWarningDialog(getProject(), DebuggerBundle.message("evaluation.error.array.collected") + "\n" + DebuggerBundle.message("warning.recalculate"), DebuggerBundle.message("title.set.value"));
//node.getParent().calcValue();
return;
}
final ArrayType arrType = (ArrayType) array.referenceType();
final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(getProject()).getContext();
set(expression, callback, debuggerContext, new SetValueRunnable() {
public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException, InvalidTypeException, EvaluateException {
array.setValue(elementDescriptor.getIndex(), preprocessValue(evaluationContext, newValue, arrType.componentType()));
update(debuggerContext);
}
public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException, ClassNotLoadedException, IncompatibleThreadStateException, InvalidTypeException, EvaluateException {
return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, arrType.classLoader());
}
});
}
}
};
}
use of com.intellij.debugger.engine.JavaValue in project intellij-community by JetBrains.
the class CustomFieldInplaceEditor method editNew.
public static void editNew(@NotNull XValueNodeImpl parentNode) {
ValueDescriptorImpl descriptor = ((JavaValue) parentNode.getValueContainer()).getDescriptor();
EnumerationChildrenRenderer renderer = EnumerationChildrenRenderer.getCurrent(descriptor);
XDebuggerTreeNode newNode = parentNode.addTemporaryEditorNode();
DebuggerUIUtil.invokeLater(() -> new CustomFieldInplaceEditor(newNode, null, renderer) {
@Override
public void cancelEditing() {
super.cancelEditing();
parentNode.removeTemporaryEditorNode(newNode);
}
@Override
protected List<Pair<String, TextWithImports>> getRendererChildren() {
if (myRenderer != null) {
return myRenderer.getChildren();
}
String name = getTypeName(descriptor);
EnumerationChildrenRenderer enumerationChildrenRenderer = new EnumerationChildrenRenderer();
enumerationChildrenRenderer.setAppendDefaultChildren(true);
Renderer lastRenderer = descriptor.getLastRenderer();
if (lastRenderer instanceof CompoundNodeRenderer && NodeRendererSettings.getInstance().getCustomRenderers().contains((NodeRenderer) lastRenderer) && !(((CompoundNodeRenderer) lastRenderer).getChildrenRenderer() instanceof ExpressionChildrenRenderer)) {
((CompoundNodeRenderer) lastRenderer).setChildrenRenderer(enumerationChildrenRenderer);
} else {
NodeRenderer renderer = NodeRendererSettings.getInstance().createCompoundTypeRenderer(name, name, null, enumerationChildrenRenderer);
renderer.setEnabled(true);
NodeRendererSettings.getInstance().getCustomRenderers().addRenderer(renderer);
NodeRendererSettings.getInstance().fireRenderersChanged();
}
return enumerationChildrenRenderer.getChildren();
}
}.show());
}
use of com.intellij.debugger.engine.JavaValue in project intellij-community by JetBrains.
the class EditCustomFieldAction method perform.
@Override
protected void perform(XValueNodeImpl node, @NotNull String nodeName, AnActionEvent e) {
ValueDescriptorImpl descriptor = ((JavaValue) node.getValueContainer()).getDescriptor();
EnumerationChildrenRenderer enumerationChildrenRenderer = getParentEnumerationRenderer(descriptor);
if (enumerationChildrenRenderer != null) {
new CustomFieldInplaceEditor(node, (UserExpressionDescriptorImpl) descriptor, enumerationChildrenRenderer).show();
}
}
use of com.intellij.debugger.engine.JavaValue in project intellij-community by JetBrains.
the class ViewAsGroup method calcChildren.
private static AnAction[] calcChildren(List<JavaValue> values) {
List<AnAction> renderers = new ArrayList<>();
List<NodeRenderer> allRenderers = NodeRendererSettings.getInstance().getAllRenderers();
boolean anyValueDescriptor = false;
for (NodeRenderer nodeRenderer : allRenderers) {
boolean allApp = true;
for (JavaValue value : values) {
if (value instanceof JavaReferringObjectsValue) {
// disable for any referrers at all
return AnAction.EMPTY_ARRAY;
}
ValueDescriptorImpl valueDescriptor = value.getDescriptor();
anyValueDescriptor = true;
if (!valueDescriptor.isValueValid() || !nodeRenderer.isApplicable(valueDescriptor.getType())) {
allApp = false;
break;
}
}
if (!anyValueDescriptor) {
return AnAction.EMPTY_ARRAY;
}
if (allApp) {
renderers.add(new RendererAction(nodeRenderer));
}
}
List<AnAction> children = new ArrayList<>();
AnAction[] viewAsActions = ((DefaultActionGroup) ActionManager.getInstance().getAction(DebuggerActions.REPRESENTATION_LIST)).getChildren(null);
for (AnAction viewAsAction : viewAsActions) {
if (viewAsAction instanceof AutoRendererAction) {
if (renderers.size() > 1) {
viewAsAction.getTemplatePresentation().setVisible(true);
children.add(viewAsAction);
}
} else {
children.add(viewAsAction);
}
}
if (!children.isEmpty()) {
children.add(Separator.getInstance());
}
children.addAll(renderers);
return children.toArray(new AnAction[children.size()]);
}
Aggregations