Search in sources :

Example 6 with AbsentInformationException

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

the class Evaluator method getLocalVariable.

public ExpressionValue getLocalVariable(String text) {
    ExpressionValue value = null;
    try {
        StackFrame frame = thread.frame(0);
        LocalVariable var = frame.visibleVariableByName(text);
        if (var != null) {
            value = new LocalValue(thread, var);
        }
    } catch (IncompatibleThreadStateException | AbsentInformationException | InvalidStackFrameException | NativeMethodException e) {
        throw new ExpressionException(e.getMessage(), e);
    }
    LOG.debug("GET local variable {} {} ", text, value);
    return value;
}
Also used : NativeMethodException(com.sun.jdi.NativeMethodException) IncompatibleThreadStateException(com.sun.jdi.IncompatibleThreadStateException) AbsentInformationException(com.sun.jdi.AbsentInformationException) StackFrame(com.sun.jdi.StackFrame) LocalVariable(com.sun.jdi.LocalVariable) InvalidStackFrameException(com.sun.jdi.InvalidStackFrameException)

Example 7 with AbsentInformationException

use of com.sun.jdi.AbsentInformationException in project enclojure by EricThorsen.

the class CljSourcePath method annotate.

public Object annotate(CallStackFrame csf, String stratumn) {
    int lineNumber = csf.getLineNumber(stratumn);
    if (lineNumber < 1) {
        return null;
    }
    Operation operation = csf.getCurrentOperation(stratumn);
    try {
        if (operation != null) {
            int startOffset;
            int endOffset;
            if (operation.getMethodName() != null) {
                startOffset = operation.getMethodStartPosition().getOffset();
                endOffset = operation.getMethodEndPosition().getOffset();
            } else {
                startOffset = operation.getStartPosition().getOffset();
                endOffset = operation.getEndPosition().getOffset();
            }
            return EditorContextBridge.getContext().annotate(getURL(convertSlash(csf.getSourcePath(stratumn)), true), startOffset, endOffset, EditorContext.CALL_STACK_FRAME_ANNOTATION_TYPE, debugger);
        } else {
            return EditorContextBridge.getContext().annotate(getURL(convertSlash(csf.getSourcePath(stratumn)), true), lineNumber, EditorContext.CALL_STACK_FRAME_ANNOTATION_TYPE, debugger);
        }
    } catch (AbsentInformationException e) {
        return EditorContextBridge.getContext().annotate(getURL(convertClassNameToRelativePath(csf.getClassName()), true), lineNumber, EditorContext.CALL_STACK_FRAME_ANNOTATION_TYPE, debugger);
    }
}
Also used : AbsentInformationException(com.sun.jdi.AbsentInformationException) Operation(org.netbeans.spi.debugger.jpda.EditorContext.Operation)

Example 8 with AbsentInformationException

use of com.sun.jdi.AbsentInformationException in project enclojure by EricThorsen.

the class CljSourcePath method annotate.

public Object annotate(JPDAThread t, String stratumn) {
    int lineNumber = t.getLineNumber(stratumn);
    if (lineNumber < 1) {
        return null;
    //AST ast = t.getAST(stratumn);
    }
    Operation operation = t.getCurrentOperation();
    String url;
    try {
        url = getURL(convertSlash(t.getSourcePath(stratumn)), true);
    } catch (AbsentInformationException e) {
        url = getURL(convertClassNameToRelativePath(t.getClassName()), true);
    }
    List operationsAnn = annotateOperations(debugger, url, operation, t.getLastOperations(), lineNumber);
    if (operation == null) {
        if (operationsAnn.size() == 0) {
            return EditorContextBridge.getContext().annotate(url, lineNumber, EditorContext.CURRENT_LINE_ANNOTATION_TYPE, debugger);
        } else {
        /*
                operationsAnn.add(EditorContextBridge.annotate (
                url,
                lineNumber,
                EditorContext.CURRENT_LINE_ANNOTATION_TYPE,
                debugger
                ));
                 */
        }
    }
    return operationsAnn;
}
Also used : AbsentInformationException(com.sun.jdi.AbsentInformationException) ArrayList(java.util.ArrayList) List(java.util.List) Operation(org.netbeans.spi.debugger.jpda.EditorContext.Operation)

Example 9 with AbsentInformationException

use of com.sun.jdi.AbsentInformationException 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)

Example 10 with AbsentInformationException

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

the class ExceptionBreakpoint method getEventMessage.

public String getEventMessage(LocatableEvent event) {
    String exceptionName = (getQualifiedName() != null) ? getQualifiedName() : CommonClassNames.JAVA_LANG_THROWABLE;
    String threadName = null;
    if (event instanceof ExceptionEvent) {
        ExceptionEvent exceptionEvent = (ExceptionEvent) event;
        try {
            exceptionName = exceptionEvent.exception().type().name();
            threadName = exceptionEvent.thread().name();
        } catch (Exception ignore) {
        }
    }
    final Location location = event.location();
    final String locationQName = DebuggerUtilsEx.getLocationMethodQName(location);
    String locationFileName;
    try {
        locationFileName = location.sourceName();
    } catch (AbsentInformationException e) {
        locationFileName = "";
    }
    final int locationLine = Math.max(0, location.lineNumber());
    if (threadName != null) {
        return DebuggerBundle.message("exception.breakpoint.console.message.with.thread.info", exceptionName, threadName, locationQName, locationFileName, locationLine);
    } else {
        return DebuggerBundle.message("exception.breakpoint.console.message", exceptionName, locationQName, locationFileName, locationLine);
    }
}
Also used : ExceptionEvent(com.sun.jdi.event.ExceptionEvent) AbsentInformationException(com.sun.jdi.AbsentInformationException) InvalidDataException(com.intellij.openapi.util.InvalidDataException) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) AbsentInformationException(com.sun.jdi.AbsentInformationException) XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint) Location(com.sun.jdi.Location)

Aggregations

AbsentInformationException (com.sun.jdi.AbsentInformationException)12 ReferenceType (com.sun.jdi.ReferenceType)4 LocalVariable (com.sun.jdi.LocalVariable)3 Location (com.sun.jdi.Location)3 NativeMethodException (com.sun.jdi.NativeMethodException)3 StackFrame (com.sun.jdi.StackFrame)3 XBreakpoint (com.intellij.xdebugger.breakpoints.XBreakpoint)2 ClassNotPreparedException (com.sun.jdi.ClassNotPreparedException)2 IncompatibleThreadStateException (com.sun.jdi.IncompatibleThreadStateException)2 InvalidStackFrameException (com.sun.jdi.InvalidStackFrameException)2 Method (com.sun.jdi.Method)2 Value (com.sun.jdi.Value)2 EventRequestManager (com.sun.jdi.request.EventRequestManager)2 DebuggerException (org.eclipse.che.api.debugger.server.exceptions.DebuggerException)2 DebuggerAbsentInformationException (org.eclipse.che.plugin.jdb.server.exceptions.DebuggerAbsentInformationException)2 Nullable (org.jetbrains.annotations.Nullable)2 Operation (org.netbeans.spi.debugger.jpda.EditorContext.Operation)2 SourcePosition (com.intellij.debugger.SourcePosition)1 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)1 DebuggerSession (com.intellij.debugger.impl.DebuggerSession)1