diff --git a/platform/lang-impl/api-dump-experimental.txt b/platform/lang-impl/api-dump-experimental.txt index 32cb779e5658..5d38e6dcae0d 100644 --- a/platform/lang-impl/api-dump-experimental.txt +++ b/platform/lang-impl/api-dump-experimental.txt @@ -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 diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/VcsFacade.java b/platform/lang-impl/src/com/intellij/codeInsight/actions/VcsFacade.java index a077381cafb4..f5b26861a7de 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/actions/VcsFacade.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/VcsFacade.java @@ -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 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. * diff --git a/platform/vcs-impl/lang/src/com/intellij/codeInsight/actions/VcsFacadeImpl.java b/platform/vcs-impl/lang/src/com/intellij/codeInsight/actions/VcsFacadeImpl.java index 1f495ebb1d29..fc2d0dd52507 100644 --- a/platform/vcs-impl/lang/src/com/intellij/codeInsight/actions/VcsFacadeImpl.java +++ b/platform/vcs-impl/lang/src/com/intellij/codeInsight/actions/VcsFacadeImpl.java @@ -114,6 +114,22 @@ public final class VcsFacadeImpl extends VcsFacade { return getChangedRangesInfo(document, computeRanges(document, contentFromVcs)); } + @Override + public @NotNull List 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 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 getChangedFilesFromDirs(@NotNull Project project, @NotNull List psiDirs) {