vcs: Add a method to the VCS facade to get lines where code was removed (after that lines)

This change is needed to provide this info for run-to-cursor (see next commit)


(cherry picked from commit ea7653981da641a726cfd382b5033b9aacc0e437)

IJ-CR-174622

GitOrigin-RevId: 9049f1eb908b7d3cfa3d20ac2307a70e150314c9
This commit is contained in:
Alexey.Merkulov
2025-09-02 17:46:21 +02:00
committed by intellij-monorepo-bot
parent 2336e40949
commit c6c5fd5fd0
3 changed files with 25 additions and 0 deletions

View File

@@ -123,6 +123,7 @@ c:com.intellij.build.output.BuildOutputInstantReaderImpl
- a:getTitle():java.lang.String
c:com.intellij.codeInsight.actions.VcsFacade
- *:createPatchPreviewComponent(com.intellij.openapi.project.Project,java.util.Map):javax.swing.JComponent
- *:getLinesWithRemovedRangesAfter(com.intellij.psi.PsiFile):java.util.List
*:com.intellij.codeInsight.codeVision.CodeVisionProvider
- *sf:Companion:com.intellij.codeInsight.codeVision.CodeVisionProvider$Companion
- sf:EP_NAME:java.lang.String

View File

@@ -132,6 +132,14 @@ public class VcsFacade {
return null;
}
/**
* @return the list of lines where some code (after it) was removed.
*/
@ApiStatus.Experimental
public @NotNull List<Integer> getLinesWithRemovedRangesAfter(@NotNull PsiFile file) {
return Collections.emptyList();
}
/**
* Notify VCS that local file content has changed in a way, that IDE might not detect, and uncommitted changes should be updated.
*

View File

@@ -114,6 +114,22 @@ public final class VcsFacadeImpl extends VcsFacade {
return getChangedRangesInfo(document, computeRanges(document, contentFromVcs));
}
@Override
public @NotNull List<Integer> getLinesWithRemovedRangesAfter(@NotNull PsiFile file) {
Project project = file.getProject();
Document document = PsiDocumentManager.getInstance(project).getDocument(file);
if (document == null) return emptyList();
LineStatusTracker<?> tracker = LineStatusTrackerManager.getInstance(project).getLineStatusTracker(document);
if (tracker == null) return emptyList();
List<? extends Range> trackerRanges = tracker.getRanges();
if (trackerRanges == null) return emptyList();
return trackerRanges.stream()
.filter(range -> range.getType() == Range.DELETED)
.map( range -> range.getLine1())
.toList();
}
@Override
public @NotNull List<PsiFile> getChangedFilesFromDirs(@NotNull Project project,
@NotNull List<? extends PsiDirectory> psiDirs) {