Search in sources :

Example 21 with ReferenceType

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

the class VMTargetStarter method installHaltPoint.

private void installHaltPoint(VirtualMachine vm) {
    List<ReferenceType> targetClasses = vm.classesByName(VMLocalTarget.class.getName());
    ReferenceType classRef = targetClasses.get(0);
    Method meth = classRef.methodsByName("haltPoint").get(0);
    BreakpointRequest req = vm.eventRequestManager().createBreakpointRequest(meth.location());
    req.setSuspendPolicy(BreakpointRequest.SUSPEND_EVENT_THREAD);
    req.enable();
}
Also used : BreakpointRequest(com.sun.jdi.request.BreakpointRequest) Method(com.sun.jdi.Method) ReferenceType(com.sun.jdi.ReferenceType)

Example 22 with ReferenceType

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

the class VMRemoteInstance method getMethod.

protected Method getMethod(Class<?> class1, String methodName) {
    List<ReferenceType> targetClasses = vm().classesByName(class1.getName());
    ReferenceType classRef = targetClasses.get(0);
    return classRef.methodsByName(methodName).get(0);
}
Also used : ReferenceType(com.sun.jdi.ReferenceType)

Example 23 with ReferenceType

use of com.sun.jdi.ReferenceType in project processing by processing.

the class LineBreakpoint method classLoaded.

/**
   * Event handler called when a class is loaded in the debugger. Causes the
   * breakpoint to be attached, if its class was loaded.
   *
   * @param theClass the class that was just loaded.
   */
@Override
public void classLoaded(ReferenceType theClass) {
    // check if our class is being loaded
    Messages.log("Class Loaded: " + theClass.name());
    if (theClass.name().equals(className())) {
        this.theClass = theClass;
        attach();
    }
    for (ReferenceType ct : theClass.nestedTypes()) {
        Messages.log("Nested " + ct.name());
    }
}
Also used : ReferenceType(com.sun.jdi.ReferenceType)

Example 24 with ReferenceType

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

the class ClassesTable method updateCountsInternal.

private void updateCountsInternal(@NotNull Map<ReferenceType, Long> class2Count) {
    final ReferenceType selectedClass = myModel.getSelectedClassBeforeHided();
    int newSelectedIndex = -1;
    final boolean isInitialized = !myItems.isEmpty();
    myItems = Collections.unmodifiableList(new ArrayList<>(class2Count.keySet()));
    int i = 0;
    for (final ReferenceType ref : class2Count.keySet()) {
        if (ref.equals(selectedClass)) {
            newSelectedIndex = i;
        }
        final DiffValue oldValue = isInitialized && !myCounts.containsKey(ref) ? new DiffValue(0, 0) : myCounts.getOrDefault(ref, UNKNOWN_VALUE);
        myCounts.put(ref, oldValue.update(class2Count.get(ref)));
        i++;
    }
    showContent();
    if (newSelectedIndex != -1 && !myModel.isHided()) {
        final int ix = convertRowIndexToView(newSelectedIndex);
        changeSelection(ix, DiffViewTableModel.CLASSNAME_COLUMN_INDEX, false, false);
    }
    getRowSorter().allRowsChanged();
}
Also used : ReferenceType(com.sun.jdi.ReferenceType)

Example 25 with ReferenceType

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

the class PositionManagerImpl method getPsiFileByLocation.

@Nullable
protected PsiFile getPsiFileByLocation(final Project project, final Location location) {
    if (location == null) {
        return null;
    }
    final ReferenceType refType = location.declaringType();
    if (refType == null) {
        return null;
    }
    // We should find a class no matter what
    // setAlternativeResolveEnabled is turned on here
    //if (DumbService.getInstance(project).isDumb()) {
    //  return null;
    //}
    final String originalQName = refType.name();
    Ref<PsiFile> altSource = new Ref<>();
    PsiClass psiClass = findPsiClassByName(originalQName, c -> altSource.set(findAlternativeJreSourceFile(c)));
    if (!altSource.isNull()) {
        return altSource.get();
    }
    if (psiClass != null) {
        PsiElement element = psiClass.getNavigationElement();
        // see IDEA-137167, prefer not compiled elements
        if (element instanceof PsiCompiledElement) {
            PsiElement fileElement = psiClass.getContainingFile().getNavigationElement();
            if (!(fileElement instanceof PsiCompiledElement)) {
                element = fileElement;
            }
        }
        return element.getContainingFile();
    } else {
        // try to search by filename
        try {
            PsiFile[] files = FilenameIndex.getFilesByName(project, refType.sourceName(), GlobalSearchScope.allScope(project));
            for (PsiFile file : files) {
                if (file instanceof PsiJavaFile) {
                    for (PsiClass cls : ((PsiJavaFile) file).getClasses()) {
                        if (StringUtil.equals(originalQName, cls.getQualifiedName())) {
                            return file;
                        }
                    }
                }
            }
        } catch (AbsentInformationException ignore) {
        }
    }
    return null;
}
Also used : Ref(com.intellij.openapi.util.Ref) AbsentInformationException(com.sun.jdi.AbsentInformationException) ReferenceType(com.sun.jdi.ReferenceType) Nullable(org.jetbrains.annotations.Nullable)

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