Java 类com.intellij.openapi.editor.ex.RangeMarkerEx 实例源码

项目:intellij-ce-playground    文件:CompletionAssertions.java   
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);
}
项目:tools-idea    文件:CompletionAssertions.java   
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);
}
项目:consulo    文件:CompletionAssertions.java   
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);
}
项目:intellij-ce-playground    文件:MockDocument.java   
@Override
public void registerRangeMarker(@NotNull RangeMarkerEx rangeMarker,
                                int start,
                                int end,
                                boolean greedyToLeft,
                                boolean greedyToRight,
                                int layer) {

}
项目:intellij-ce-playground    文件:RangeMarkerTest.java   
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();
}
项目:intellij-ce-playground    文件:RangeMarkerTest.java   
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();
}
项目:intellij-ce-playground    文件:RangeMarkerTest.java   
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);
}
项目:intellij-ce-playground    文件:RangeMarkerTest.java   
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);
}
项目:intellij-ce-playground    文件:RangeMarkerTest.java   
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);
}
项目:intellij-ce-playground    文件:FrozenDocument.java   
@Override
public void registerRangeMarker(@NotNull RangeMarkerEx rangeMarker,
                                int start,
                                int end,
                                boolean greedyToLeft,
                                boolean greedyToRight,
                                int layer) {
  throw new UnsupportedOperationException();
}
项目:intellij-ce-playground    文件:RangeMarkerImpl.java   
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;
      }
    });
  }
}
项目:intellij-ce-playground    文件:DocumentWindowImpl.java   
@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);
}
项目:intellij-ce-playground    文件:DocumentWindowImpl.java   
@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);
}
项目:intellij-ce-playground    文件:DocumentWindowImpl.java   
@Override
public void registerRangeMarker(@NotNull RangeMarkerEx rangeMarker,
                                int start,
                                int end,
                                boolean greedyToLeft,
                                boolean greedyToRight,
                                int layer) {
  throw new IllegalStateException();
}
项目:intellij-ce-playground    文件:FoldingRegionWindow.java   
FoldingRegionWindow(@NotNull DocumentWindow documentWindow,
                    @NotNull EditorWindow editorWindow,
                    @NotNull FoldRegion hostRegion,
                    int startShift,
                    int endShift)
{
  super(documentWindow, (RangeMarkerEx)hostRegion, startShift, endShift);
  myEditorWindow = editorWindow;
  myHostRegion = hostRegion;
}
项目:tools-idea    文件:RangeMarkerTest.java   
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();
}
项目:tools-idea    文件:RangeMarkerTest.java   
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();
}
项目:tools-idea    文件:RangeMarkerTest.java   
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);
}
项目:tools-idea    文件:RangeMarkerTest.java   
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);
}
项目:tools-idea    文件:RangeMarkerTest.java   
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);
}
项目:tools-idea    文件:RangeMarkerImpl.java   
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;
      }
    });
  }
}
项目:tools-idea    文件:DocumentWindowImpl.java   
@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);
}
项目:tools-idea    文件:DocumentWindowImpl.java   
@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);
}
项目:consulo    文件:MockDocument.java   
@Override
public void registerRangeMarker(@Nonnull RangeMarkerEx rangeMarker,
                                int start,
                                int end,
                                boolean greedyToLeft,
                                boolean greedyToRight,
                                int layer) {

}
项目:consulo    文件:RangeMarkerTest.java   
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();
}
项目:consulo    文件:RangeMarkerTest.java   
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();
}
项目:consulo    文件:RangeMarkerTest.java   
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);
}
项目:consulo    文件:RangeMarkerTest.java   
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);
}
项目:consulo    文件:RangeMarkerTest.java   
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);
}
项目:consulo    文件:FrozenDocument.java   
@Override
public void registerRangeMarker(@Nonnull RangeMarkerEx rangeMarker,
                                int start,
                                int end,
                                boolean greedyToLeft,
                                boolean greedyToRight,
                                int layer) {
  throw new UnsupportedOperationException();
}
项目:consulo    文件:RangeMarkerImpl.java   
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;
    });
  }
}
项目:consulo    文件:IntervalTreeImpl.java   
@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();
  }
}
项目:consulo    文件:DocumentWindowImpl.java   
@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);
}
项目:consulo    文件:DocumentWindowImpl.java   
@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);
}
项目:consulo    文件:DocumentWindowImpl.java   
@Override
public void registerRangeMarker(@Nonnull RangeMarkerEx rangeMarker,
                                int start,
                                int end,
                                boolean greedyToLeft,
                                boolean greedyToRight,
                                int layer) {
  throw new IllegalStateException();
}
项目:consulo    文件:FoldingRegionWindow.java   
FoldingRegionWindow(@Nonnull DocumentWindow documentWindow,
                    @Nonnull EditorWindow editorWindow,
                    @Nonnull FoldRegion hostRegion,
                    int startShift,
                    int endShift)
{
  super(documentWindow, (RangeMarkerEx)hostRegion, startShift, endShift);
  myEditorWindow = editorWindow;
  myHostRegion = hostRegion;
}
项目:intellij-ce-playground    文件:MockDocument.java   
@Override
public boolean removeRangeMarker(@NotNull RangeMarkerEx rangeMarker) {
  return false;
}
项目:intellij-ce-playground    文件:RangeMarkerTest.java   
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);
}
项目:intellij-ce-playground    文件:RangeMarkerTest.java   
private RangeMarkerEx createMarker(PsiFile psiFile, final int start, final int end) {
  document = documentManager.getDocument(psiFile);
  return (RangeMarkerEx)document.createRangeMarker(start, end);
}
项目:intellij-ce-playground    文件:FrozenDocument.java   
@Override
public boolean removeRangeMarker(@NotNull RangeMarkerEx rangeMarker) {
  throw new UnsupportedOperationException();
}