use of com.intellij.debugger.engine.DebugProcessImpl in project intellij-community by JetBrains.
the class InterruptThreadAction method actionPerformed.
public void actionPerformed(final AnActionEvent e) {
final DebuggerTreeNodeImpl[] nodes = getSelectedNodes(e.getDataContext());
if (nodes == null) {
return;
}
//noinspection ConstantConditions
final List<ThreadReferenceProxyImpl> threadsToInterrupt = new ArrayList<>();
for (final DebuggerTreeNodeImpl debuggerTreeNode : nodes) {
final NodeDescriptorImpl descriptor = debuggerTreeNode.getDescriptor();
if (descriptor instanceof ThreadDescriptorImpl) {
threadsToInterrupt.add(((ThreadDescriptorImpl) descriptor).getThreadReference());
}
}
if (!threadsToInterrupt.isEmpty()) {
final DebuggerContextImpl debuggerContext = getDebuggerContext(e.getDataContext());
final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
if (debugProcess != null) {
debugProcess.getManagerThread().schedule(new DebuggerCommandImpl() {
protected void action() throws Exception {
boolean unsupported = false;
for (ThreadReferenceProxyImpl thread : threadsToInterrupt) {
try {
thread.getThreadReference().interrupt();
} catch (UnsupportedOperationException ignored) {
unsupported = true;
}
}
if (unsupported) {
final Project project = debugProcess.getProject();
XDebugSessionImpl.NOTIFICATION_GROUP.createNotification("Thread operation 'interrupt' is not supported by VM", MessageType.INFO).notify(project);
}
}
});
}
}
}
use of com.intellij.debugger.engine.DebugProcessImpl in project intellij-community by JetBrains.
the class AddSteppingFilterAction method actionPerformed.
public void actionPerformed(final AnActionEvent e) {
final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext());
DebugProcessImpl process = debuggerContext.getDebugProcess();
if (process == null) {
return;
}
final StackFrameProxyImpl proxy = PopFrameAction.getStackFrameProxy(e);
process.getManagerThread().schedule(new DebuggerCommandImpl() {
protected void action() throws Exception {
final String name = getClassName(proxy != null ? proxy : debuggerContext.getFrameProxy());
if (name == null) {
return;
}
final Project project = e.getData(CommonDataKeys.PROJECT);
ApplicationManager.getApplication().invokeLater(() -> {
String filter = Messages.showInputDialog(project, "", "Add Stepping Filter", null, name, null);
if (filter != null) {
ClassFilter[] newFilters = ArrayUtil.append(DebuggerSettings.getInstance().getSteppingFilters(), new ClassFilter(filter));
DebuggerSettings.getInstance().setSteppingFilters(newFilters);
}
});
}
});
}
use of com.intellij.debugger.engine.DebugProcessImpl in project intellij-community by JetBrains.
the class AutoRendererAction method actionPerformed.
public void actionPerformed(@NotNull final AnActionEvent e) {
final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext());
final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
if (debugProcess != null) {
final List<JavaValue> selectedValues = ViewAsGroup.getSelectedValues(e);
if (!selectedValues.isEmpty()) {
debugProcess.getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) {
public void threadAction() {
for (JavaValue selectedValue : selectedValues) {
selectedValue.getDescriptor().setRenderer(null);
}
DebuggerAction.refreshViews(e);
}
});
}
}
}
use of com.intellij.debugger.engine.DebugProcessImpl in project intellij-community by JetBrains.
the class NewArrayInstanceEvaluator method evaluate.
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
// throw new EvaluateException("Creating new array instances is not supported yet", true);
DebugProcessImpl debugProcess = context.getDebugProcess();
Object obj = myArrayTypeEvaluator.evaluate(context);
if (!(obj instanceof ArrayType)) {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.array.type.expected"));
}
ArrayType arrayType = (ArrayType) obj;
int dimension;
Object[] initialValues = null;
if (myDimensionEvaluator != null) {
Object o = myDimensionEvaluator.evaluate(context);
if (!(o instanceof Value && DebuggerUtils.isNumeric((Value) o))) {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.array.dimention.numeric.value.expected"));
}
PrimitiveValue value = (PrimitiveValue) o;
dimension = value.intValue();
} else {
// myInitializerEvaluator must not be null
Object o = myInitializerEvaluator.evaluate(context);
if (!(o instanceof Object[])) {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.evaluate.array.initializer"));
}
initialValues = (Object[]) o;
dimension = initialValues.length;
}
ArrayReference arrayReference = debugProcess.newInstance(arrayType, dimension);
if (initialValues != null && initialValues.length > 0) {
if (LOG.isDebugEnabled()) {
LOG.debug("Setting initial values: dimension = " + dimension + "; array size is " + initialValues.length);
}
setInitialValues(arrayReference, initialValues, context);
}
return arrayReference;
}
use of com.intellij.debugger.engine.DebugProcessImpl in project intellij-community by JetBrains.
the class NewArrayInstanceEvaluator method setInitialValues.
private static void setInitialValues(ArrayReference arrayReference, Object[] values, EvaluationContextImpl context) throws EvaluateException {
ArrayType type = (ArrayType) arrayReference.referenceType();
DebugProcessImpl debugProcess = context.getDebugProcess();
try {
if (type.componentType() instanceof ArrayType) {
ArrayType componentType = (ArrayType) type.componentType();
int length = arrayReference.length();
for (int idx = 0; idx < length; idx++) {
ArrayReference componentArray = (ArrayReference) arrayReference.getValue(idx);
Object value = values[idx];
if (value instanceof Value) {
arrayReference.setValue(idx, (Value) value);
} else {
Object[] componentArrayValues = (Object[]) value;
if (componentArray == null) {
componentArray = debugProcess.newInstance(componentType, componentArrayValues.length);
arrayReference.setValue(idx, componentArray);
}
setInitialValues(componentArray, componentArrayValues, context);
}
}
} else {
if (values.length > 0) {
arrayReference.setValues(new ArrayList(Arrays.asList(values)));
}
}
} catch (ClassNotLoadedException ex) {
final ReferenceType referenceType;
try {
referenceType = context.isAutoLoadClasses() ? debugProcess.loadClass(context, ex.className(), type.classLoader()) : null;
} catch (InvocationException | InvalidTypeException | IncompatibleThreadStateException | ClassNotLoadedException e) {
throw EvaluateExceptionUtil.createEvaluateException(e);
}
if (referenceType != null) {
setInitialValues(arrayReference, values, context);
} else {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("error.class.not.loaded", ex.className()));
}
} catch (InvalidTypeException ex) {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.array.initializer.type"));
} catch (IndexOutOfBoundsException ex) {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.invalid.array.size"));
} catch (ClassCastException ex) {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.initialize.array"));
}
}
Aggregations