當前位置: 首頁>>代碼示例>>Java>>正文


Java FragmentSide類代碼示例

本文整理匯總了Java中com.intellij.openapi.diff.impl.highlighting.FragmentSide的典型用法代碼示例。如果您正苦於以下問題:Java FragmentSide類的具體用法?Java FragmentSide怎麽用?Java FragmentSide使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FragmentSide類屬於com.intellij.openapi.diff.impl.highlighting包,在下文中一共展示了FragmentSide類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getBeginnings

import com.intellij.openapi.diff.impl.highlighting.FragmentSide; //導入依賴的package包/類
/**
 * Get beginnings of the changes from the specified side.
 * @param side          Side of the changes.
 * @param unappliedOnly If true - only unapplied changes will be considered, if false - all changes (both applied and not applied).
 */
public int[] getBeginnings(FragmentSide side, boolean unappliedOnly) {
  List<Integer> result = new ArrayList<Integer>(myDiffs.size());
  int previousBeginning = Integer.MIN_VALUE;

  for (Diff diff : myDiffs) {
    if (!unappliedOnly || !diff.getDiffType().isApplied()) {
      Interval interval = diff.getInterval(side);
      int start = interval.getStart();
      if (start != previousBeginning) result.add(start);
      previousBeginning = start;
    }
  }

  return ArrayUtil.toIntArray(result);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:LineBlocks.java

示例2: fromChanges

import com.intellij.openapi.diff.impl.highlighting.FragmentSide; //導入依賴的package包/類
@NotNull
public static LineBlocks fromChanges(@NotNull List<Change> changes) {
  // changes may come mixed, need to sort them to get correct intervals
  Collections.sort(changes, ChangeList.CHANGE_ORDER);

  List<Diff> diffs = new ArrayList<Diff>(changes.size());
  for (Change change : changes) {
    if (!change.isValid()) { continue; }
    int start1 = change.getChangeSide(FragmentSide.SIDE1).getStartLine();
    int end1 = change.getChangeSide(FragmentSide.SIDE1).getEndLine();
    Interval interval1 = Interval.fromTo(start1, end1);

    int start2 = change.getChangeSide(FragmentSide.SIDE2).getStartLine();
    int end2 = change.getChangeSide(FragmentSide.SIDE2).getEndLine();
    Interval interval2 = Interval.fromTo(start2, end2);

    diffs.add(new Diff(interval1, interval2, change.getType().getTypeKey()));
  }
  return new LineBlocks(diffs);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:LineBlocks.java

示例3: createVisiblePolygons

import com.intellij.openapi.diff.impl.highlighting.FragmentSide; //導入依賴的package包/類
public static ArrayList<DividerPolygon> createVisiblePolygons(@NotNull EditingSides sides,
                                                              @NotNull FragmentSide left,
                                                              int diffDividerPolygonsOffset) {
  Editor editor1 = sides.getEditor(left);
  Editor editor2 = sides.getEditor(left.otherSide());
  LineBlocks lineBlocks = sides.getLineBlocks();
  Trapezium visibleArea = new Trapezium(getVisibleInterval(editor1),
                                        getVisibleInterval(editor2));
  Interval indices = lineBlocks.getVisibleIndices(visibleArea);
  Transformation[] transformations = new Transformation[]{getTransformation(editor1),
    getTransformation(editor2)};
  ArrayList<DividerPolygon> polygons = new ArrayList<DividerPolygon>();
  for (int i = indices.getStart(); i < indices.getEnd(); i++) {
    Trapezium trapezium = lineBlocks.getTrapezium(i);
    final TextDiffType type = lineBlocks.getType(i);
    Color color = type.getPolygonColor(editor1);
    polygons.add(createPolygon(transformations, trapezium, color, left, diffDividerPolygonsOffset, type.isApplied()));
  }
  return polygons;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:DividerPolygon.java

示例4: createPolygon

import com.intellij.openapi.diff.impl.highlighting.FragmentSide; //導入依賴的package包/類
private static DividerPolygon createPolygon(@NotNull Transformation[] transformations,
                                            @NotNull Trapezium trapezium,
                                            @Nullable Color color,
                                            @NotNull FragmentSide left,
                                            int diffDividerPolygonsOffset, boolean applied) {
  Interval base1 = trapezium.getBase(left);
  Interval base2 = trapezium.getBase(left.otherSide());
  Transformation leftTransform = transformations[left.getIndex()];
  Transformation rightTransform = transformations[left.otherSide().getIndex()];
  int start1 = leftTransform.transform(base1.getStart());
  int end1 = leftTransform.transform(base1.getEnd());
  int start2 = rightTransform.transform(base2.getStart());
  int end2 = rightTransform.transform(base2.getEnd());
  return new DividerPolygon(start1 - diffDividerPolygonsOffset, start2 - diffDividerPolygonsOffset,
                            end1 - diffDividerPolygonsOffset, end2 - diffDividerPolygonsOffset,
                            color, applied);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:DividerPolygon.java

示例5: covertSequentialOneSideToChange

import com.intellij.openapi.diff.impl.highlighting.FragmentSide; //導入依賴的package包/類
@NotNull
  private static DiffFragment[] covertSequentialOneSideToChange(@NotNull DiffFragment[] fragments) {
    if (fragments.length < 2) return fragments;
    DiffCorrection.FragmentsCollector collector = new DiffCorrection.FragmentsCollector();
//    DiffFragment previous = fragments[0];
    DiffFragment previous = null;
    for (int i = 0; i < fragments.length; i++) {
      DiffFragment fragment = fragments[i];
      if (fragment.isOneSide()) {
        if (previous == null) previous = fragment;
        else {
          FragmentSide side = FragmentSide.chooseSide(fragment);
          DiffString previousText = side.getText(previous);
          if (previousText == null) previousText = DiffString.EMPTY;
          previous = side.createFragment(DiffString.concatenateNullable(previousText, side.getText(fragment)),
                                         side.getOtherText(previous), true);
        }
      } else {
        if (previous != null) collector.add(previous);
        previous = null;
        collector.add(fragment);
      }
    }
    if (previous != null) collector.add(previous);
    return collector.toArray();
  }
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:27,代碼來源:UniteSameType.java

示例6: buildChanges

import com.intellij.openapi.diff.impl.highlighting.FragmentSide; //導入依賴的package包/類
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;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:ChangeList.java

示例7: getData

import com.intellij.openapi.diff.impl.highlighting.FragmentSide; //導入依賴的package包/類
public Object getData(String dataId) {
  if (FocusDiffSide.DATA_KEY.is(dataId)) {
    int index = getFocusedEditorIndex();
    if (index < 0) return null;
    switch (index) {
      case 0:
        return new BranchFocusedSide(FragmentSide.SIDE1);
      case 1:
        return new MergeFocusedSide();
      case 2:
        return new BranchFocusedSide(FragmentSide.SIDE2);
    }
  }
  else if (PlatformDataKeys.DIFF_VIEWER.is(dataId)) return MergePanel2.this;
  return super.getData(dataId);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:MergePanel2.java

示例8: testLineNumberTransformation

import com.intellij.openapi.diff.impl.highlighting.FragmentSide; //導入依賴的package包/類
public void testLineNumberTransformation() {
  LineBlocks lineBlocks = LineBlocks.createLineBlocks(new LineBlock[]{
      new LineBlock(2, 2, 2, 2, null),
      new LineBlock(6, 1, 6, 2, null),
      new LineBlock(8, 2, 9, 0, null)});

  checkLeftRight(lineBlocks, 0, 0);
  checkLeftRight(lineBlocks, 3, 3);
  checkLeftRight(lineBlocks, 5, 5);
  checkLeftRight(lineBlocks, 6, 6);
  assertEquals(6, lineBlocks.transform(FragmentSide.SIDE2, 7));
  checkLeftRight(lineBlocks, 7, 8);
  checkLeftRight(lineBlocks, 8, 9);
  assertEquals(9, lineBlocks.transform(FragmentSide.SIDE1, 9));
  assertEquals(9, lineBlocks.transform(FragmentSide.SIDE1, 10));
  checkLeftRight(lineBlocks, 11, 10);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:LineBlocksTest.java

示例9: mostSensible

import com.intellij.openapi.diff.impl.highlighting.FragmentSide; //導入依賴的package包/類
@Nullable
public static Operation mostSensible(Document document, Document otherDocument, TextRange range, TextRange otherRange, FragmentSide base) {
  if (!canMakeWritable(document) && !canMakeWritable(otherDocument)) return null;
  if (range.getLength() != 0) {
    if (canMakeWritable(otherDocument))
      return otherRange.getLength() != 0 ?
             replaceOperation(range, otherRange, document, otherDocument, base) :
             insertOperation(range, otherRange.getEndOffset(), document, otherDocument, base);
    else return otherRange.getLength() == 0 ? removeOperation(range, document) : null;
  }
  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:13,代碼來源:MergeOperations.java

示例10: addModifyActions

import com.intellij.openapi.diff.impl.highlighting.FragmentSide; //導入依賴的package包/類
private static void addModifyActions(final LineFragment fragment, DiffMarkup wrapper, DiffMarkup otherWrapper) {
  if (fragment.isEqual()) return;
  if (fragment.isHasLineChildren()) return;
  FragmentSide side = wrapper.getSide();
  TextRange range = fragment.getRange(side);
  TextRange otherRange = fragment.getRange(side.otherSide());
  Document document = wrapper.getDocument();
  Document otherDocument = otherWrapper.getDocument();
  wrapper.addAction(MergeOperations.mostSensible(document, otherDocument, range, otherRange, side), range.getStartOffset());
  otherWrapper.addAction(MergeOperations.mostSensible(otherDocument, document, otherRange, range, side.otherSide()), otherRange.getStartOffset());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:12,代碼來源:FragmentHighlighterImpl.java

示例11: actionPerformed

import com.intellij.openapi.diff.impl.highlighting.FragmentSide; //導入依賴的package包/類
@Override
public void actionPerformed(AnActionEvent e) {
  int currentLogicalLineIdx = getCurrentLogicalLineIdx(true);
  int nextLineIdx = currentLogicalLineIdx == myLeftLines.size() - 1 ? currentLogicalLineIdx : currentLogicalLineIdx + 1;

  DiffPanelImpl panel = (DiffPanelImpl) getCurrentPanel();
  panel.getSideView(FragmentSide.SIDE1).scrollToFirstDiff(myLeftLines.get(nextLineIdx));
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:9,代碼來源:ChangesFragmentedDiffPanel.java

示例12: getIntervals

import com.intellij.openapi.diff.impl.highlighting.FragmentSide; //導入依賴的package包/類
public Interval[] getIntervals(FragmentSide side) {
  Interval[] intervals = new Interval[myDiffs.size()];
  for (int i = 0; i < intervals.length; i++) {
    intervals[i] = myDiffs.get(i).getInterval(side);
  }
  return intervals;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:8,代碼來源:LineBlocks.java

示例13: transform

import com.intellij.openapi.diff.impl.highlighting.FragmentSide; //導入依賴的package包/類
private int transform(int location, Interval[] domain, Interval[] range) {
  if (domain.length == 0) {
    if (range.length != 0) {
      LOG.error("" + range.length);
    }
    return location;
  }
  int count = getIntervals(FragmentSide.SIDE1).length;
  LOG.assertTrue(count == getIntervals(FragmentSide.SIDE2).length);
  int index = getMaxStartedIndex(domain, location);
  Interval leftInterval;
  Interval rightInterval;
  if (index == 0) {
    if (domain[0].contains(location)) {
      leftInterval = domain[0];
      rightInterval = range[0];
    } else {
      leftInterval = Interval.fromTo(0, domain[0].getStart());
      rightInterval = Interval.fromTo(0, range[0].getStart());
    }
  } else if (index == count) {
    leftInterval = Interval.toInf(domain[count - 1].getEnd());
    rightInterval = Interval.toInf(range[count - 1].getEnd());
  } else {
    if (domain[index].contains(location)) {
      leftInterval = domain[index];
      rightInterval = range[index];
    } else {
      leftInterval = Interval.fromTo(domain[index - 1].getEnd(), domain[index].getStart());
      rightInterval = Interval.fromTo(range[index - 1].getEnd(), range[index].getStart());
    }
  }
  return LinearTransformation.oneToOne(location, leftInterval.getStart(), rightInterval);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:35,代碼來源:LineBlocks.java

示例14: add

import com.intellij.openapi.diff.impl.highlighting.FragmentSide; //導入依賴的package包/類
public void add(@NotNull TextRange base, @NotNull TextRange version, @NotNull FragmentSide side) {
  int index = side.getIndex();
  int otherIndex = side.otherSide().getIndex();
  EqualPair pair = new EqualPair(base, version, side);

  LOG.assertTrue(myPairs[index] == null || pair.getBaseStart() - myPairs[index].getBaseEnd() >= 0); // '==' can be in case of insertion
  LOG.assertTrue(myPairs[otherIndex] == null || pair.getBaseStart() >= myPairs[otherIndex].getBaseStart());

  myPairs[index] = pair;
  if (myPairs[otherIndex] != null && myPairs[index].getBaseStart() >= myPairs[otherIndex].getBaseEnd()) myPairs[otherIndex] = null;

  process();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:MergeBuilder.java

示例15: process

import com.intellij.openapi.diff.impl.highlighting.FragmentSide; //導入依賴的package包/類
public List<LineFragment> process(@Nullable String text1, @Nullable String text2) throws FilesTooBigForDiffException {
  if (myHighlightMode == HighlightMode.NO_HIGHLIGHTING) {
    return Collections.emptyList();
  }

  text1 = StringUtil.notNullize(text1);
  text2 = StringUtil.notNullize(text2);
  if (text1.isEmpty() || text2.isEmpty()) {
    return new DummyDiffFragmentsProcessor().process(text1, text2);
  }

  DiffString diffText1 = DiffString.create(text1);
  DiffString diffText2 = DiffString.create(text2);

  DiffFragment[] woFormattingBlocks = myDiffPolicy.buildFragments(diffText1, diffText2);
  DiffFragment[] step1lineFragments = new DiffCorrection.TrueLineBlocks(myComparisonPolicy).correctAndNormalize(woFormattingBlocks);
  ArrayList<LineFragment> lineBlocks = new DiffFragmentsProcessor().process(step1lineFragments);

  int badLinesCount = 0;
  if (myHighlightMode == HighlightMode.BY_WORD) {
    for (LineFragment lineBlock : lineBlocks) {
      if (lineBlock.isOneSide() || lineBlock.isEqual()) continue;
      try {
        DiffString subText1 = lineBlock.getText(diffText1, FragmentSide.SIDE1);
        DiffString subText2 = lineBlock.getText(diffText2, FragmentSide.SIDE2);
        ArrayList<LineFragment> subFragments = findSubFragments(subText1, subText2);
        lineBlock.setChildren(new ArrayList<Fragment>(subFragments));
        lineBlock.adjustTypeFromChildrenTypes();
      }
      catch (FilesTooBigForDiffException ignore) {
        // If we can't by-word compare two lines - this is not a reason to break entire diff.
        badLinesCount++;
        if (badLinesCount > FilesTooBigForDiffException.MAX_BAD_LINES) break;
      }
    }
  }
  return lineBlocks;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:39,代碼來源:TextCompareProcessor.java


注:本文中的com.intellij.openapi.diff.impl.highlighting.FragmentSide類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。