mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
[debugger] set lambda breakpoint by default, IDEA-349250
Straightforward implementation covering multi-line Stream call chains. GitOrigin-RevId: ca1ebf6ffa757ed1bc034245d6a0cc89d55bb553
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4cc512584b
commit
f72e57b099
@@ -432,6 +432,30 @@ public class JavaLineBreakpointType extends JavaLineBreakpointTypeBase<JavaLineB
|
||||
public Icon getIcon() {
|
||||
return AllIcons.Debugger.Db_set_breakpoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority(@NotNull Project project) {
|
||||
var basePriority = super.getPriority(project);
|
||||
|
||||
PsiFile file = DebuggerUtilsEx.getPsiFile(mySourcePosition, project);
|
||||
if (file == null) return basePriority;
|
||||
|
||||
SourcePosition pos = SourcePosition.createFromLine(file, mySourcePosition.getLine());
|
||||
var firstLineElement = pos.getElementAt();
|
||||
if (firstLineElement == null) return basePriority;
|
||||
|
||||
if (isLowPriority(firstLineElement)) {
|
||||
// Thus, we are raising the priority of other variants (i.e., lambda argument).
|
||||
return basePriority - 50;
|
||||
}
|
||||
|
||||
return basePriority;
|
||||
}
|
||||
|
||||
protected boolean isLowPriority(PsiElement firstLineElement) {
|
||||
// Dot at the beginning is the sign of a multi-line statement, lower the line breakpoint priority.
|
||||
return firstLineElement instanceof PsiJavaToken dot && dot.getTokenType() == JavaTokenType.DOT;
|
||||
}
|
||||
}
|
||||
|
||||
public class LambdaJavaBreakpointVariant extends ExactJavaBreakpointVariant {
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiManager
|
||||
import com.intellij.psi.impl.source.tree.LeafPsiElement
|
||||
import com.intellij.psi.util.elementType
|
||||
import com.intellij.xdebugger.XSourcePosition
|
||||
import com.intellij.xdebugger.breakpoints.XBreakpoint
|
||||
import com.intellij.xdebugger.breakpoints.XLineBreakpoint
|
||||
@@ -50,7 +51,12 @@ class KotlinLineBreakpointType :
|
||||
position: XSourcePosition,
|
||||
element: PsiElement?,
|
||||
lambdaOrdinal: Int
|
||||
) : LineJavaBreakpointVariant(position, element, lambdaOrdinal)
|
||||
) : LineJavaBreakpointVariant(position, element, lambdaOrdinal) {
|
||||
override fun isLowPriority(firstLineElement: PsiElement?): Boolean {
|
||||
// Dot at the beginning is the sign of a multi-line statement, lower the line breakpoint priority.
|
||||
return firstLineElement.elementType == KtTokens.DOT
|
||||
}
|
||||
}
|
||||
|
||||
inner class KotlinBreakpointVariant(
|
||||
position: XSourcePosition,
|
||||
|
||||
Reference in New Issue
Block a user