Search in sources :

Example 46 with Procedure1

use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 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 47 with Procedure1

use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-core by eclipse.

the class PartialSerializerTest method testMandatoryChildChange.

@Test
public void testMandatoryChildChange() {
    final IChangeSerializer.IModification<MandatoryChild> _function = (MandatoryChild 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.<MandatoryChild>recordDiff(MandatoryChild.class, "#4 foo", _function);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("0 0   H");
    _builder.newLine();
    _builder.append("      ");
    _builder.append("B MandatoryChild       Model");
    _builder.newLine();
    _builder.append("0 2    S \"#4\"                 Model:\'#4\'");
    _builder.newLine();
    _builder.append("2 1 1  H \" \"                  Whitespace:TerminalRule\'WS\'");
    _builder.newLine();
    _builder.append("       ");
    _builder.append("B MandatoryValue\'baz\'  MandatoryValue path:MandatoryChild/child");
    _builder.newLine();
    _builder.append("3 3 1   S \"baz\"                MandatoryValue:name=ID");
    _builder.newLine();
    _builder.append("       ");
    _builder.append("E MandatoryValue\'baz\'  MandatoryValue path:MandatoryChild/child");
    _builder.newLine();
    _builder.append("      ");
    _builder.append("E MandatoryChild       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) IChangeSerializer(org.eclipse.xtext.ide.serializer.IChangeSerializer) MandatoryChild(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryChild) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 48 with Procedure1

use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-core by eclipse.

the class PartialSerializerTest method testOptionalChildListInsertIntoEndThree.

@Test
public void testOptionalChildListInsertIntoEndThree() {
    final IChangeSerializer.IModification<OptionalChildList> _function = (OptionalChildList it) -> {
        EList<MandatoryValue> _children = it.getChildren();
        MandatoryValue _createMandatoryValue = this.fac.createMandatoryValue();
        final Procedure1<MandatoryValue> _function_1 = (MandatoryValue it_1) -> {
            it_1.setName("b");
        };
        MandatoryValue _doubleArrow = ObjectExtensions.<MandatoryValue>operator_doubleArrow(_createMandatoryValue, _function_1);
        _children.add(_doubleArrow);
        EList<MandatoryValue> _children_1 = it.getChildren();
        MandatoryValue _createMandatoryValue_1 = this.fac.createMandatoryValue();
        final Procedure1<MandatoryValue> _function_2 = (MandatoryValue it_1) -> {
            it_1.setName("c");
        };
        MandatoryValue _doubleArrow_1 = ObjectExtensions.<MandatoryValue>operator_doubleArrow(_createMandatoryValue_1, _function_2);
        _children_1.add(_doubleArrow_1);
        EList<MandatoryValue> _children_2 = it.getChildren();
        MandatoryValue _createMandatoryValue_2 = this.fac.createMandatoryValue();
        final Procedure1<MandatoryValue> _function_3 = (MandatoryValue it_1) -> {
            it_1.setName("d");
        };
        MandatoryValue _doubleArrow_2 = ObjectExtensions.<MandatoryValue>operator_doubleArrow(_createMandatoryValue_2, _function_3);
        _children_2.add(_doubleArrow_2);
    };
    ITextRegionAccess _recordDiff = this.<OptionalChildList>recordDiff(OptionalChildList.class, "#13 a", _function);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("0 0   H");
    _builder.newLine();
    _builder.append("      ");
    _builder.append("B OptionalChildList    Model");
    _builder.newLine();
    _builder.append("0 3    S \"#13\"                Model:\'#13\'");
    _builder.newLine();
    _builder.append("3 1    H \" \"                  Whitespace:TerminalRule\'WS\'");
    _builder.newLine();
    _builder.append("       ");
    _builder.append("B MandatoryValue\'a\'    OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[0]");
    _builder.newLine();
    _builder.append("4 1 1   S \"a\"                  MandatoryValue:name=ID");
    _builder.newLine();
    _builder.append("       ");
    _builder.append("E MandatoryValue\'a\'    OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[0]");
    _builder.newLine();
    _builder.append("5 0 1  H");
    _builder.newLine();
    _builder.append("       ");
    _builder.append("B MandatoryValue\'b\'    MandatoryValue path:OptionalChildList/children[1]");
    _builder.newLine();
    _builder.append("5 1 1   S \"b\"                  MandatoryValue:name=ID");
    _builder.newLine();
    _builder.append("       ");
    _builder.append("E MandatoryValue\'b\'    MandatoryValue path:OptionalChildList/children[1]");
    _builder.newLine();
    _builder.append("6 0 1  H");
    _builder.newLine();
    _builder.append("       ");
    _builder.append("B MandatoryValue\'c\'    MandatoryValue path:OptionalChildList/children[2]");
    _builder.newLine();
    _builder.append("6 1 1   S \"c\"                  MandatoryValue:name=ID");
    _builder.newLine();
    _builder.append("       ");
    _builder.append("E MandatoryValue\'c\'    MandatoryValue path:OptionalChildList/children[2]");
    _builder.newLine();
    _builder.append("7 0 1  H");
    _builder.newLine();
    _builder.append("       ");
    _builder.append("B MandatoryValue\'d\'    MandatoryValue path:OptionalChildList/children[3]");
    _builder.newLine();
    _builder.append("7 1 1   S \"d\"                  MandatoryValue:name=ID");
    _builder.newLine();
    _builder.append("       ");
    _builder.append("E MandatoryValue\'d\'    MandatoryValue path:OptionalChildList/children[3]");
    _builder.newLine();
    _builder.append("      ");
    _builder.append("E OptionalChildList    Model");
    _builder.newLine();
    _builder.append("8 0 1 H");
    _builder.newLine();
    _builder.append("------------ diff 1 ------------");
    _builder.newLine();
    _builder.append("4 1   S \"a\"                  MandatoryValue:name=ID");
    _builder.newLine();
    _builder.append("5 0   H");
    _builder.newLine();
    this._changeSerializerTestHelper.operator_tripleEquals(_recordDiff, _builder);
}
Also used : OptionalChildList(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.OptionalChildList) MandatoryValue(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryValue) ITextRegionAccess(org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess) IChangeSerializer(org.eclipse.xtext.ide.serializer.IChangeSerializer) EList(org.eclipse.emf.common.util.EList) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 49 with Procedure1

use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-core by eclipse.

the class PartialSerializerTest method testOptionalChildListInsertIntoMiddle.

@Test
public void testOptionalChildListInsertIntoMiddle() {
    final IChangeSerializer.IModification<OptionalChildList> _function = (OptionalChildList it) -> {
        EList<MandatoryValue> _children = it.getChildren();
        MandatoryValue _createMandatoryValue = this.fac.createMandatoryValue();
        final Procedure1<MandatoryValue> _function_1 = (MandatoryValue it_1) -> {
            it_1.setName("x2");
        };
        MandatoryValue _doubleArrow = ObjectExtensions.<MandatoryValue>operator_doubleArrow(_createMandatoryValue, _function_1);
        _children.add(1, _doubleArrow);
    };
    ITextRegionAccess _recordDiff = this.<OptionalChildList>recordDiff(OptionalChildList.class, "#13 x1 x3", _function);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("0 0   H");
    _builder.newLine();
    _builder.append("       ");
    _builder.append("B OptionalChildList    Model");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("0 3    S \"#13\"                Model:\'#13\'");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("3 1    H \" \"                  Whitespace:TerminalRule\'WS\'");
    _builder.newLine();
    _builder.append("        ");
    _builder.append("B MandatoryValue\'x1\'   OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[0]");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("4 2     S \"x1\"                 MandatoryValue:name=ID");
    _builder.newLine();
    _builder.append("        ");
    _builder.append("E MandatoryValue\'x1\'   OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[0]");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("6 1 1  H \" \"                  Whitespace:TerminalRule\'WS\'");
    _builder.newLine();
    _builder.append("        ");
    _builder.append("B MandatoryValue\'x2\'   MandatoryValue path:OptionalChildList/children[1]");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("7 2 1   S \"x2\"                 MandatoryValue:name=ID");
    _builder.newLine();
    _builder.append("        ");
    _builder.append("E MandatoryValue\'x2\'   MandatoryValue path:OptionalChildList/children[1]");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("9 0 1  H");
    _builder.newLine();
    _builder.append("        ");
    _builder.append("B MandatoryValue\'x3\'   OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[2]");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("9 2     S \"x3\"                 MandatoryValue:name=ID");
    _builder.newLine();
    _builder.append("        ");
    _builder.append("E MandatoryValue\'x3\'   OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[2]");
    _builder.newLine();
    _builder.append("       ");
    _builder.append("E OptionalChildList    Model");
    _builder.newLine();
    _builder.append("11 0   H");
    _builder.newLine();
    _builder.append("------------ diff 1 ------------");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("6 1  H \" \"                  Whitespace:TerminalRule\'WS\'");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("7 2  S \"x3\"                 MandatoryValue:name=ID");
    _builder.newLine();
    this._changeSerializerTestHelper.operator_tripleEquals(_recordDiff, _builder);
}
Also used : OptionalChildList(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.OptionalChildList) MandatoryValue(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryValue) ITextRegionAccess(org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess) IChangeSerializer(org.eclipse.xtext.ide.serializer.IChangeSerializer) EList(org.eclipse.emf.common.util.EList) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 50 with Procedure1

use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-core by eclipse.

the class PartialSerializerTest method testOptionalChildListInsertIntoEndOne.

@Test
public void testOptionalChildListInsertIntoEndOne() {
    final IChangeSerializer.IModification<OptionalChildList> _function = (OptionalChildList it) -> {
        EList<MandatoryValue> _children = it.getChildren();
        MandatoryValue _createMandatoryValue = this.fac.createMandatoryValue();
        final Procedure1<MandatoryValue> _function_1 = (MandatoryValue it_1) -> {
            it_1.setName("x2");
        };
        MandatoryValue _doubleArrow = ObjectExtensions.<MandatoryValue>operator_doubleArrow(_createMandatoryValue, _function_1);
        _children.add(_doubleArrow);
    };
    ITextRegionAccess _recordDiff = this.<OptionalChildList>recordDiff(OptionalChildList.class, "#13 x1", _function);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("0 0   H");
    _builder.newLine();
    _builder.append("      ");
    _builder.append("B OptionalChildList    Model");
    _builder.newLine();
    _builder.append("0 3    S \"#13\"                Model:\'#13\'");
    _builder.newLine();
    _builder.append("3 1    H \" \"                  Whitespace:TerminalRule\'WS\'");
    _builder.newLine();
    _builder.append("       ");
    _builder.append("B MandatoryValue\'x1\'   OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[0]");
    _builder.newLine();
    _builder.append("4 2 1   S \"x1\"                 MandatoryValue:name=ID");
    _builder.newLine();
    _builder.append("       ");
    _builder.append("E MandatoryValue\'x1\'   OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[0]");
    _builder.newLine();
    _builder.append("6 0 1  H");
    _builder.newLine();
    _builder.append("       ");
    _builder.append("B MandatoryValue\'x2\'   MandatoryValue path:OptionalChildList/children[1]");
    _builder.newLine();
    _builder.append("6 2 1   S \"x2\"                 MandatoryValue:name=ID");
    _builder.newLine();
    _builder.append("       ");
    _builder.append("E MandatoryValue\'x2\'   MandatoryValue path:OptionalChildList/children[1]");
    _builder.newLine();
    _builder.append("      ");
    _builder.append("E OptionalChildList    Model");
    _builder.newLine();
    _builder.append("8 0 1 H");
    _builder.newLine();
    _builder.append("------------ diff 1 ------------");
    _builder.newLine();
    _builder.append("4 2   S \"x1\"                 MandatoryValue:name=ID");
    _builder.newLine();
    _builder.append("6 0   H");
    _builder.newLine();
    this._changeSerializerTestHelper.operator_tripleEquals(_recordDiff, _builder);
}
Also used : OptionalChildList(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.OptionalChildList) MandatoryValue(org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryValue) ITextRegionAccess(org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess) IChangeSerializer(org.eclipse.xtext.ide.serializer.IChangeSerializer) EList(org.eclipse.emf.common.util.EList) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Aggregations

Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)173 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)99 Test (org.junit.Test)98 IHiddenRegionFormatter (org.eclipse.xtext.formatting2.IHiddenRegionFormatter)28 IFormattableDocument (org.eclipse.xtext.formatting2.IFormattableDocument)20 GenericFormatter (org.eclipse.xtext.formatting2.internal.GenericFormatter)20 ITextRegionExtensions (org.eclipse.xtext.formatting2.regionaccess.ITextRegionExtensions)20 GenericFormatterTestRequest (org.eclipse.xtext.formatting2.internal.GenericFormatterTestRequest)18 AbstractXtendCompilerTest (org.eclipse.xtend.core.tests.compiler.AbstractXtendCompilerTest)16 CompilationTestHelper (org.eclipse.xtext.xbase.testing.CompilationTestHelper)16 EList (org.eclipse.emf.common.util.EList)14 IChangeSerializer (org.eclipse.xtext.ide.serializer.IChangeSerializer)14 MapBasedPreferenceValues (org.eclipse.xtext.preferences.MapBasedPreferenceValues)14 IDList (org.eclipse.xtext.formatting2.internal.formattertestlanguage.IDList)13 EObject (org.eclipse.emf.ecore.EObject)11 Method (java.lang.reflect.Method)10 AbstractBuilderTest (org.eclipse.xtend.ide.tests.codebuilder.AbstractBuilderTest)10 ITextRegionAccess (org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess)10 MandatoryValue (org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryValue)10 Field (java.lang.reflect.Field)9