Search in sources :

Example 26 with DiffFragment

use of com.intellij.openapi.diff.ex.DiffFragment in project intellij-community by JetBrains.

the class ByWordTest method testIdea56428.

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);
}
Also used : DiffFragment(com.intellij.openapi.diff.ex.DiffFragment)

Example 27 with DiffFragment

use of com.intellij.openapi.diff.ex.DiffFragment in project intellij-community by JetBrains.

the class ByWordTest method testIgnoreSpaces.

public void testIgnoreSpaces() throws FilesTooBigForDiffException {
    ByWord byWord = new ByWord(ComparisonPolicy.IGNORE_SPACE);
    DiffFragment[] fragments = byWord.buildFragments(" o.f(a)", "o. f( b)");
    CHECK.compareAll(new DiffFragment[] { DiffFragment.unchanged(" o.f(", "o. f( "), new DiffFragment("a", "b"), DiffFragment.unchanged(")", ")") }, UniteSameType.INSTANCE.correct(fragments));
}
Also used : DiffFragment(com.intellij.openapi.diff.ex.DiffFragment)

Example 28 with DiffFragment

use of com.intellij.openapi.diff.ex.DiffFragment in project intellij-community by JetBrains.

the class ByWordTest method testIdea58505.

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);
}
Also used : DiffFragment(com.intellij.openapi.diff.ex.DiffFragment)

Example 29 with DiffFragment

use of com.intellij.openapi.diff.ex.DiffFragment in project intellij-community by JetBrains.

the class CorrectionTest method testConnectSingleSideToChange.

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);
}
Also used : DiffFragment(com.intellij.openapi.diff.ex.DiffFragment)

Example 30 with DiffFragment

use of com.intellij.openapi.diff.ex.DiffFragment in project intellij-community by JetBrains.

the class CorrectionTest method testTrueLineBlocksWithSameLines.

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);
}
Also used : DiffFragment(com.intellij.openapi.diff.ex.DiffFragment)

Aggregations

DiffFragment (com.intellij.openapi.diff.ex.DiffFragment)55 DiffString (com.intellij.openapi.diff.impl.string.DiffString)15 NotNull (org.jetbrains.annotations.NotNull)13 FragmentSide (com.intellij.openapi.diff.impl.highlighting.FragmentSide)3 LineFragment (com.intellij.openapi.diff.impl.fragments.LineFragment)2 TextRange (com.intellij.openapi.util.TextRange)2 FilesTooBigForDiffException (com.intellij.util.diff.FilesTooBigForDiffException)2 Fragment (com.intellij.openapi.diff.impl.fragments.Fragment)1 DiffCorrection (com.intellij.openapi.diff.impl.processing.DiffCorrection)1 DiffFragmentsProcessor (com.intellij.openapi.diff.impl.processing.DiffFragmentsProcessor)1 Document (com.intellij.openapi.editor.Document)1 VcsException (com.intellij.openapi.vcs.VcsException)1 Diff (com.intellij.util.diff.Diff)1 ArrayList (java.util.ArrayList)1