本文整理汇总了Java中com.intellij.openapi.diff.ex.DiffFragment.isEqual方法的典型用法代码示例。如果您正苦于以下问题:Java DiffFragment.isEqual方法的具体用法?Java DiffFragment.isEqual怎么用?Java DiffFragment.isEqual使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.diff.ex.DiffFragment
的用法示例。
在下文中一共展示了DiffFragment.isEqual方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: add
import com.intellij.openapi.diff.ex.DiffFragment; //导入方法依赖的package包/类
private void add(@NotNull DiffFragment fragment) {
DiffString text1 = fragment.getText1();
DiffString text2 = fragment.getText2();
if (text1 != null) myVersion1.addOffset(text1.length());
if (text2 != null) myVersion2.addOffset(text2.length());
if (fragment.isEqual() && !myFragments.isEmpty()) {
int lastIndex = myFragments.size() - 1;
DiffFragment prevFragment = myFragments.get(lastIndex);
if (prevFragment.isEqual()) {
prevFragment.appendText1(text1);
prevFragment.appendText2(text2);
return;
}
}
myFragments.add(fragment);
}
示例2: addPostfixes
import com.intellij.openapi.diff.ex.DiffFragment; //导入方法依赖的package包/类
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);
}
}
}
示例3: concatenate
import com.intellij.openapi.diff.ex.DiffFragment; //导入方法依赖的package包/类
@NotNull
public static DiffFragment concatenate(@NotNull DiffFragment[] line, int from, int to) {
DiffString[] data1 = new DiffString[to - from];
DiffString[] data2 = new DiffString[to - from];
boolean isEqual = true;
for (int i = 0; i < to - from; i++) {
DiffFragment fragment = line[from + i];
isEqual &= fragment.isEqual();
data1[i] = fragment.getText1();
data2[i] = fragment.getText2();
}
DiffString text1 = notEmptyContent(DiffString.concatenate(data1));
DiffString text2 = notEmptyContent(DiffString.concatenate(data2));
return isEqual ? DiffFragment.unchanged(text1, text2) : new DiffFragment(text1, text2);
}
示例4: process
import com.intellij.openapi.diff.ex.DiffFragment; //导入方法依赖的package包/类
@Override
public void process(@NotNull DiffFragment fragment, @NotNull DiffCorrection.FragmentsCollector collector) {
if (fragment.isEqual()) {
collector.add(fragment);
return;
}
if (fragment.isOneSide()) {
FragmentSide side = FragmentSide.chooseSide(fragment);
DiffString text = side.getText(fragment);
if (StringUtil.isEmptyOrSpaces(text)) {
collector.add(side.createFragment(text, DiffString.EMPTY, false));
return;
}
}
collector.add(fragment);
}
示例5: getEqualRanges
import com.intellij.openapi.diff.ex.DiffFragment; //导入方法依赖的package包/类
private static void getEqualRanges(@NotNull DiffFragment fragment, @NotNull int[] leftOffsets, @NotNull TextRange[] equalRanges) {
int baseLength = getTextLength(fragment.getText1());
int versionLength = getTextLength(fragment.getText2());
if (fragment.isEqual()) {
equalRanges[0] = new TextRange(leftOffsets[0], leftOffsets[0] + baseLength);
equalRanges[1] = new TextRange(leftOffsets[1], leftOffsets[1] + versionLength);
} else {
equalRanges[0] = null;
equalRanges[1] = null;
}
leftOffsets[0] += baseLength;
leftOffsets[1] += versionLength;
}
示例6: process
import com.intellij.openapi.diff.ex.DiffFragment; //导入方法依赖的package包/类
@Override
public void process(@NotNull DiffFragment fragment, @NotNull FragmentBuffer buffer) {
if (fragment.isEqual()) buffer.add(fragment);
else if (fragment.isOneSide()) {
DiffString text = FragmentSide.chooseSide(fragment).getText(fragment);
if (StringUtil.endsWithChar(text, '\n'))
buffer.add(fragment);
else
buffer.markIfNone(CHANGE);
} else buffer.markIfNone(CHANGE);
}
示例7: unite
import com.intellij.openapi.diff.ex.DiffFragment; //导入方法依赖的package包/类
@NotNull
public static DiffFragment unite(@NotNull DiffFragment fragment1, @NotNull DiffFragment fragment2) {
LOG.assertTrue(isSameType(fragment1, fragment2));
if (!fragment1.isOneSide()) {
DiffString unitedText1 = DiffString.concatenateNullable(fragment1.getText1(), fragment2.getText1());
DiffString unitedText2 = DiffString.concatenateNullable(fragment1.getText2(), fragment2.getText2());
LOG.assertTrue(fragment1.isEqual() == fragment2.isEqual());
return fragment1.isEqual() ? DiffFragment.unchanged(unitedText1, unitedText2) :
new DiffFragment(unitedText1, unitedText2);
}
FragmentSide side = FragmentSide.chooseSide(fragment1);
return side
.createFragment(DiffString.concatenateNullable(side.getText(fragment1), side.getText(fragment2)), null, fragment1.isModified());
}
示例8: isSameType
import com.intellij.openapi.diff.ex.DiffFragment; //导入方法依赖的package包/类
public static boolean isSameType(@NotNull DiffFragment fragment1, @NotNull DiffFragment fragment2) {
if (fragment1.isEqual()) return fragment2.isEqual();
if (fragment1.isChange()) return fragment2.isChange();
if (fragment1.getText1() == null) return fragment2.getText1() == null;
if (fragment1.getText2() == null) return fragment2.getText2() == null;
LOG.assertTrue(false);
return false;
}
示例9: areEqualOrFormatting
import com.intellij.openapi.diff.ex.DiffFragment; //导入方法依赖的package包/类
private static boolean areEqualOrFormatting(@NotNull DiffFragment[] fragments) {
for (int i = 0; i < fragments.length; i++) {
DiffFragment fragment = fragments[i];
if (fragment.isEqual()) continue;
for (int side = 0; side < 2; side++) {
DiffString text = FragmentSide.fromIndex(side).getText(fragment);
if (text == null || text.isEmptyOrSpaces()) continue;
return false;
}
}
return true;
}
示例10: areEqual
import com.intellij.openapi.diff.ex.DiffFragment; //导入方法依赖的package包/类
private static boolean areEqual(@NotNull DiffFragment[] fragments) {
for (int i = 0; i < fragments.length; i++) {
DiffFragment fragment = fragments[i];
if (!fragment.isEqual()) return false;
}
return true;
}