use of com.intellij.debugger.SourcePosition in project intellij-community by JetBrains.
the class RunToCursorBreakpoint method getXBreakpointType.
@Nullable
@Override
protected JavaLineBreakpointType getXBreakpointType() {
SourcePosition position = getSourcePosition();
VirtualFile file = position.getFile().getVirtualFile();
int line = position.getLine();
for (XLineBreakpointType<?> type : XDebuggerUtil.getInstance().getLineBreakpointTypes()) {
if (type instanceof JavaLineBreakpointType && type.canPutAt(file, line, myProject)) {
return ((JavaLineBreakpointType) type);
}
}
return null;
}
use of com.intellij.debugger.SourcePosition in project intellij-community by JetBrains.
the class StepIntoBreakpoint method create.
@Nullable
protected static StepIntoBreakpoint create(@NotNull Project project, @NotNull BreakpointStepMethodFilter filter) {
final SourcePosition pos = filter.getBreakpointPosition();
if (pos != null) {
final StepIntoBreakpoint breakpoint = new StepIntoBreakpoint(project, pos, filter);
breakpoint.init();
return breakpoint;
}
return null;
}
use of com.intellij.debugger.SourcePosition 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);
}
use of com.intellij.debugger.SourcePosition in project intellij-community by JetBrains.
the class JavaLineBreakpointType method computeVariants.
@NotNull
@Override
public List<JavaBreakpointVariant> computeVariants(@NotNull Project project, @NotNull XSourcePosition position) {
PsiFile file = PsiManager.getInstance(project).findFile(position.getFile());
if (file == null) {
return Collections.emptyList();
}
SourcePosition pos = SourcePosition.createFromLine(file, position.getLine());
List<PsiLambdaExpression> lambdas = DebuggerUtilsEx.collectLambdas(pos, true);
if (lambdas.isEmpty()) {
return Collections.emptyList();
}
PsiElement startMethod = DebuggerUtilsEx.getContainingMethod(pos);
//noinspection SuspiciousMethodCalls
if (lambdas.contains(startMethod) && lambdas.size() == 1) {
return Collections.emptyList();
}
Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
if (document == null) {
return Collections.emptyList();
}
List<JavaBreakpointVariant> res = new SmartList<>();
if (!(startMethod instanceof PsiLambdaExpression)) {
// base method
res.add(new LineJavaBreakpointVariant(position, startMethod, -1));
}
int ordinal = 0;
for (PsiLambdaExpression lambda : lambdas) {
//lambdas
PsiElement firstElem = DebuggerUtilsEx.getFirstElementOnTheLine(lambda, document, position.getLine());
XSourcePositionImpl elementPosition = XSourcePositionImpl.createByElement(firstElem);
if (elementPosition != null) {
if (lambda == startMethod) {
res.add(0, new LineJavaBreakpointVariant(elementPosition, lambda, ordinal++));
} else {
res.add(new LambdaJavaBreakpointVariant(elementPosition, lambda, ordinal++));
}
}
}
//all
res.add(new JavaBreakpointVariant(position));
return res;
}
use of com.intellij.debugger.SourcePosition in project intellij-community by JetBrains.
the class LineBreakpoint method acceptLocation.
protected boolean acceptLocation(final DebugProcessImpl debugProcess, ReferenceType classType, final Location loc) {
Method method = loc.method();
// if (DebuggerUtils.isSynthetic(method)) { return false; }
if (isAnonymousClass(classType)) {
if ((method.isConstructor() && loc.codeIndex() == 0) || method.isBridge())
return false;
}
SourcePosition position = debugProcess.getPositionManager().getSourcePosition(loc);
if (position == null)
return false;
return ReadAction.compute(() -> {
JavaLineBreakpointType type = getXBreakpointType();
if (type == null)
return true;
return type.matchesPosition(this, position);
});
}
Aggregations