mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ManualRangeMarker: really honor surviveOnExternalChange, add getMarkerCount
This commit is contained in:
@@ -27,6 +27,7 @@ import com.intellij.util.containers.WeakHashMap;
|
||||
import com.intellij.util.containers.WeakValueHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -53,7 +54,7 @@ class MarkerCache {
|
||||
RangeKey key = new RangeKey(range, greedyLeft, greedyRight, persistent);
|
||||
ManualRangeMarker marker = byRange.get(key);
|
||||
if (marker == null) {
|
||||
marker = new ManualRangeMarker(frozen, range, greedyLeft, greedyRight, true);
|
||||
marker = new ManualRangeMarker(frozen, range, greedyLeft, greedyRight, persistent);
|
||||
myMarkerSet.add(marker);
|
||||
byRange.put(key, marker);
|
||||
myUpdatedRanges = null;
|
||||
@@ -166,6 +167,11 @@ class MarkerCache {
|
||||
return updated == null ? null : updated.getRange();
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
synchronized int getMarkerCount() {
|
||||
return myMarkerSet.size();
|
||||
}
|
||||
|
||||
private static class RangeKey {
|
||||
final int start;
|
||||
final int end;
|
||||
|
||||
+8
@@ -223,6 +223,14 @@ public class SmartPointerManagerImpl extends SmartPointerManager {
|
||||
}
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public int getMarkerCount(@NotNull Document document) {
|
||||
synchronized (lock) {
|
||||
VirtualFile file = FileDocumentManager.getInstance().getFile(document);
|
||||
return file == null ? 0 : getMarkerCache(file).getMarkerCount();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pointToTheSameElement(@NotNull SmartPsiElementPointer pointer1, @NotNull SmartPsiElementPointer pointer2) {
|
||||
return SmartPsiElementPointerImpl.pointsToTheSameElementAs(pointer1, pointer2);
|
||||
|
||||
Reference in New Issue
Block a user