Search in sources :

Example 16 with ReferenceType

use of com.sun.jdi.ReferenceType in project jdk8u_jdk by JetBrains.

the class VisibleMethods method runTests.

/********** test core **********/
protected void runTests() throws Exception {
    /*
         * Run to String.<init>
         */
    startToMain("CC");
    ReferenceType ac = findReferenceType("AC");
    List<String> visible = ac.visibleMethods().stream().map(Method::toString).collect(Collectors.toList());
    System.out.println("visibleMethods(): " + visible);
    verifyContains(visible, 1, "Two.m(java.lang.String)");
    verifyContains(visible, 1, "One.m(java.lang.Object)");
    verifyContains(visible, 0, "Super.m(java.lang.Object)");
    verifyContains(visible, 0, "Super.m(java.lang.String)");
    verifyContains(visible, 1, "Two.m1()", "One.m1()");
    /*
         * resume the target listening for events
         */
    listenUntilVMDisconnect();
}
Also used : ReferenceType(com.sun.jdi.ReferenceType)

Example 17 with ReferenceType

use of com.sun.jdi.ReferenceType in project intellij-community by JetBrains.

the class JavaScratchPositionManager method getPsiFileByLocation.

@Nullable
@Override
protected PsiFile getPsiFileByLocation(Project project, Location location) {
    if (location == null) {
        return null;
    }
    final ReferenceType refType = location.declaringType();
    if (refType == null) {
        return null;
    }
    final PsiFile psiFile = PsiManager.getInstance(project).findFile(myScratchFile);
    if (!(psiFile instanceof PsiJavaFile)) {
        return null;
    }
    final PsiClass[] classes = ((PsiJavaFile) psiFile).getClasses();
    if (classes.length == 0) {
        return null;
    }
    final String originalQName = refType.name();
    for (PsiClass aClass : classes) {
        if (StringUtil.equals(originalQName, aClass.getQualifiedName())) {
            return psiFile;
        }
    }
    final int dollar = originalQName.indexOf('$');
    final String alternativeQName = dollar > 0 ? originalQName.substring(0, dollar) : null;
    if (!StringUtil.isEmpty(alternativeQName)) {
        for (PsiClass aClass : classes) {
            if (StringUtil.equals(alternativeQName, aClass.getQualifiedName())) {
                return psiFile;
            }
        }
    }
    return null;
}
Also used : PsiClass(com.intellij.psi.PsiClass) PsiFile(com.intellij.psi.PsiFile) PsiJavaFile(com.intellij.psi.PsiJavaFile) ReferenceType(com.sun.jdi.ReferenceType) Nullable(org.jetbrains.annotations.Nullable)

Example 18 with ReferenceType

use of com.sun.jdi.ReferenceType in project kotlin by JetBrains.

the class AbstractPositionManagerTest method assertBreakpointIsHandledCorrectly.

private static void assertBreakpointIsHandledCorrectly(Breakpoint breakpoint, PositionManager positionManager) throws NoDataException {
    SourcePosition position = SourcePosition.createFromLine(breakpoint.file, breakpoint.lineNumber);
    List<ReferenceType> classes = positionManager.getAllClasses(position);
    assertNotNull(classes);
    assertEquals(1, classes.size());
    ReferenceType type = classes.get(0);
    assertTrue("Type name " + type.name() + " doesn't match " + breakpoint.classNameRegexp + " for line " + (breakpoint.lineNumber + 1), type.name().matches(breakpoint.classNameRegexp));
    // JDI names are of form "package.Class$InnerClass"
    ReferenceType typeWithFqName = new MockReferenceType(type.name().replace('/', '.'));
    Location location = new MockLocation(typeWithFqName, breakpoint.file.getName(), breakpoint.lineNumber + 1);
    SourcePosition actualPosition = positionManager.getSourcePosition(location);
    assertNotNull(actualPosition);
    assertEquals(position.getFile(), actualPosition.getFile());
    assertEquals(position.getLine(), actualPosition.getLine());
}
Also used : SourcePosition(com.intellij.debugger.SourcePosition) ReferenceType(com.sun.jdi.ReferenceType) Location(com.sun.jdi.Location)

Example 19 with ReferenceType

use of com.sun.jdi.ReferenceType in project che by eclipse.

the class JdiValueImpl method getVariables.

@Override
public JdiVariable[] getVariables() {
    if (variables == null) {
        if (isPrimitive()) {
            variables = new JdiVariable[0];
        } else {
            if (isArray()) {
                ArrayReference array = (ArrayReference) value;
                int length = array.length();
                variables = new JdiVariable[length];
                for (int i = 0; i < length; i++) {
                    variables[i] = new JdiArrayElementImpl(i, array.getValue(i));
                }
            } else {
                ObjectReference object = (ObjectReference) value;
                ReferenceType type = object.referenceType();
                List<Field> fields = type.allFields();
                variables = new JdiVariable[fields.size()];
                int i = 0;
                for (Field f : fields) {
                    variables[i++] = new JdiFieldImpl(f, object);
                }
                // See JdiFieldImpl#compareTo(JdiFieldImpl).
                Arrays.sort(variables);
            }
        }
    }
    return variables;
}
Also used : Field(com.sun.jdi.Field) ArrayReference(com.sun.jdi.ArrayReference) ObjectReference(com.sun.jdi.ObjectReference) ReferenceType(com.sun.jdi.ReferenceType)

Example 20 with ReferenceType

use of com.sun.jdi.ReferenceType in project gravel by gravel-st.

the class VMRemoteTarget method trapExceptions.

private void trapExceptions() {
    ReferenceType referenceType = vm.classesByName("java.lang.Throwable").get(0);
    vm.eventRequestManager().createExceptionRequest(referenceType, true, true).enable();
}
Also used : ReferenceType(com.sun.jdi.ReferenceType)

Aggregations

ReferenceType (com.sun.jdi.ReferenceType)40 Nullable (org.jetbrains.annotations.Nullable)9 Project (com.intellij.openapi.project.Project)8 Location (com.sun.jdi.Location)5 ObjectReference (com.sun.jdi.ObjectReference)5 AbsentInformationException (com.sun.jdi.AbsentInformationException)4 Method (com.sun.jdi.Method)4 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)3 ClassesTable (com.intellij.debugger.memory.ui.ClassesTable)3 InstancesWindow (com.intellij.debugger.memory.ui.InstancesWindow)3 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)3 XDebugSession (com.intellij.xdebugger.XDebugSession)3 SourcePosition (com.intellij.debugger.SourcePosition)2 DebugProcess (com.intellij.debugger.engine.DebugProcess)2 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)2 InstancesTracker (com.intellij.debugger.memory.component.InstancesTracker)2 InstancesProvider (com.intellij.debugger.memory.utils.InstancesProvider)2 ClassPrepareRequestor (com.intellij.debugger.requests.ClassPrepareRequestor)2 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)2 PsiClass (com.intellij.psi.PsiClass)2