[debugger] yet one less getSourcePosition usage

GitOrigin-RevId: ef504cb768b93f9e1292887d733dfd3f81268835
This commit is contained in:
Egor Ushakov
2024-10-03 16:53:20 +02:00
committed by intellij-monorepo-bot
parent 6b729379f5
commit 6edeceeac8
3 changed files with 15 additions and 6 deletions

View File

@@ -388,8 +388,13 @@ public abstract class BreakpointWithHighlighter<P extends JavaBreakpointProperti
}
protected String getFileName() {
XSourcePosition sourcePosition = myXBreakpoint.getSourcePosition();
return sourcePosition != null ? sourcePosition.getFile().getName() : "";
VirtualFile file = getVirtualFile();
return file != null ? file.getName() : "";
}
@Nullable
protected VirtualFile getVirtualFile() {
return ObjectUtils.doIfNotNull(ObjectUtils.doIfNotNull(myXBreakpoint, XBreakpoint::getSourcePosition), XSourcePosition::getFile);
}
@Override

View File

@@ -226,11 +226,10 @@ public class LineBreakpoint<P extends JavaBreakpointProperties> extends Breakpoi
}
private boolean isInScopeOf(DebugProcessImpl debugProcess, String className) {
final SourcePosition position = getSourcePosition();
if (position != null) {
final VirtualFile breakpointFile = position.getFile().getVirtualFile();
VirtualFile breakpointFile = getVirtualFile();
if (breakpointFile != null) {
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
if (breakpointFile != null && fileIndex.isUnderSourceRootOfType(breakpointFile, JavaModuleSourceRootTypes.SOURCES)) {
if (fileIndex.isUnderSourceRootOfType(breakpointFile, JavaModuleSourceRootTypes.SOURCES)) {
if (debugProcess.getSearchScope().contains(breakpointFile)) {
return true;
}

View File

@@ -45,6 +45,11 @@ public class RunToCursorBreakpoint extends SyntheticLineBreakpoint implements St
return myCustomPosition.getFile().getName();
}
@Override
protected @Nullable VirtualFile getVirtualFile() {
return myCustomPosition.getFile().getVirtualFile();
}
@Override
public boolean isRestoreBreakpoints() {
return myRestoreBreakpoints;