Search in sources :

Example 1 with OptionalChild

use of org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.OptionalChild in project xtext-core by eclipse.

the class PartialSerializerTest method testOptionalChildInsert.

@Test
public void testOptionalChildInsert() {
    final IChangeSerializer.IModification<OptionalChild> _function = (OptionalChild it) -> {
        MandatoryValue _createMandatoryValue = this.fac.createMandatoryValue();
        final Procedure1<MandatoryValue> _function_1 = (MandatoryValue it_1) -> {
            it_1.setName("baz");
        };
        MandatoryValue _doubleArrow = ObjectExtensions.<MandatoryValue>operator_doubleArrow(_createMandatoryValue, _function_1);
        it.setChild(_doubleArrow);
    };
    ITextRegionAccess _recordDiff = this.<OptionalChild>recordDiff(OptionalChild.class, "#5", _function);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("0 0 1 H");
    _builder.newLine();
    _builder.append("      ");
    _builder.append("B OptionalChild        Model");
    _builder.newLine();
    _builder.append("0 2 1  S \"#5\"                 Model:\'#5\'");
    _builder.newLine();
    _builder.append("2 0 1  H");
    _builder.newLine();
    _builder.append("       ");
    _builder.append("B MandatoryValue\'baz\'  OptionalChild:child=MandatoryValue path:OptionalChild/child");
    _builder.newLine();
    _builder.append("2 3 1   S \"baz\"                MandatoryValue:name=ID");
    _builder.newLine();
    _builder.append("       ");
    _builder.append("E MandatoryValue\'baz\'  OptionalChild:child=MandatoryValue path:OptionalChild/child");
    _builder.newLine();
    _builder.append("      ");
    _builder.append("E OptionalChild        Model");
    _builder.newLine();
    _builder.append("5 0 1 H");
    _builder.newLine();
    _builder.append("------------ diff 1 ------------");
    _builder.newLine();
    _builder.append("0 0 H");
    _builder.newLine();
    _builder.append("0 2 S \"#5\"                 Model:\'#5\'");
    _builder.newLine();
    _builder.append("2 0 H");
    _builder.newLine();
    this._changeSerializerTestHelper.operator_tripleEquals(_recordDiff, _builder);
}
Also used : MandatoryValue(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryValue) ITextRegionAccess(org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess) OptionalChild(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.OptionalChild) IChangeSerializer(org.eclipse.xtext.ide.serializer.IChangeSerializer) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 2 with OptionalChild

use of org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.OptionalChild in project xtext-core by eclipse.

the class PartialSerializerTest method testOptionalChildChange.

@Test
public void testOptionalChildChange() {
    final IChangeSerializer.IModification<OptionalChild> _function = (OptionalChild it) -> {
        MandatoryValue _createMandatoryValue = this.fac.createMandatoryValue();
        final Procedure1<MandatoryValue> _function_1 = (MandatoryValue it_1) -> {
            it_1.setName("baz");
        };
        MandatoryValue _doubleArrow = ObjectExtensions.<MandatoryValue>operator_doubleArrow(_createMandatoryValue, _function_1);
        it.setChild(_doubleArrow);
    };
    ITextRegionAccess _recordDiff = this.<OptionalChild>recordDiff(OptionalChild.class, "#5 foo", _function);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("0 0   H");
    _builder.newLine();
    _builder.append("      ");
    _builder.append("B OptionalChild        Model");
    _builder.newLine();
    _builder.append("0 2    S \"#5\"                 Model:\'#5\'");
    _builder.newLine();
    _builder.append("2 1 1  H \" \"                  Whitespace:TerminalRule\'WS\'");
    _builder.newLine();
    _builder.append("       ");
    _builder.append("B MandatoryValue\'baz\'  MandatoryValue path:OptionalChild/child");
    _builder.newLine();
    _builder.append("3 3 1   S \"baz\"                MandatoryValue:name=ID");
    _builder.newLine();
    _builder.append("       ");
    _builder.append("E MandatoryValue\'baz\'  MandatoryValue path:OptionalChild/child");
    _builder.newLine();
    _builder.append("      ");
    _builder.append("E OptionalChild        Model");
    _builder.newLine();
    _builder.append("6 0 1 H");
    _builder.newLine();
    _builder.append("------------ diff 1 ------------");
    _builder.newLine();
    _builder.append("2 1  H \" \"                  Whitespace:TerminalRule\'WS\'");
    _builder.newLine();
    _builder.append("3 3  S \"foo\"                MandatoryValue:name=ID");
    _builder.newLine();
    _builder.append("6 0  H");
    _builder.newLine();
    this._changeSerializerTestHelper.operator_tripleEquals(_recordDiff, _builder);
}
Also used : MandatoryValue(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryValue) ITextRegionAccess(org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess) OptionalChild(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.OptionalChild) IChangeSerializer(org.eclipse.xtext.ide.serializer.IChangeSerializer) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 3 with OptionalChild

use of org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.OptionalChild in project xtext-core by eclipse.

the class PartialSerializerTest method testOptionalChildRemove.

@Test
public void testOptionalChildRemove() {
    final IChangeSerializer.IModification<OptionalChild> _function = (OptionalChild it) -> {
        it.setChild(null);
    };
    ITextRegionAccess _recordDiff = this.<OptionalChild>recordDiff(OptionalChild.class, "#5 foo", _function);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("0 0   H");
    _builder.newLine();
    _builder.append("      ");
    _builder.append("B OptionalChild        Model");
    _builder.newLine();
    _builder.append("0 2    S \"#5\"                 Model:\'#5\'");
    _builder.newLine();
    _builder.append("      ");
    _builder.append("E OptionalChild        Model");
    _builder.newLine();
    _builder.append("2 1 1 H \" \"                  Whitespace:TerminalRule\'WS\'");
    _builder.newLine();
    _builder.append("------------ diff 1 ------------");
    _builder.newLine();
    _builder.append("2 1  H \" \"                  Whitespace:TerminalRule\'WS\'");
    _builder.newLine();
    _builder.append("3 3  S \"foo\"                MandatoryValue:name=ID");
    _builder.newLine();
    _builder.append("6 0  H");
    _builder.newLine();
    this._changeSerializerTestHelper.operator_tripleEquals(_recordDiff, _builder);
}
Also used : ITextRegionAccess(org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess) OptionalChild(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.OptionalChild) IChangeSerializer(org.eclipse.xtext.ide.serializer.IChangeSerializer) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Aggregations

StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)3 ITextRegionAccess (org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess)3 IChangeSerializer (org.eclipse.xtext.ide.serializer.IChangeSerializer)3 OptionalChild (org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.OptionalChild)3 Test (org.junit.Test)3 MandatoryValue (org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryValue)2 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)2