use of com.sun.jdi.ReferenceType in project intellij-community by JetBrains.
the class ShowInstancesByClassAction method perform.
@Override
protected void perform(XValueNodeImpl node, @NotNull String nodeName, AnActionEvent e) {
final Project project = e.getProject();
if (project != null) {
final XDebugSession debugSession = XDebuggerManager.getInstance(project).getCurrentSession();
final ObjectReference ref = getObjectReference(node);
if (debugSession != null && ref != null) {
final ReferenceType referenceType = ref.referenceType();
new InstancesWindow(debugSession, l -> {
final List<ObjectReference> instances = referenceType.instances(l);
return instances == null ? Collections.emptyList() : instances;
}, referenceType.name()).show();
}
}
}
use of com.sun.jdi.ReferenceType in project intellij-community by JetBrains.
the class DebuggerTreeNodeExpression method castToRuntimeType.
public static PsiExpression castToRuntimeType(PsiExpression expression, Value value) throws EvaluateException {
if (!(value instanceof ObjectReference)) {
return expression;
}
ReferenceType valueType = ((ObjectReference) value).referenceType();
if (valueType == null) {
return expression;
}
Project project = expression.getProject();
PsiType type = RuntimeTypeEvaluator.getCastableRuntimeType(project, value);
if (type == null) {
return expression;
}
PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
String typeName = type.getCanonicalText();
try {
PsiParenthesizedExpression parenthExpression = (PsiParenthesizedExpression) elementFactory.createExpressionFromText("((" + typeName + ")expression)", null);
//noinspection ConstantConditions
((PsiTypeCastExpression) parenthExpression.getExpression()).getOperand().replace(expression);
Set<String> imports = expression.getUserData(ADDITIONAL_IMPORTS_KEY);
if (imports == null) {
imports = new SmartHashSet<>();
}
imports.add(typeName);
parenthExpression.putUserData(ADDITIONAL_IMPORTS_KEY, imports);
return parenthExpression;
} catch (IncorrectOperationException e) {
throw new EvaluateException(DebuggerBundle.message("error.invalid.type.name", typeName), e);
}
}
use of com.sun.jdi.ReferenceType in project intellij-community by JetBrains.
the class NodeManagerImpl method getContextKeyForFrame.
@Nullable
public static String getContextKeyForFrame(final StackFrameProxyImpl frame) {
if (frame == null) {
return null;
}
try {
final Location location = frame.location();
final Method method = DebuggerUtilsEx.getMethod(location);
if (method == null) {
return null;
}
final ReferenceType referenceType = location.declaringType();
final StringBuilder builder = StringBuilderSpinAllocator.alloc();
try {
return builder.append(referenceType.signature()).append("#").append(method.name()).append(method.signature()).toString();
} finally {
StringBuilderSpinAllocator.dispose(builder);
}
} catch (EvaluateException ignored) {
} catch (InternalException ie) {
if (ie.errorCode() != 23) {
// INVALID_METHODID
throw ie;
}
}
return null;
}
use of com.sun.jdi.ReferenceType in project intellij-community by JetBrains.
the class GroovyPositionManager method getAllClasses.
@Override
@NotNull
public List<ReferenceType> getAllClasses(@NotNull final SourcePosition position) throws NoDataException {
if (LOG.isDebugEnabled()) {
LOG.debug("getAllClasses: " + position);
}
checkGroovyFile(position);
List<ReferenceType> result = ApplicationManager.getApplication().runReadAction(new Computable<List<ReferenceType>>() {
@Override
public List<ReferenceType> compute() {
GroovyPsiElement sourceImage = findReferenceTypeSourceImage(position);
if (sourceImage instanceof GrTypeDefinition && !((GrTypeDefinition) sourceImage).isAnonymous()) {
String qName = getClassNameForJvm((GrTypeDefinition) sourceImage);
if (qName != null)
return myDebugProcess.getVirtualMachineProxy().classesByName(qName);
} else if (sourceImage == null) {
final String scriptName = getScriptQualifiedName(position);
if (scriptName != null)
return myDebugProcess.getVirtualMachineProxy().classesByName(scriptName);
} else {
String enclosingName = findEnclosingName(position);
if (enclosingName == null)
return null;
final List<ReferenceType> outers = myDebugProcess.getVirtualMachineProxy().classesByName(enclosingName);
final List<ReferenceType> result = new ArrayList<>(outers.size());
for (ReferenceType outer : outers) {
final ReferenceType nested = findNested(outer, sourceImage, position);
if (nested != null) {
result.add(nested);
}
}
return result;
}
return null;
}
});
if (LOG.isDebugEnabled()) {
LOG.debug("getAllClasses = " + result);
}
if (result == null)
throw NoDataException.INSTANCE;
return result;
}
use of com.sun.jdi.ReferenceType 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 + "$*");
}
Aggregations