Search in sources :

Example 1 with JavaLineBreakpointProperties

use of org.jetbrains.java.debugger.breakpoints.properties.JavaLineBreakpointProperties in project intellij-community by JetBrains.

the class JavaLineBreakpointType method getContainingMethod.

@Nullable
public PsiElement getContainingMethod(@NotNull LineBreakpoint<?> breakpoint) {
    SourcePosition position = breakpoint.getSourcePosition();
    if (position == null)
        return null;
    JavaBreakpointProperties properties = breakpoint.getProperties();
    if (properties instanceof JavaLineBreakpointProperties && !(breakpoint instanceof RunToCursorBreakpoint)) {
        Integer ordinal = ((JavaLineBreakpointProperties) properties).getLambdaOrdinal();
        if (ordinal > -1) {
            List<PsiLambdaExpression> lambdas = DebuggerUtilsEx.collectLambdas(position, true);
            if (ordinal < lambdas.size()) {
                return lambdas.get(ordinal);
            }
        }
    }
    return DebuggerUtilsEx.getContainingMethod(position);
}
Also used : XSourcePosition(com.intellij.xdebugger.XSourcePosition) SourcePosition(com.intellij.debugger.SourcePosition) JavaLineBreakpointProperties(org.jetbrains.java.debugger.breakpoints.properties.JavaLineBreakpointProperties) JavaBreakpointProperties(org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with JavaLineBreakpointProperties

use of org.jetbrains.java.debugger.breakpoints.properties.JavaLineBreakpointProperties in project kotlin by JetBrains.

the class KotlinLineBreakpointType method getContainingMethod.

@Override
@Nullable
public PsiElement getContainingMethod(@NotNull LineBreakpoint<?> breakpoint) {
    SourcePosition position = breakpoint.getSourcePosition();
    if (position == null)
        return null;
    JavaBreakpointProperties properties = getProperties(breakpoint);
    if (properties instanceof JavaLineBreakpointProperties) {
        Integer ordinal = ((JavaLineBreakpointProperties) properties).getLambdaOrdinal();
        PsiElement lambda = getLambdaByOrdinal(position, ordinal);
        if (lambda != null)
            return lambda;
    }
    return getContainingMethod(position.getElementAt());
}
Also used : XSourcePosition(com.intellij.xdebugger.XSourcePosition) SourcePosition(com.intellij.debugger.SourcePosition) JavaLineBreakpointProperties(org.jetbrains.java.debugger.breakpoints.properties.JavaLineBreakpointProperties) JavaBreakpointProperties(org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties) PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

SourcePosition (com.intellij.debugger.SourcePosition)2 XSourcePosition (com.intellij.xdebugger.XSourcePosition)2 Nullable (org.jetbrains.annotations.Nullable)2 JavaBreakpointProperties (org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties)2 JavaLineBreakpointProperties (org.jetbrains.java.debugger.breakpoints.properties.JavaLineBreakpointProperties)2 PsiElement (com.intellij.psi.PsiElement)1