Search in sources :

Example 6 with Delegate

use of org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Delegate in project xtext-core by eclipse.

the class RegionAccessBuilderTest method testUnassignedPrefixedDelegate.

@Test
public void testUnassignedPrefixedDelegate() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("4 prefix foo");
    _builder.newLine();
    String _trim = _builder.toString().trim();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append(" ");
    _builder_1.append("0 0 H");
    _builder_1.newLine();
    _builder_1.append("     ");
    _builder_1.append("B PrefixedUnassigned Root");
    _builder_1.newLine();
    _builder_1.append(" ");
    _builder_1.append("0 1  S \"4\"        PrefixedUnassigned:\'4\'");
    _builder_1.newLine();
    _builder_1.append(" ");
    _builder_1.append("1 1  H \" \"        Whitespace:TerminalRule\'WS\'");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("B Delegate\'foo\' PrefixedUnassigned:delegate=PrefixedDelegate path:PrefixedUnassigned/delegate");
    _builder_1.newLine();
    _builder_1.append(" ");
    _builder_1.append("2 6   S \"prefix\"   PrefixedDelegate:\'prefix\'");
    _builder_1.newLine();
    _builder_1.append(" ");
    _builder_1.append("8 1   H \" \"        Whitespace:TerminalRule\'WS\'");
    _builder_1.newLine();
    _builder_1.append(" ");
    _builder_1.append("9 3   S \"foo\"      Delegate:name=ID");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("E Delegate\'foo\' PrefixedUnassigned:delegate=PrefixedDelegate path:PrefixedUnassigned/delegate");
    _builder_1.newLine();
    _builder_1.append("     ");
    _builder_1.append("E PrefixedUnassigned Root");
    _builder_1.newLine();
    _builder_1.append("12 0 H");
    _builder_1.newLine();
    this.operator_tripleEquals(_trim, _builder_1);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) TextRegionAccessToString(org.eclipse.xtext.formatting2.debug.TextRegionAccessToString) Test(org.junit.Test)

Example 7 with Delegate

use of org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Delegate in project xtext-core by eclipse.

the class RegionAccessDiffTest method testDeleteOne.

@Test
public void testDeleteOne() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("4/*1*/prefix/*2*/foo");
    _builder.newLine();
    final ITextRegionAccess access = this._regionAccessTestHelper.toTextRegionAccess(_builder);
    final Procedure1<ITextRegionDiffBuilder> _function = (ITextRegionDiffBuilder it) -> {
        @Extension final ITextRegionExtensions ext = access.getExtensions();
        EObject _semanticElement = access.regionForRootEObject().getSemanticElement();
        final PrefixedUnassigned rootObj = ((PrefixedUnassigned) _semanticElement);
        final ISemanticRegion prefix = ext.regionFor(rootObj.getDelegate()).keyword("prefix");
        it.remove(prefix);
    };
    ITextRegionAccess _modify = this._regionAccessTestHelper.modify(access, _function);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append(" ");
    _builder_1.append("0  0   H");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("B PrefixedUnassigned Root");
    _builder_1.newLine();
    _builder_1.append(" ");
    _builder_1.append("0  1    S \"4\"        PrefixedUnassigned:\'4\'");
    _builder_1.newLine();
    _builder_1.append(" ");
    _builder_1.append("1    1  H \"/*1*/\"    Comment:TerminalRule\'ML_COMMENT\' Association:CONTAINER");
    _builder_1.newLine();
    _builder_1.append("   ");
    _builder_1.append("10    \"/*2*/\"    Comment:TerminalRule\'ML_COMMENT\' Association:CONTAINER");
    _builder_1.newLine();
    _builder_1.append("         ");
    _builder_1.append("B Delegate\'foo\' PrefixedUnassigned:delegate=PrefixedDelegate path:PrefixedUnassigned/delegate");
    _builder_1.newLine();
    _builder_1.append("11  3     S \"foo\"      Delegate:name=ID");
    _builder_1.newLine();
    _builder_1.append("         ");
    _builder_1.append("E Delegate\'foo\' PrefixedUnassigned:delegate=PrefixedDelegate path:PrefixedUnassigned/delegate");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("E PrefixedUnassigned Root");
    _builder_1.newLine();
    _builder_1.append("14  0   H");
    _builder_1.newLine();
    _builder_1.append("------------ diff 1 ------------");
    _builder_1.newLine();
    _builder_1.append(" ");
    _builder_1.append("1  5 H \"/*1*/\"    Comment:TerminalRule\'ML_COMMENT\' Association:CONTAINER");
    _builder_1.newLine();
    _builder_1.append(" ");
    _builder_1.append("6  6 S \"prefix\"   PrefixedDelegate:\'prefix\'");
    _builder_1.newLine();
    _builder_1.append("12  5 H \"/*2*/\"    Comment:TerminalRule\'ML_COMMENT\' Association:CONTAINER");
    _builder_1.newLine();
    this._regionAccessTestHelper.operator_tripleEquals(_modify, _builder_1);
}
Also used : ITextRegionAccess(org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess) EObject(org.eclipse.emf.ecore.EObject) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) PrefixedUnassigned(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.PrefixedUnassigned) ITextRegionDiffBuilder(org.eclipse.xtext.formatting2.regionaccess.ITextRegionDiffBuilder) ISemanticRegion(org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion) ITextRegionExtensions(org.eclipse.xtext.formatting2.regionaccess.ITextRegionExtensions) Test(org.junit.Test)

Example 8 with Delegate

use of org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Delegate in project xtext-core by eclipse.

the class RegionAccessDiffTest method testSerializeRootObject.

@Test
public void testSerializeRootObject() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("3 foo");
    _builder.newLine();
    final ITextRegionAccess access = this._regionAccessTestHelper.toTextRegionAccess(_builder);
    final Procedure1<ITextRegionDiffBuilder> _function = (ITextRegionDiffBuilder it) -> {
        final IEObjectRegion root = access.regionForRootEObject();
        EObject _semanticElement = root.getSemanticElement();
        final Delegate rootObj = ((Delegate) _semanticElement);
        rootObj.setName("baaaz");
        final ITextRegionAccess textRegions = this.serializer.serializeToRegions(rootObj);
        it.replace(root.getPreviousHiddenRegion(), root.getNextHiddenRegion(), textRegions);
    };
    ITextRegionAccess _modify = this._regionAccessTestHelper.modify(access, _function);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("0 0 1 H");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("B Delegate\'baaaz\' Root");
    _builder_1.newLine();
    _builder_1.append("0 1 1  S \"3\"        Unassigned:\'3\'");
    _builder_1.newLine();
    _builder_1.append("1 1 1  H \" \"        Whitespace:TerminalRule\'WS\'");
    _builder_1.newLine();
    _builder_1.append("2 5 1  S \"baaaz\"    Delegate:name=ID");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("E Delegate\'baaaz\' Root");
    _builder_1.newLine();
    _builder_1.append("7 0 1 H");
    _builder_1.newLine();
    _builder_1.append("------------ diff 1 ------------");
    _builder_1.newLine();
    _builder_1.append("0 0 H");
    _builder_1.newLine();
    _builder_1.append("0 1 S \"3\"        Unassigned:\'3\'");
    _builder_1.newLine();
    _builder_1.append("1 1 H \" \"        Whitespace:TerminalRule\'WS\'");
    _builder_1.newLine();
    _builder_1.append("2 3 S \"foo\"      Delegate:name=ID");
    _builder_1.newLine();
    _builder_1.append("5 0 H");
    _builder_1.newLine();
    this._regionAccessTestHelper.operator_tripleEquals(_modify, _builder_1);
}
Also used : ITextRegionAccess(org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess) IEObjectRegion(org.eclipse.xtext.formatting2.regionaccess.IEObjectRegion) Delegate(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Delegate) EObject(org.eclipse.emf.ecore.EObject) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) ITextRegionDiffBuilder(org.eclipse.xtext.formatting2.regionaccess.ITextRegionDiffBuilder) Test(org.junit.Test)

Example 9 with Delegate

use of org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Delegate in project xtext-core by eclipse.

the class RegionAccessDiffTest method testSerializeChildObject.

@Test
public void testSerializeChildObject() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("2 foo");
    _builder.newLine();
    final ITextRegionAccess access = this._regionAccessTestHelper.toTextRegionAccess(_builder);
    final Procedure1<ITextRegionDiffBuilder> _function = (ITextRegionDiffBuilder it) -> {
        EObject _semanticElement = access.regionForRootEObject().getSemanticElement();
        final Delegate child = ((Delegation) _semanticElement).getDelegate();
        final IEObjectRegion childRegion = access.regionForEObject(child);
        child.setName("baaaz");
        final ITextRegionAccess textRegions = this.serializer.serializeToRegions(child);
        it.replace(childRegion.getPreviousHiddenRegion(), childRegion.getNextHiddenRegion(), textRegions);
    };
    ITextRegionAccess _modify = this._regionAccessTestHelper.modify(access, _function);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("0 0   H");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("B Delegation Root");
    _builder_1.newLine();
    _builder_1.append("0 1    S \"2\"        Delegation:\'2\'");
    _builder_1.newLine();
    _builder_1.append("1 1 1  H \" \"        Whitespace:TerminalRule\'WS\'");
    _builder_1.newLine();
    _builder_1.append("       ");
    _builder_1.append("B Delegate\'baaaz\' Delegate path:Delegation/delegate");
    _builder_1.newLine();
    _builder_1.append("2 5 1   S \"baaaz\"    Delegate:name=ID");
    _builder_1.newLine();
    _builder_1.append("       ");
    _builder_1.append("E Delegate\'baaaz\' Delegate path:Delegation/delegate");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("E Delegation Root");
    _builder_1.newLine();
    _builder_1.append("7 0 1 H");
    _builder_1.newLine();
    _builder_1.append("------------ diff 1 ------------");
    _builder_1.newLine();
    _builder_1.append("1 1  H \" \"        Whitespace:TerminalRule\'WS\'");
    _builder_1.newLine();
    _builder_1.append("2 3  S \"foo\"      Delegate:name=ID");
    _builder_1.newLine();
    _builder_1.append("5 0  H");
    _builder_1.newLine();
    this._regionAccessTestHelper.operator_tripleEquals(_modify, _builder_1);
}
Also used : ITextRegionAccess(org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess) Delegate(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Delegate) IEObjectRegion(org.eclipse.xtext.formatting2.regionaccess.IEObjectRegion) EObject(org.eclipse.emf.ecore.EObject) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) ITextRegionDiffBuilder(org.eclipse.xtext.formatting2.regionaccess.ITextRegionDiffBuilder) Test(org.junit.Test)

Aggregations

StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)6 Test (org.junit.Test)6 Delegate (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Delegate)4 EObject (org.eclipse.emf.ecore.EObject)3 TextRegionAccessToString (org.eclipse.xtext.formatting2.debug.TextRegionAccessToString)3 ITextRegionAccess (org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess)3 ITextRegionDiffBuilder (org.eclipse.xtext.formatting2.regionaccess.ITextRegionDiffBuilder)3 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)2 IEObjectRegion (org.eclipse.xtext.formatting2.regionaccess.IEObjectRegion)2 PrefixedUnassigned (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.PrefixedUnassigned)2 EPackage (org.eclipse.emf.ecore.EPackage)1 Action (org.eclipse.xtext.Action)1 Parameter (org.eclipse.xtext.Parameter)1 ParserRule (org.eclipse.xtext.ParserRule)1 ISemanticRegion (org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion)1 ITextRegionExtensions (org.eclipse.xtext.formatting2.regionaccess.ITextRegionExtensions)1 Add (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Add)1 AssignedAction (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.AssignedAction)1 Delegation (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Delegation)1 Mixed (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Mixed)1