Java 类com.intellij.util.diff.FilesTooBigForDiffException 实例源码

项目:intellij-ce-playground    文件:PersistentRangeHighlighterImpl.java   
private boolean translatedViaDiff(DocumentEvent e, DocumentEventImpl event) {
  try {
    myLine = event.translateLineViaDiff(myLine);
  }
  catch (FilesTooBigForDiffException ignored) {
    return false;
  }
  if (myLine < 0 || myLine >= getDocument().getLineCount()) {
    invalidate(e);
  }
  else {
    DocumentEx document = getDocument();
    setIntervalStart(document.getLineStartOffset(myLine));
    setIntervalEnd(document.getLineEndOffset(myLine));
  }
  return true;
}
项目:intellij-ce-playground    文件:DiffPanelImpl.java   
void rediff() {
  try {
    if (myTopMessageDiffPanel != null) {
      myPanel.removeTopComponent(myTopMessageDiffPanel);
    }
    LineBlocks blocks = myData.updateEditors();
    setLineBlocks(blocks != null ? blocks : LineBlocks.EMPTY);
    if (blocks != null && blocks.getCount() == 0) {
      if (myData.isContentsEqual()) {
        setFileContentsAreIdentical();
      }
    }
  }
  catch (FilesTooBigForDiffException e) {
    setTooBigFileErrorContents();
  }
}
项目:intellij-ce-playground    文件:PersistentRangeMarker.java   
@Nullable
private static Pair<ProperTextRange, LinesCols> translateViaDiff(final DocumentEventImpl event, LinesCols linesCols) {
  try {
    int myStartLine = event.translateLineViaDiffStrict(linesCols.myStartLine);
    Document document = event.getDocument();
    if (myStartLine < 0 || myStartLine >= document.getLineCount()) {
      return null;
    }

    int start = document.getLineStartOffset(myStartLine) + linesCols.myStartColumn;
    if (start >= document.getTextLength()) return null;

    int myEndLine = event.translateLineViaDiffStrict(linesCols.myEndLine);
    if (myEndLine < 0 || myEndLine >= document.getLineCount()) {
      return null;
    }

    int end = document.getLineStartOffset(myEndLine) + linesCols.myEndColumn;
    if (end > document.getTextLength() || end < start) return null;

    return Pair.create(new ProperTextRange(start, end), new LinesCols(myStartLine, linesCols.myStartColumn, myEndLine, linesCols.myEndColumn));
  }
  catch (FilesTooBigForDiffException e) {
    return null;
  }
}
项目:intellij-ce-playground    文件:VcsHistoryDialog.java   
@Nullable
private Block getBlock(VcsFileRevision revision) throws FilesTooBigForDiffException, VcsException {
  if (myRevisionToContentMap.containsKey(revision)) {
    return myRevisionToContentMap.get(revision);
  }

  final String revisionContent = getContentOf(revision);
  if (revisionContent == null) return null;

  int index = myRevisions.indexOf(revision);
  Block blockByIndex = getBlock(index);
  if (blockByIndex == null) return null;

  myRevisionToContentMap.put(revision, new FindBlock(revisionContent, blockByIndex).getBlockInThePrevVersion());
  return myRevisionToContentMap.get(revision);
}
项目:intellij-ce-playground    文件:ChangeList.java   
private ArrayList<Change> buildChanges() throws FilesTooBigForDiffException {
  Document base = getDocument(FragmentSide.SIDE1);
  DiffString[] baseLines = DiffUtil.convertToLines(base.getText());
  Document version = getDocument(FragmentSide.SIDE2);
  DiffString[] versionLines = DiffUtil.convertToLines(version.getText());
  DiffFragment[] fragments = ComparisonPolicy.DEFAULT.buildDiffFragmentsFromLines(baseLines, versionLines);
  final ArrayList<Change> result = new ArrayList<Change>();
  new DiffFragmentsEnumerator(fragments) {
    @Override
    protected void process(DiffFragment fragment) {
      if (fragment.isEqual()) return;
      Context context = getContext();
      TextRange range1 = context.createRange(FragmentSide.SIDE1);
      TextRange range2 = context.createRange(FragmentSide.SIDE2);
      result.add(new SimpleChange(ChangeType.fromDiffFragment(context.getFragment()), range1, range2, ChangeList.this));
    }
  }.execute();
  return result;
}
项目:intellij-ce-playground    文件:LineStatusTracker.java   
private List<Range> getNewChangedRanges(int changedLine1, int changedLine2, int vcsLine1, int vcsLine2)
  throws FilesTooBigForDiffException {

  if (changedLine1 == changedLine2 && vcsLine1 == vcsLine2) {
    return Collections.emptyList();
  }
  if (changedLine1 == changedLine2) {
    return Collections.singletonList(new Range(changedLine1, changedLine2, vcsLine1, vcsLine2));
  }
  if (vcsLine1 == vcsLine2) {
    return Collections.singletonList(new Range(changedLine1, changedLine2, vcsLine1, vcsLine2));
  }

  List<String> lines = new DocumentWrapper(myDocument).getLines(changedLine1, changedLine2 - 1);
  List<String> vcsLines = new DocumentWrapper(myVcsDocument).getLines(vcsLine1, vcsLine2 - 1);

  return new RangesBuilder(lines, vcsLines, changedLine1, vcsLine1, myMode).getRanges();
}
项目:intellij-ce-playground    文件:CorrectionTest.java   
public void testChangedSpaceCorrection() throws FilesTooBigForDiffException {
  DiffCorrection correction = new DiffCorrection.ChangedSpace(ComparisonPolicy.DEFAULT);
  DiffFragment[] fragments = correction.correct(new DiffFragment[]{
      new DiffFragment("x", "y"),
      new DiffFragment(" ", "   "),
      new DiffFragment("ab", "ab"),
      new DiffFragment(" ", " "),
      new DiffFragment(" ", " w o r d"),
      new DiffFragment("   ", " w o r d")});
  CHECK.compareAll(new DiffFragment[]{
    new DiffFragment("x", "y"),
    new DiffFragment(null, "  "), new DiffFragment(" ", " "),
    new DiffFragment("ab", "ab"),
    new DiffFragment(" ", " "),
    new DiffFragment(" ", " "), new DiffFragment(null, "w o r d"),
    new DiffFragment("  ", null), new DiffFragment(" ", " "), new DiffFragment(null, "w o r d")}, fragments);

  fragments = correction.correct(new DiffFragment[]{new DiffFragment("\n  ", "\n ")});
  CHECK.compareAll(new DiffFragment[]{new DiffFragment("\n", "\n"),
                                      new DiffFragment(" ", null), new DiffFragment(" ", " ")}, fragments);
  fragments = correction.correct(new DiffFragment[]{new DiffFragment("\n", "\n\n")});
  CHECK.compareAll(new DiffFragment[]{new DiffFragment("\n", "\n"), new DiffFragment(null, "\n")}, fragments);
}
项目:intellij-ce-playground    文件:CorrectionTest.java   
public void testConcatinateSingleSide() throws FilesTooBigForDiffException {
  DiffCorrection correction = new DiffCorrection.ConcatenateSingleSide();
  DiffFragment[] corrected = correction.correct(
      new DiffFragment[]{new DiffFragment(null, "a"),
                         new DiffFragment("b", null),
                         new DiffFragment("c", "d"),
                         new DiffFragment(null, "a"),
                         new DiffFragment("b", null),
                         new DiffFragment("1", null),
                         new DiffFragment("x", "x"),
                         new DiffFragment(null, "a")});
  CHECK.compareAll(new DiffFragment[]{new DiffFragment("b", "a"),
                                      new DiffFragment("c", "d"),
                                      new DiffFragment("b1", "a"),
                                      new DiffFragment("x", "x"), new DiffFragment(null, "a")},
                   corrected);
}
项目:intellij-ce-playground    文件:CorrectionTest.java   
public void testConnectSingleSideToChange() throws FilesTooBigForDiffException {
  DiffFragment first = DiffFragment.unchanged("a", "A");
  DiffFragment oneSide = new DiffFragment(null, "b");
  DiffFragment equal = new DiffFragment("c", "c");
  DiffFragment last = DiffFragment.unchanged("g", "G");
  DiffFragment[] fragments = DiffCorrection.ConnectSingleSideToChange.INSTANCE.correct(new DiffFragment[]{
    first,
    oneSide,
    equal,
    new DiffFragment(null, "d"), new DiffFragment("e", "E"), new DiffFragment("f", null),
    last
  });
  CHECK.compareAll(new DiffFragment[]{
    first, oneSide, equal,
    new DiffFragment("ef", "dE"),
    last
  }, fragments);
}
项目:intellij-ce-playground    文件:ChangesDiffCalculator.java   
public Collection<TextRange> calculateDiff(@NotNull final Document beforeDocument, @NotNull final Document currentDocument) {
  myNewMarkup.ranges.clear();
  myOldMarkup.document = beforeDocument;
  myNewMarkup.document = currentDocument;

  List<LineFragment> lineFragments;
  try {
    lineFragments = myCompareProcessor.process(beforeDocument.getText(), currentDocument.getText());
  }
  catch (FilesTooBigForDiffException e) {
    LOG.info(e);
    return Collections.emptyList();
  }

  final FragmentHighlighterImpl fragmentHighlighter = new FragmentHighlighterImpl(myOldMarkup, myNewMarkup);
  for (Iterator<LineFragment> iterator = lineFragments.iterator(); iterator.hasNext();) {
    LineFragment fragment = iterator.next();
    fragmentHighlighter.setIsLast(!iterator.hasNext());
    fragment.highlight(fragmentHighlighter);
  }

  return new ArrayList<TextRange>(myNewMarkup.ranges);
}
项目:intellij-ce-playground    文件:SelectedBlockHistoryTest.java   
private static void doTest(
  String[] beforePrevBlock,
  String[] prevBlock,
  String[] afterPrevBlock,
  String[] beforeBlock,
  String[] block,
  String[] afterBlock) throws FilesTooBigForDiffException {

  String[] prevVersion = composeVersion(beforePrevBlock, prevBlock, afterPrevBlock);
  String[] currentVersion = composeVersion(beforeBlock, block, afterBlock);
  FindBlock findBlock = new FindBlock(prevVersion,
      new Block(currentVersion, beforeBlock.length, beforeBlock.length + block.length - 1));

  Block actualBlock = findBlock.getBlockInThePrevVersion();
  Block expectedBlock = new Block(prevVersion,beforePrevBlock.length, beforePrevBlock.length + prevBlock.length - 1);

  assertEquals(expectedBlock, actualBlock);

}
项目:intellij-ce-playground    文件:TextCompareProcessor.java   
private ArrayList<LineFragment> findSubFragments(@NotNull DiffString text1, @NotNull DiffString text2) throws FilesTooBigForDiffException {
  DiffFragment[] fragments = new ByWord(myComparisonPolicy).buildFragments(text1, text2);
  fragments = DiffCorrection.ConnectSingleSideToChange.INSTANCE.correct(fragments);
  fragments = UniteSameType.INSTANCE.correct(fragments);
  fragments = PreferWholeLines.INSTANCE.correct(fragments);
  fragments = UniteSameType.INSTANCE.correct(fragments);
  DiffFragment[][] lines = Util.splitByUnchangedLines(fragments);
  lines = Util.uniteFormattingOnly(lines);

  LineFragmentsCollector collector = new LineFragmentsCollector();
  for (DiffFragment[] line : lines) {
    DiffFragment[][] subLines = LineBlockDivider.SINGLE_SIDE.divide(line);
    subLines = Util.uniteFormattingOnly(subLines);
    for (DiffFragment[] subLineFragments : subLines) {
      LineFragment subLine = collector.addDiffFragment(Util.concatenate(subLineFragments));
      if (!subLine.isOneSide()) {
        subLine.setChildren(processInlineFragments(subLineFragments));
      }
    }
  }
  return collector.getFragments();
}
项目:intellij-ce-playground    文件:DiffCorrection.java   
@Override
public void process(@NotNull DiffFragment fragment, @NotNull FragmentsCollector collector) throws FilesTooBigForDiffException {
  DiffString text1 = fragment.getText1();
  DiffString text2 = fragment.getText2();
  if (!fragment.isEqual()) {
    if (myComparisonPolicy.isEqual(fragment))
      fragment = myComparisonPolicy.createFragment(text1, text2);
    collector.add(fragment);
  } else {
    assert text1 != null;
    assert text2 != null;
    DiffString[] lines1 = text1.tokenize();
    DiffString[] lines2 = text2.tokenize();
    LOG.assertTrue(lines1.length == lines2.length);
    for (int i = 0; i < lines1.length; i++)
      collector.addAll(myDiffPolicy.buildFragments(lines1[i], lines2[i]));
  }
}
项目:intellij-ce-playground    文件:VcsHistoryDialog.java   
private void updateRevisionsList() throws VcsException {
  if (myIsInLoading) return;
  if (myChangesOnlyCheckBox.isSelected()) {
    loadContentsFor(myRevisions.toArray(new VcsFileRevision[myRevisions.size()]));
    try {
      ((ListTableModel)myList.getModel()).setItems(filteredRevisions());
    }
    catch (FilesTooBigForDiffException e) {
      myChangesOnlyCheckBox.setEnabled(false);
      myChangesOnlyCheckBox.setSelected(false);
      setErrorText(e.getMessage());
      ((ListTableModel)myList.getModel()).setItems(myRevisions);
    }
    ((ListTableModel)myList.getModel()).fireTableDataChanged();
    updateDiff(0, 0);

  }
  else {
    ((ListTableModel)myList.getModel()).setItems(myRevisions);
    ((ListTableModel)myList.getModel()).fireTableDataChanged();
  }

}
项目:intellij-ce-playground    文件:ByWord.java   
private void addPostfixes() throws FilesTooBigForDiffException {
  DiffString postfix1 = myVersion1.getCurrentWordPostfixAndOneMore();
  DiffString postfix2 = myVersion2.getCurrentWordPostfixAndOneMore();
  int length1 = postfix1.length();
  int length2 = postfix2.length();
  DiffFragment wholePostfix = myComparisonPolicy.createFragment(postfix1, postfix2);
  if (wholePostfix.isEqual()) {
    add(DiffFragment.unchanged(cutLast(postfix1, length1), cutLast(postfix2, length2)));
    return;
  }
  if (length1 > 0 || length2 > 0) {
    DiffFragment[] fragments = BY_CHAR.buildFragments(postfix1, postfix2);
    DiffFragment firstFragment = fragments[0];
    if (firstFragment.isEqual()) {
      final DiffString text1 = cutLast(firstFragment.getText1(), length1);
      final DiffString text2 = cutLast(firstFragment.getText2(), length2);
      add(myComparisonPolicy.createFragment(text1, text2));
      //add(firstFragment);
    }
  }
}
项目:intellij-ce-playground    文件:DocumentEventImpl.java   
public int translateLineViaDiff(int line) throws FilesTooBigForDiffException {
  Diff.Change change = reBuildDiffIfNeeded();
  if (change == null) return line;

  int newLine = line;

  while (change != null) {
    if (line < change.line0) break;
    if (line >= change.line0 + change.deleted) {
      newLine += change.inserted - change.deleted;
    }
    else {
      int delta = Math.min(change.inserted, line - change.line0);
      newLine = change.line1 + delta;
      break;
    }

    change = change.link;
  }

  return newLine;
}
项目:intellij-ce-playground    文件:DiffIterableUtil.java   
@NotNull
public static <T> FairDiffIterable diff(@NotNull T[] data1, @NotNull T[] data2, @NotNull ProgressIndicator indicator) {
  indicator.checkCanceled();

  try {
    // TODO: use ProgressIndicator inside
    Diff.Change change = Diff.buildChanges(data1, data2);
    return fair(create(change, data1.length, data2.length));
  }
  catch (FilesTooBigForDiffException e) {
    throw new DiffTooBigException();
  }
}
项目:intellij-ce-playground    文件:SelectionReverter.java   
protected void doRevert() throws IOException, FilesTooBigForDiffException {
  Block b = myCalculator.getSelectionFor(myLeftRevision, new Progress() {
    public void processed(int percentage) {
      // should be already processed.
    }
  });

  Document d = myGateway.getDocument(myRightEntry.getPath());

  int from = d.getLineStartOffset(myFromLine);
  int to = d.getLineEndOffset(myToLine);

  d.replaceString(from, to, b.getBlockContent());
}
项目:intellij-ce-playground    文件:SelectionDifferenceModel.java   
@Override
protected boolean isLeftContentAvailable(RevisionProcessingProgress p) {
  try {
    return myCalculator.canCalculateFor(myLeftRevision, p);
  }
  catch (FilesTooBigForDiffException e) {
    return false;
  }
}
项目:intellij-ce-playground    文件:SelectionDifferenceModel.java   
@Override
protected boolean isRightContentAvailable(RevisionProcessingProgress p) {
  try {
    return myCalculator.canCalculateFor(myRightRevision, p);
  }
  catch (FilesTooBigForDiffException e) {
    return false;
  }
}
项目:intellij-ce-playground    文件:SelectionDifferenceModel.java   
private String getContentOf(Revision r, RevisionProcessingProgress p) {
  try {
    return myCalculator.getSelectionFor(r, p).getBlockContent();
  }
  catch (FilesTooBigForDiffException e) {
    return "";
  }
}
项目:intellij-ce-playground    文件:FindBlock.java   
public Block getBlockInThePrevVersion() throws FilesTooBigForDiffException {

    Diff.Change change = Diff.buildChanges(myResult.getSource(), myCurrentVersion.getSource());
    while (change != null) {
      shiftIndices(change.line1, change.line1, change.line0);
      shiftIndices(change.line1, change.line1 + change.inserted, change.line0 + change.deleted);
      change = change.link;
    }

    if (myResult.getEnd() >= myResult.getSource().length){
      myResult.setEnd(myResult.getSource().length - 1);
    }

    return myResult;
  }
项目:intellij-ce-playground    文件:ModelDiff.java   
@Nullable
public static List<Cmd> createDiffCmds(@NotNull Model<Object> listModel, @NotNull Object[] oldElements, @NotNull Object[] newElements) {
  Diff.Change change = null;
  try {
    change = Diff.buildChanges(oldElements, newElements);
  }
  catch (FilesTooBigForDiffException e) {
    // should not occur
  }

  if (change == null) {
    return null;
  }

  List<Cmd> commands = new ArrayList<Cmd>();
  int inserted = 0;
  int deleted = 0;
  while (change != null) {
    if (change.deleted > 0) {
      final int start = change.line0 + inserted - deleted;
      commands.add(new RemoveCmd<Object>(listModel, start, start + change.deleted - 1));
    }

    if (change.inserted > 0) {
      for (int i = 0; i < change.inserted; i++) {
        commands.add(new InsertCmd<Object>(listModel, change.line0 + i + inserted - deleted, newElements[change.line1 + i]));
      }
    }

    deleted += change.deleted;
    inserted += change.inserted;
    change = change.link;
  }
  return commands;
}
项目:intellij-ce-playground    文件:PresetBlocksDiffPolicy.java   
@NotNull
@Override
public DiffFragment[] buildFragments(@NotNull DiffString text1, @NotNull DiffString text2) throws FilesTooBigForDiffException {
  final List<DiffFragment> fragments = new ArrayList<DiffFragment>();
  for (int i = 0; i < myRanges.size(); i++) {
    final BeforeAfter<TextRange> range = myRanges.get(i);
    fragments.addAll(Arrays.asList(myDelegate.buildFragments(
      text1.substring(range.getBefore().getStartOffset(), range.getBefore().getEndOffset()).copy(),
      text2.substring(range.getAfter().getStartOffset(), range.getAfter().getEndOffset()).copy())));
  }

  return fragments.toArray(new DiffFragment[fragments.size()]);
}
项目:intellij-ce-playground    文件:ChangeList.java   
public static ChangeList build(@NotNull Document base, @NotNull Document version, @NotNull Project project) throws FilesTooBigForDiffException {
  ChangeList result = new ChangeList(base, version, project);
  ArrayList<Change> changes = result.buildChanges();
  Collections.sort(changes, CHANGE_ORDER);
  result.setChanges(changes);
  return result;
}
项目:intellij-ce-playground    文件:MergeList.java   
@NotNull
private static List<MergeFragment> processText(@NotNull String leftText,
                                               @NotNull String baseText,
                                               @NotNull String rightText,
                                               @NotNull ContextLogger logger) throws FilesTooBigForDiffException {
  DiffFragment[] leftFragments = DiffPolicy.DEFAULT_LINES.buildFragments(DiffString.create(baseText), DiffString.create(leftText));
  DiffFragment[] rightFragments = DiffPolicy.DEFAULT_LINES.buildFragments(DiffString.create(baseText), DiffString.create(rightText));
  int[] leftOffsets = {0, 0};
  int[] rightOffsets = {0, 0};
  int leftIndex = 0;
  int rightIndex = 0;
  MergeBuilder builder = new MergeBuilder(logger);
  while (leftIndex < leftFragments.length || rightIndex < rightFragments.length) {
    FragmentSide side;
    TextRange[] equalRanges = new TextRange[2];
    if (leftOffsets[0] < rightOffsets[0] && leftIndex < leftFragments.length) {
      side = FragmentSide.SIDE1;
      getEqualRanges(leftFragments[leftIndex], leftOffsets, equalRanges);
      leftIndex++;
    } else if (rightIndex < rightFragments.length) {
      side = FragmentSide.SIDE2;
      getEqualRanges(rightFragments[rightIndex], rightOffsets, equalRanges);
      rightIndex++;
    } else break;
    if (equalRanges[0] != null && equalRanges[1] != null) builder.add(equalRanges[0], equalRanges[1], side);
    else logger.assertTrue(equalRanges[0] == null && equalRanges[1] == null);
  }
  return builder.finish(leftText.length(), baseText.length(), rightText.length());
}
项目:intellij-ce-playground    文件:CorrectionTest.java   
public void testTrueLineBlock() throws FilesTooBigForDiffException {
  DiffCorrection.TrueLineBlocks correction = new DiffCorrection.TrueLineBlocks(ComparisonPolicy.DEFAULT);
  DiffFragment[] fragments = correction.correctAndNormalize(new DiffFragment[]{
    DiffFragment.unchanged(" 1\n  ab\n x\n", "  2\n ab\n x\n"),
    new DiffFragment("XXX\n111\n", "YYY\n222\n"),
    DiffFragment.unchanged(" a\n", "  a\n")});
  CHECK.compareAll(new DiffFragment[]{new DiffFragment(" 1\n", "  2\n"),
                                      new DiffFragment("  ab\n", " ab\n"),
                                      new DiffFragment(" x\n", " x\n"),
                                      new DiffFragment("XXX\n111\n", "YYY\n222\n"),
                                      new DiffFragment(" a\n", "  a\n")},
                   fragments);
}
项目:intellij-ce-playground    文件:CorrectionTest.java   
public void testTrueLineBlocksWithSameLines() throws FilesTooBigForDiffException {
  DiffCorrection.TrueLineBlocks correction = new DiffCorrection.TrueLineBlocks(ComparisonPolicy.DEFAULT);
  DiffFragment[] fragments = correction.correctAndNormalize(new DiffFragment[]{
    DiffFragment.unchanged(" X\n  X\n  X", "  X\n X\n  X")});
  CHECK.compareAll(new DiffFragment[]{new DiffFragment(" X\n  X\n", "  X\n X\n"),
                                      new DiffFragment("  X", "  X")},
                   fragments);
}
项目:intellij-ce-playground    文件:ByWordTest.java   
public void test1() throws FilesTooBigForDiffException {
  DiffPolicy byWord = new ByWord(ComparisonPolicy.DEFAULT);
  DiffFragment[] fragments = byWord.buildFragments("abc def, 123", "ab def, 12");
  CHECK.compareAll(new DiffFragment[]{new DiffFragment("abc", "ab"),
                                      new DiffFragment(" def, ", " def, "),
                                      new DiffFragment("123", "12")}, fragments);
}
项目:intellij-ce-playground    文件:ByWordTest.java   
public void test2() throws FilesTooBigForDiffException {
  DiffPolicy byWord = new ByWord(ComparisonPolicy.DEFAULT);
  DiffFragment[] fragments = byWord.buildFragments(" a[xy]+1", ",a[]+1");
  CHECK.compareAll(new DiffFragment[]{new DiffFragment(" ", null),
                                      new DiffFragment(null, ","),
                                      new DiffFragment("a[", "a["),
                                      new DiffFragment("xy", null),
                                      new DiffFragment("]+1", "]+1")}, fragments);
}
项目:intellij-ce-playground    文件:ByWordTest.java   
public void test4() throws FilesTooBigForDiffException {
  DiffPolicy byWord = new ByWord(ComparisonPolicy.DEFAULT);
  DiffFragment[] fragments = byWord.buildFragments("  abc\n2222\n", "    x = abc\nzzzz\n");
  CHECK.compareAll(new DiffFragment[]{
    new DiffFragment(null, "  "), new DiffFragment("  ", "  "), new DiffFragment(null, "x"), new DiffFragment(null, " ="),
    new DiffFragment(null, " "),
    new DiffFragment("abc\n", "abc\n"),
    new DiffFragment("2222", "zzzz"),
    new DiffFragment("\n", "\n")}, fragments);
}
项目:intellij-ce-playground    文件:ByWordTest.java   
public void testIdea58505() throws FilesTooBigForDiffException {
  DiffPolicy byWord = new ByWord(ComparisonPolicy.DEFAULT);
  DiffFragment[] fragments = byWord.buildFragments("   if (eventMerger!=null && !dataSelection.getValueIsAdjusting()) {",
                                                   "   if (eventMerger!=null && (dataSelection==null || !dataSelection.getValueIsAdjusting())) {");
  CHECK.compareAll(new DiffFragment[] {
    new DiffFragment("   if (eventMerger!=null && ", "   if (eventMerger!=null && "),
    new DiffFragment("!", "("),
    new DiffFragment("dataSelection", "dataSelection"),
    new DiffFragment(null, "=="),
    new DiffFragment(null, "null || !dataSelection"),
    new DiffFragment(".getValueIsAdjusting())", ".getValueIsAdjusting())"),
    new DiffFragment(null, ")"),
    new DiffFragment(" {", " {")
  }, fragments);
}
项目:intellij-ce-playground    文件:ByWordTest.java   
public void testIdea58505Trim() throws FilesTooBigForDiffException {
  DiffPolicy byWord = new ByWord(ComparisonPolicy.TRIM_SPACE);
  DiffFragment[] fragments = byWord.buildFragments("   if (eventMerger!=null && !dataSelection.getValueIsAdjusting()) {",
                                                   "   if (eventMerger!=null && (dataSelection==null || !dataSelection.getValueIsAdjusting())) {");
  CHECK.compareAll(new DiffFragment[] {
    new DiffFragment("   if (eventMerger!=null && ", "   if (eventMerger!=null && "),
    new DiffFragment("!", "("),
    new DiffFragment("dataSelection", "dataSelection"),
    new DiffFragment(null, "=="),
    new DiffFragment(null, "null || !dataSelection"),
    new DiffFragment(".getValueIsAdjusting())", ".getValueIsAdjusting())"),
    new DiffFragment(null, ")"),
    new DiffFragment(" {", " {")
  }, fragments);
}
项目:intellij-ce-playground    文件:ByWordTest.java   
public void testIdea56428() throws FilesTooBigForDiffException {
  DiffPolicy byWord = new ByWord(ComparisonPolicy.DEFAULT);
  DiffFragment[] fragments = byWord.buildFragments("messageInsertStatement = connection.prepareStatement(\"INSERT INTO AUDIT (AUDIT_TYPE_ID, STATUS, SERVER_ID, INSTANCE_ID, REQUEST_ID) VALUES (?, ?, ?, ?, ?)\");\n",
                                                   "messageInsertStatement = connection.prepareStatement(\"INSERT INTO AUDIT (AUDIT_TYPE_ID, CREATION_TIMESTAMP, STATUS, SERVER_ID, INSTANCE_ID, REQUEST_ID) VALUES (?, ?, ?, ?, ?, ?)\");\n");
  CHECK.compareAll(new DiffFragment[] {
    new DiffFragment("messageInsertStatement = connection.prepareStatement(\"INSERT INTO AUDIT (AUDIT_TYPE_ID, ", "messageInsertStatement = connection.prepareStatement(\"INSERT INTO AUDIT (AUDIT_TYPE_ID, "),
    new DiffFragment(null, "CREATION_TIMESTAMP"),
    new DiffFragment(null, ","),
    new DiffFragment(null, " "),
    new DiffFragment("STATUS, SERVER_ID, INSTANCE_ID, REQUEST_ID) VALUES (?, ?, ?, ?, ?", "STATUS, SERVER_ID, INSTANCE_ID, REQUEST_ID) VALUES (?, ?, ?, ?, ?"),
    new DiffFragment(null, ", ?"),
    new DiffFragment(")\");\n", ")\");\n"),
  }, fragments);
}
项目:intellij-ce-playground    文件:ByWordTest.java   
public void testLeadingFormatting() throws FilesTooBigForDiffException {
  DiffPolicy byWord = new ByWord(ComparisonPolicy.DEFAULT);
  DiffFragment[] fragments = byWord.buildFragments(" abc\n 123", " 123");
  CHECK.compareAll(new DiffFragment[]{new DiffFragment(" abc\n", null),
                                      new DiffFragment(" 123", " 123")},
                   UniteSameType.INSTANCE.correct(fragments));
}
项目:intellij-ce-playground    文件:ByWordTest.java   
public void testRestyleNewLines() throws FilesTooBigForDiffException {
  DiffPolicy byWord = new ByWord(ComparisonPolicy.DEFAULT);
  DiffFragment[] fragments = byWord.buildFragments("f(a, b);", "f(a,\n  b);");
  CHECK.compareAll(new DiffFragment[]{new DiffFragment("f(a,", "f(a,"),
                                      new DiffFragment(" ", "\n  "),
                                      new DiffFragment("b);", "b);")},
                   UniteSameType.INSTANCE.correct(fragments));
}
项目:intellij-ce-playground    文件:RearrangeCodeProcessor.java   
@NotNull
@Override
protected FutureTask<Boolean> prepareTask(@NotNull final PsiFile file, final boolean processChangedTextOnly) {
  return new FutureTask<Boolean>(new Callable<Boolean>() {
    @Override
    public Boolean call() throws Exception {
      try {
        Collection<TextRange> ranges = getRangesToFormat(file, processChangedTextOnly);
        Document document = PsiDocumentManager.getInstance(myProject).getDocument(file);

        if (document != null && Rearranger.EXTENSION.forLanguage(file.getLanguage()) != null) {
          PsiDocumentManager.getInstance(myProject).doPostponedOperationsAndUnblockDocument(document);
          PsiDocumentManager.getInstance(myProject).commitDocument(document);
          Runnable command = prepareRearrangeCommand(file, ranges);
          try {
            CommandProcessor.getInstance().executeCommand(myProject, command, COMMAND_NAME, null);
          }
          finally {
            PsiDocumentManager.getInstance(myProject).commitDocument(document);
          }
        }

        return true;
      }
      catch (FilesTooBigForDiffException e) {
        handleFileTooBigException(LOG, e, file);
        return false;
      }
    }
  });
}
项目:intellij-ce-playground    文件:AbstractLayoutCodeProcessor.java   
protected void handleFileTooBigException(Logger logger, FilesTooBigForDiffException e, @NotNull PsiFile file) {
  logger.info("Error while calculating changed ranges for: " + file.getVirtualFile(), e);
  if (!ApplicationManager.getApplication().isUnitTestMode()) {
    Notification notification = new Notification(ApplicationBundle.message("reformat.changed.text.file.too.big.notification.groupId"),
                                                 ApplicationBundle.message("reformat.changed.text.file.too.big.notification.title"),
                                                 ApplicationBundle.message("reformat.changed.text.file.too.big.notification.text", file.getName()),
                                                 NotificationType.INFORMATION);
    notification.notify(file.getProject());
  }
}
项目:intellij-ce-playground    文件:UniteSameTypeTest.java   
public void testUnitDifferentOnesides() throws FilesTooBigForDiffException {
  DiffFragment[] fragments = UniteSameType.INSTANCE.correct(new DiffFragment[]{new DiffFragment("a", "b"),
                                                      new DiffFragment(null, " "),
                                                      new DiffFragment("\n ", null),
                                                      new DiffFragment("x", "x")});
  CHECK.compareAll(new DiffFragment[]{new DiffFragment("a\n ", "b "), new DiffFragment("x", "x")}, fragments);
}
项目:intellij-ce-playground    文件:UniteSameTypeTest.java   
public void testUniteEqualsUnitesFormattingOnly() throws FilesTooBigForDiffException {
  DiffFragment changed = new DiffFragment("abc", "123");
  DiffFragment equal = new DiffFragment("qqq", "qqq");
  DiffFragment[] fragments = DiffCorrection.UnitEquals.INSTANCE.correct(new DiffFragment[]{
    changed,
    new DiffFragment(" xxx", "xxx"), new DiffFragment("yyy", "  yyy"),
    equal});
  CHECK.compareAll(new DiffFragment[]{changed, new DiffFragment(" xxxyyy", "xxx  yyy"), equal}, fragments);
}