private void watchTail(int offset) { stopWatching(); tailWatcher = (RangeMarkerEx)getDocument().createRangeMarker(offset, offset); if (!tailWatcher.isValid()) { throw new AssertionError(getDocument() + "; offset=" + offset); } tailWatcher.setGreedyToRight(true); spy = new RangeMarkerSpy(tailWatcher) { @Override protected void invalidated(DocumentEvent e) { if (ApplicationManager.getApplication().isUnitTestMode()) { LOG.error("Tail offset invalidated, say thanks to the "+ e); } if (invalidateTrace == null) { invalidateTrace = DebugUtil.currentStackTrace(); killer = e; } } }; getDocument().addDocumentListener(spy); }
private void watchTail(int offset) { stopWatching(); tailWatcher = (RangeMarkerEx)getDocument().createRangeMarker(offset, offset); if (!tailWatcher.isValid()) { throw new AssertionError(getDocument() + "; offset=" + offset); } tailWatcher.setGreedyToRight(true); spy = new RangeMarkerSpy(tailWatcher) { @Override protected void invalidated(DocumentEvent e) { if (ApplicationManager.getApplication().isUnitTestMode()) { LOG.error("Tail offset invalidated, say thanks to the "+ e); } if (invalidateTrace == null) { invalidateTrace = new Throwable(); killer = e; } } }; getDocument().addDocumentListener(spy); }
@Override public void registerRangeMarker(@NotNull RangeMarkerEx rangeMarker, int start, int end, boolean greedyToLeft, boolean greedyToRight, int layer) { }
public void testSwap() { RangeMarkerEx marker1 = createMarker("012345678901234567", 5,6); DocumentEx document = (DocumentEx)marker1.getDocument(); document.createRangeMarker(3, 5); document.createRangeMarker(6, 7); document.createRangeMarker(4, 4); marker1.dispose(); }
public void testX() { RangeMarkerEx marker1 = createMarker(StringUtil.repeatSymbol(' ', 10), 3,6); DocumentEx document = (DocumentEx)marker1.getDocument(); document.createRangeMarker(2, 3); document.createRangeMarker(3, 8); document.createRangeMarker(7, 9); RangeMarkerEx r1 = (RangeMarkerEx)document.createRangeMarker(6, 8); r1.dispose(); marker1.dispose(); }
private RangeMarkerEx createMarker(@NonNls String string) { int start = string.indexOf('['); assertTrue(start != -1); string = string.replace("[", ""); int end = string.indexOf(']'); assertTrue(end != -1); string = string.replace("]", ""); return createMarker(string, start, end); }
public void testMoveTextRetargetsMarkers() throws Exception { RangeMarkerEx marker1 = createMarker("01234567890", 1, 3); DocumentEx document = (DocumentEx)marker1.getDocument(); RangeMarker marker2 = document.createRangeMarker(2, 4); document.moveText(0, 5, 8); assertEquals("56701234890", document.getText()); assertValidMarker(marker1, 4, 6); assertValidMarker(marker2, 5, 7); }
public void testMoveTextToTheBeginningRetargetsMarkers() throws Exception { RangeMarkerEx marker1 = createMarker("01234567890", 5, 5); DocumentEx document = (DocumentEx)marker1.getDocument(); RangeMarker marker2 = document.createRangeMarker(5, 7); document.moveText(4, 7, 1); assertEquals("04561237890", document.getText()); assertValidMarker(marker1, 2, 2); assertValidMarker(marker2, 2, 4); }
@Override public void registerRangeMarker(@NotNull RangeMarkerEx rangeMarker, int start, int end, boolean greedyToLeft, boolean greedyToRight, int layer) { throw new UnsupportedOperationException(); }
void invalidate(@NotNull final Object reason) { setValid(false); RangeMarkerTree.RMNode<RangeMarkerEx> node = myNode; if (node != null) { node.processAliveKeys(new Processor<RangeMarkerEx>() { @Override public boolean process(RangeMarkerEx markerEx) { myNode.getTree().beforeRemove(markerEx, reason); return true; } }); } }
@Override @NotNull public RangeMarker createRangeMarker(final int startOffset, final int endOffset) { ProperTextRange hostRange = injectedToHost(new ProperTextRange(startOffset, endOffset)); RangeMarker hostMarker = myDelegate.createRangeMarker(hostRange); int startShift = Math.max(0, hostToInjected(hostRange.getStartOffset()) - startOffset); int endShift = Math.max(0, endOffset - hostToInjected(hostRange.getEndOffset()) - startShift); return new RangeMarkerWindow(this, (RangeMarkerEx)hostMarker, startShift, endShift); }
@Override @NotNull public RangeMarker createRangeMarker(final int startOffset, final int endOffset, final boolean surviveOnExternalChange) { if (!surviveOnExternalChange) { return createRangeMarker(startOffset, endOffset); } ProperTextRange hostRange = injectedToHost(new ProperTextRange(startOffset, endOffset)); //todo persistent? RangeMarker hostMarker = myDelegate.createRangeMarker(hostRange.getStartOffset(), hostRange.getEndOffset(), surviveOnExternalChange); int startShift = Math.max(0, hostToInjected(hostRange.getStartOffset()) - startOffset); int endShift = Math.max(0, endOffset - hostToInjected(hostRange.getEndOffset()) - startShift); return new RangeMarkerWindow(this, (RangeMarkerEx)hostMarker, startShift, endShift); }
@Override public void registerRangeMarker(@NotNull RangeMarkerEx rangeMarker, int start, int end, boolean greedyToLeft, boolean greedyToRight, int layer) { throw new IllegalStateException(); }
FoldingRegionWindow(@NotNull DocumentWindow documentWindow, @NotNull EditorWindow editorWindow, @NotNull FoldRegion hostRegion, int startShift, int endShift) { super(documentWindow, (RangeMarkerEx)hostRegion, startShift, endShift); myEditorWindow = editorWindow; myHostRegion = hostRegion; }
private static RangeMarkerEx createMarker(@NonNls String string) { int start = string.indexOf('['); assertTrue(start != -1); string = string.replace("[", ""); int end = string.indexOf(']'); assertTrue(end != -1); string = string.replace("]", ""); return createMarker(string, start, end); }
public void invalidate(@NotNull final Object reason) { setValid(false); RangeMarkerTree.RMNode<RangeMarkerEx> node = myNode; if (node != null) { node.processAliveKeys(new Processor<RangeMarkerEx>() { @Override public boolean process(RangeMarkerEx markerEx) { myNode.getTree().reportInvalidation(markerEx, reason); return true; } }); } }
@Override public void registerRangeMarker(@Nonnull RangeMarkerEx rangeMarker, int start, int end, boolean greedyToLeft, boolean greedyToRight, int layer) { }
@Override public void registerRangeMarker(@Nonnull RangeMarkerEx rangeMarker, int start, int end, boolean greedyToLeft, boolean greedyToRight, int layer) { throw new UnsupportedOperationException(); }
void invalidate(@Nonnull final Object reason) { setValid(false); RangeMarkerTree.RMNode<RangeMarkerEx> node = myNode; if (node != null) { node.processAliveKeys(markerEx -> { myNode.getTree().beforeRemove(markerEx, reason); return true; }); } }
@Override public boolean removeInterval(@Nonnull T interval) { if (!((RangeMarkerEx)interval).isValid()) return false; try { l.writeLock().lock(); incModCount(); if (!((RangeMarkerEx)interval).isValid()) return false; checkBelongsToTheTree(interval, true); checkMax(true); processReferenceQueue(); IntervalNode<T> node = lookupNode(interval); if (node == null) return false; beforeRemove(interval, "Explicit Dispose"); node.removeInterval(interval); setNode(interval, null); checkMax(true); return true; } finally { l.writeLock().unlock(); } }
@Override @Nonnull public RangeMarker createRangeMarker(final int startOffset, final int endOffset) { ProperTextRange hostRange = injectedToHost(new ProperTextRange(startOffset, endOffset)); RangeMarker hostMarker = myDelegate.createRangeMarker(hostRange); int startShift = Math.max(0, hostToInjected(hostRange.getStartOffset()) - startOffset); int endShift = Math.max(0, endOffset - hostToInjected(hostRange.getEndOffset()) - startShift); return new RangeMarkerWindow(this, (RangeMarkerEx)hostMarker, startShift, endShift); }
@Override @Nonnull public RangeMarker createRangeMarker(final int startOffset, final int endOffset, final boolean surviveOnExternalChange) { if (!surviveOnExternalChange) { return createRangeMarker(startOffset, endOffset); } ProperTextRange hostRange = injectedToHost(new ProperTextRange(startOffset, endOffset)); //todo persistent? RangeMarker hostMarker = myDelegate.createRangeMarker(hostRange.getStartOffset(), hostRange.getEndOffset(), surviveOnExternalChange); int startShift = Math.max(0, hostToInjected(hostRange.getStartOffset()) - startOffset); int endShift = Math.max(0, endOffset - hostToInjected(hostRange.getEndOffset()) - startShift); return new RangeMarkerWindow(this, (RangeMarkerEx)hostMarker, startShift, endShift); }
@Override public void registerRangeMarker(@Nonnull RangeMarkerEx rangeMarker, int start, int end, boolean greedyToLeft, boolean greedyToRight, int layer) { throw new IllegalStateException(); }
FoldingRegionWindow(@Nonnull DocumentWindow documentWindow, @Nonnull EditorWindow editorWindow, @Nonnull FoldRegion hostRegion, int startShift, int endShift) { super(documentWindow, (RangeMarkerEx)hostRegion, startShift, endShift); myEditorWindow = editorWindow; myHostRegion = hostRegion; }
@Override public boolean removeRangeMarker(@NotNull RangeMarkerEx rangeMarker) { return false; }
private RangeMarkerEx createMarker(String text, final int start, final int end) { psiFile = createFile("x.txt", text); fileNode = psiFile.getNode(); // the node should be loaded, otherwise PsiToDocumentSynchronizer will ignore our commands return createMarker(psiFile, start, end); }
private RangeMarkerEx createMarker(PsiFile psiFile, final int start, final int end) { document = documentManager.getDocument(psiFile); return (RangeMarkerEx)document.createRangeMarker(start, end); }
@Override public boolean removeRangeMarker(@NotNull RangeMarkerEx rangeMarker) { throw new UnsupportedOperationException(); }