From 8751c22d4eec5a5291e8375e72395d15d94071b6 Mon Sep 17 00:00:00 2001 From: Egor Ushakov Date: Mon, 23 Apr 2018 20:09:25 +0300 Subject: [PATCH] restored limitation to line for java-related highlighters - IDEA-CR-31880 --- .../com/intellij/debugger/impl/DebuggerUtilsEx.java | 13 ++++++++++++- .../ui/breakpoints/JavaLineBreakpointType.java | 7 +++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java index bbe997e591db..abf191b72a59 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java @@ -860,10 +860,21 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils { @Nullable @Override public TextRange getHighlightRange() { - return SourcePositionHighlighter.getHighlightRangeFor(mySourcePosition); + return intersectWithLine(SourcePositionHighlighter.getHighlightRangeFor(mySourcePosition), mySourcePosition.getFile(), getLine()); } } + @Nullable + public static TextRange intersectWithLine(@Nullable TextRange range, @Nullable PsiFile file, int line) { + if (range != null && file != null) { + Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file); + if (document != null) { + range = range.intersection(DocumentUtil.getLineTextRange(document, line)); + } + } + return range; + } + @Nullable public static PsiFile getPsiFile(@Nullable XSourcePosition position, Project project) { ApplicationManager.getApplication().assertReadAccessAllowed(); diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointType.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointType.java index 2895510c97e2..3d4410dd11d9 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointType.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaLineBreakpointType.java @@ -190,7 +190,10 @@ public class JavaLineBreakpointType extends JavaLineBreakpointTypeBase