Search in sources :

Example 1 with TestableTextSegmentSet

use of org.eclipse.xtext.formatting2.internal.TestableTextSegmentSet in project xtext-core by eclipse.

the class RegionSetTest method testMergeConflic4.

@Test
public void testMergeConflic4() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("issues=mergeConflict:[20,2]<>[21,5]");
    _builder.newLine();
    _builder.append("set=[[21,5]]");
    _builder.newLine();
    final Procedure1<TestableTextSegmentSet> _function = (TestableTextSegmentSet it) -> {
        TextSegment _textSegment = new TextSegment(null, 21, 5);
        it.add(_textSegment);
        TextSegment _textSegment_1 = new TextSegment(null, 20, 2);
        it.add(_textSegment_1);
    };
    this.test(_builder, _function);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) TextSegment(org.eclipse.xtext.formatting2.regionaccess.internal.TextSegment) ITextSegment(org.eclipse.xtext.formatting2.regionaccess.ITextSegment) TestableTextSegmentSet(org.eclipse.xtext.formatting2.internal.TestableTextSegmentSet) Test(org.junit.Test)

Example 2 with TestableTextSegmentSet

use of org.eclipse.xtext.formatting2.internal.TestableTextSegmentSet in project xtext-core by eclipse.

the class RegionSetTest method testNoMergeConflic1.

@Test
public void testNoMergeConflic1() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("issues=");
    _builder.newLine();
    _builder.append("set=[[20,0], [20,1]]");
    _builder.newLine();
    final Procedure1<TestableTextSegmentSet> _function = (TestableTextSegmentSet it) -> {
        TextSegment _textSegment = new TextSegment(null, 20, 0);
        it.add(_textSegment);
        TextSegment _textSegment_1 = new TextSegment(null, 20, 1);
        it.add(_textSegment_1);
    };
    this.test(_builder, _function);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) TextSegment(org.eclipse.xtext.formatting2.regionaccess.internal.TextSegment) ITextSegment(org.eclipse.xtext.formatting2.regionaccess.ITextSegment) TestableTextSegmentSet(org.eclipse.xtext.formatting2.internal.TestableTextSegmentSet) Test(org.junit.Test)

Example 3 with TestableTextSegmentSet

use of org.eclipse.xtext.formatting2.internal.TestableTextSegmentSet in project xtext-core by eclipse.

the class RegionSetTest method test.

private void test(final CharSequence expectation, final Procedure1<? super TestableTextSegmentSet> test) {
    Function<ITextSegment, ITextSegment> _identity = Functions.<ITextSegment>identity();
    Function<Object, String> _stringFunction = Functions.toStringFunction();
    ArrayListTextSegmentSet<ITextSegment> _arrayListTextSegmentSet = new ArrayListTextSegmentSet<ITextSegment>(_identity, _stringFunction, true);
    final TestableTextSegmentSet set = new TestableTextSegmentSet(_arrayListTextSegmentSet);
    try {
        test.apply(set);
    } catch (final Throwable _t) {
        if (_t instanceof Throwable) {
            final Throwable t = (Throwable) _t;
            t.printStackTrace();
            Assert.fail();
        } else {
            throw Exceptions.sneakyThrow(_t);
        }
    }
    Assert.assertEquals(expectation.toString(), set.toString());
}
Also used : ArrayListTextSegmentSet(org.eclipse.xtext.formatting2.internal.ArrayListTextSegmentSet) ITextSegment(org.eclipse.xtext.formatting2.regionaccess.ITextSegment) TestableTextSegmentSet(org.eclipse.xtext.formatting2.internal.TestableTextSegmentSet)

Example 4 with TestableTextSegmentSet

use of org.eclipse.xtext.formatting2.internal.TestableTextSegmentSet in project xtext-core by eclipse.

the class RegionSetTest method testNoMergeConflic2.

@Test
public void testNoMergeConflic2() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("issues=");
    _builder.newLine();
    _builder.append("set=[[20,0], [20,1]]");
    _builder.newLine();
    final Procedure1<TestableTextSegmentSet> _function = (TestableTextSegmentSet it) -> {
        TextSegment _textSegment = new TextSegment(null, 20, 1);
        it.add(_textSegment);
        TextSegment _textSegment_1 = new TextSegment(null, 20, 0);
        it.add(_textSegment_1);
    };
    this.test(_builder, _function);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) TextSegment(org.eclipse.xtext.formatting2.regionaccess.internal.TextSegment) ITextSegment(org.eclipse.xtext.formatting2.regionaccess.ITextSegment) TestableTextSegmentSet(org.eclipse.xtext.formatting2.internal.TestableTextSegmentSet) Test(org.junit.Test)

Example 5 with TestableTextSegmentSet

use of org.eclipse.xtext.formatting2.internal.TestableTextSegmentSet in project xtext-core by eclipse.

the class RegionSetTest method testMergeConflic3.

@Test
public void testMergeConflic3() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("issues=mergeConflict:[20,2]<>[21,0]");
    _builder.newLine();
    _builder.append("set=[[20,2]]");
    _builder.newLine();
    final Procedure1<TestableTextSegmentSet> _function = (TestableTextSegmentSet it) -> {
        TextSegment _textSegment = new TextSegment(null, 21, 0);
        it.add(_textSegment);
        TextSegment _textSegment_1 = new TextSegment(null, 20, 2);
        it.add(_textSegment_1);
    };
    this.test(_builder, _function);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) TextSegment(org.eclipse.xtext.formatting2.regionaccess.internal.TextSegment) ITextSegment(org.eclipse.xtext.formatting2.regionaccess.ITextSegment) TestableTextSegmentSet(org.eclipse.xtext.formatting2.internal.TestableTextSegmentSet) Test(org.junit.Test)

Aggregations

TestableTextSegmentSet (org.eclipse.xtext.formatting2.internal.TestableTextSegmentSet)9 ITextSegment (org.eclipse.xtext.formatting2.regionaccess.ITextSegment)9 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)8 TextSegment (org.eclipse.xtext.formatting2.regionaccess.internal.TextSegment)8 Test (org.junit.Test)8 ArrayListTextSegmentSet (org.eclipse.xtext.formatting2.internal.ArrayListTextSegmentSet)1