RIDER-114196 Sticky lines: add api to receive notification when all sticky lines are removed

GitOrigin-RevId: e97a4ab6523f03c5a452323375548f2c91048023
This commit is contained in:
Alexandr Trushev
2024-07-02 14:03:33 +00:00
committed by intellij-monorepo-bot
parent ca4b559d8a
commit 56d2fb7229
4 changed files with 20 additions and 6 deletions
@@ -126,7 +126,7 @@ class StickyLinesCollector(private val project: Project, private val document: D
", old removed: ${outdatedLines.size}" +
", ${debugPsiFile(psiFile)}"
}
stickyModel.notifyListeners()
stickyModel.notifyLinesUpdate()
}
private fun stickyLinesModel(psiFile: PsiFile): StickyLinesModel? {
@@ -102,10 +102,13 @@ internal class StickyLinesManager(
}
}
override fun modelChanged() {
override fun linesUpdated() {
recalculateAndRepaintLines()
}
override fun linesRemoved() {
}
override fun dispose() {
stickyModel.removeListener(this)
}
@@ -48,7 +48,7 @@ public interface StickyLinesModel {
void removeListener(@NotNull Listener listener);
void notifyListeners();
void notifyLinesUpdate();
/**
* Marker associated with sticky line to distinguish the highlighting daemon which produced the line.
@@ -68,6 +68,14 @@ public interface StickyLinesModel {
}
interface Listener {
void modelChanged();
/**
* Called when a batch of sticky lines is added or removed
*/
void linesUpdated();
/**
* Called when all sticky lines are removed
*/
void linesRemoved();
}
}
@@ -145,9 +145,9 @@ public final class StickyLinesModelImpl implements StickyLinesModel {
}
@Override
public void notifyListeners() {
public void notifyLinesUpdate() {
for (Listener listener : myListeners) {
listener.modelChanged();
listener.linesUpdated();
}
}
@@ -159,6 +159,9 @@ public final class StickyLinesModelImpl implements StickyLinesModel {
for (StickyLine line : getAllStickyLines()) {
removeStickyLine(line);
}
for (Listener listener : myListeners) {
listener.linesRemoved();
}
if (project != null) {
restartStickyLinesPass(project);
}