use of com.intellij.debugger.engine.DebugProcess in project intellij-community by JetBrains.
the class GroovyPositionManager method createPrepareRequest.
@Override
public ClassPrepareRequest createPrepareRequest(@NotNull final ClassPrepareRequestor requestor, @NotNull final SourcePosition position) throws NoDataException {
if (LOG.isDebugEnabled()) {
LOG.debug("createPrepareRequest: " + position);
}
checkGroovyFile(position);
String qName = getOuterClassName(position);
if (qName != null) {
return myDebugProcess.getRequestsManager().createClassPrepareRequest(requestor, qName);
}
qName = findEnclosingName(position);
if (qName == null)
throw NoDataException.INSTANCE;
ClassPrepareRequestor waitRequestor = new ClassPrepareRequestor() {
@Override
public void processClassPrepare(DebugProcess debuggerProcess, ReferenceType referenceType) {
final CompoundPositionManager positionManager = ((DebugProcessImpl) debuggerProcess).getPositionManager();
if (!positionManager.locationsOfLine(referenceType, position).isEmpty()) {
requestor.processClassPrepare(debuggerProcess, referenceType);
}
}
};
return myDebugProcess.getRequestsManager().createClassPrepareRequest(waitRequestor, qName + "$*");
}
use of com.intellij.debugger.engine.DebugProcess in project android by JetBrains.
the class DynamicResourceIdResolver method getAndroidResourceName.
@Nullable
@Override
public String getAndroidResourceName(int resId) {
String id = myDelegate.getAndroidResourceName(resId);
if (id != null) {
return id;
}
DebugProcess debugProcess = myContext.getDebugProcess();
VirtualMachineProxyImpl vmProxy = (VirtualMachineProxyImpl) debugProcess.getVirtualMachineProxy();
List<ReferenceType> classes = vmProxy.classesByName(CLASS_RESOURCES);
if (classes.isEmpty()) {
LOG.warn(CLASS_RESOURCES + " class not loaded?");
return null;
}
if (classes.size() != 1) {
LOG.warn("Expected a single Resource class loaded, but found " + classes.size());
}
ReferenceType resourcesClassType = classes.get(0);
Method getResourceNameMethod = DebuggerUtils.findMethod(resourcesClassType, "getResourceName", "(I)Ljava/lang/String;");
if (getResourceNameMethod == null) {
LOG.warn("Unable to locate getResourceName(int id) in class " + resourcesClassType.name());
return null;
}
List<ObjectReference> instances = resourcesClassType.instances(10);
if (instances.isEmpty()) {
LOG.warn("No instances of Resource class found");
return null;
}
List args = Collections.singletonList(DebuggerUtilsEx.createValue(vmProxy, "int", resId));
for (ObjectReference ref : instances) {
try {
Value value = debugProcess.invokeMethod(myContext, ref, getResourceNameMethod, args);
if (value instanceof StringReference) {
StringReference nameRef = (StringReference) value;
return nameRef.value();
}
} catch (EvaluateException e) {
ObjectReference exception = e.getExceptionFromTargetVM();
// do not log Resources$NotFoundException
if (exception == null || !DebuggerUtils.instanceOf(exception.type(), "android.content.res.Resources$NotFoundException")) {
LOG.warn("Unexpected error while invoking Resources.getResourceName()", e);
// continue and try this on other object references
}
}
}
return null;
}
use of com.intellij.debugger.engine.DebugProcess in project android by JetBrains.
the class AndroidRemoteDebugProcessHandler method detachProcessImpl.
@Override
protected void detachProcessImpl() {
DebugProcess debugProcess = DebuggerManager.getInstance(myProject).getDebugProcess(this);
if (debugProcess != null) {
debugProcess.stop(false);
}
notifyProcessDetached();
}
Aggregations