Search in sources :

Example 1 with PrefixedUnassigned

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

the class RegionAccessTestLanguageSemanticSequencer method sequence.

@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
    EPackage epackage = semanticObject.eClass().getEPackage();
    ParserRule rule = context.getParserRule();
    Action action = context.getAssignedAction();
    Set<Parameter> parameters = context.getEnabledBooleanParameters();
    if (epackage == RegionaccesstestlanguagePackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case RegionaccesstestlanguagePackage.ACTION:
                sequence_Fragment_Mixed(context, (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Action) semanticObject);
                return;
            case RegionaccesstestlanguagePackage.ADD:
                sequence_Expression(context, (Add) semanticObject);
                return;
            case RegionaccesstestlanguagePackage.ASSIGNED_ACTION:
                sequence_Mixed(context, (AssignedAction) semanticObject);
                return;
            case RegionaccesstestlanguagePackage.DELEGATE:
                sequence_Delegate(context, (Delegate) semanticObject);
                return;
            case RegionaccesstestlanguagePackage.DELEGATION:
                sequence_Delegation(context, (Delegation) semanticObject);
                return;
            case RegionaccesstestlanguagePackage.MIXED:
                sequence_Mixed(context, (Mixed) semanticObject);
                return;
            case RegionaccesstestlanguagePackage.NAMED:
                sequence_Primary(context, (Named) semanticObject);
                return;
            case RegionaccesstestlanguagePackage.PREFIXED_UNASSIGNED:
                sequence_PrefixedUnassigned(context, (PrefixedUnassigned) semanticObject);
                return;
            case RegionaccesstestlanguagePackage.ROOT:
                sequence_Root(context, (Root) semanticObject);
                return;
            case RegionaccesstestlanguagePackage.ROOT_ACTION:
                sequence_Root(context, (RootAction) semanticObject);
                return;
            case RegionaccesstestlanguagePackage.SIMPLE:
                sequence_Simple(context, (Simple) semanticObject);
                return;
            case RegionaccesstestlanguagePackage.VALUE_LIST:
                sequence_ValueList(context, (ValueList) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : Add(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Add) ParserRule(org.eclipse.xtext.ParserRule) Named(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Named) Action(org.eclipse.xtext.Action) RootAction(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.RootAction) AssignedAction(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.AssignedAction) Root(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Root) RootAction(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.RootAction) ValueList(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.ValueList) Delegation(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Delegation) EPackage(org.eclipse.emf.ecore.EPackage) Simple(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Simple) AssignedAction(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.AssignedAction) Delegate(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Delegate) Mixed(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Mixed) Parameter(org.eclipse.xtext.Parameter) PrefixedUnassigned(org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.PrefixedUnassigned)

Example 2 with PrefixedUnassigned

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

the class RegionAccessDiffTest method testDeleteOne.

@Test
public void testDeleteOne() throws Exception {
    String model = "4/*1*/prefix/*2*/foo\n";
    ITextRegionAccess access = regionAccessTestHelper.toTextRegionAccess(model);
    ITextRegionAccess modifiedAccess = regionAccessTestHelper.modify(access, (ITextRegionDiffBuilder it) -> {
        ITextRegionExtensions ext = access.getExtensions();
        PrefixedUnassigned rootObj = (PrefixedUnassigned) access.regionForRootEObject().getSemanticElement();
        ISemanticRegion prefix = ext.regionFor(rootObj.getDelegate()).keyword("prefix");
        it.remove(prefix);
    });
    String expectation = " 0  0   H\n" + "        B PrefixedUnassigned Root\n" + " 0  1    S \"4\"        PrefixedUnassigned:'4'\n" + " 1    1  H \"/*1*/\"    Comment:TerminalRule'ML_COMMENT' Association:CONTAINER\n" + "   10    \"/*2*/\"    Comment:TerminalRule'ML_COMMENT' Association:CONTAINER\n" + "         B Delegate'foo' PrefixedUnassigned:delegate=PrefixedDelegate path:PrefixedUnassigned/delegate\n" + "11  3     S \"foo\"      Delegate:name=ID\n" + "         E Delegate'foo' PrefixedUnassigned:delegate=PrefixedDelegate path:PrefixedUnassigned/delegate\n" + "        E PrefixedUnassigned Root\n" + "14  0   H\n" + "------------ diff 1 ------------\n" + " 1  5 H \"/*1*/\"    Comment:TerminalRule'ML_COMMENT' Association:CONTAINER\n" + " 6  6 S \"prefix\"   PrefixedDelegate:'prefix'\n" + "12  5 H \"/*2*/\"    Comment:TerminalRule'ML_COMMENT' Association:CONTAINER\n";
    regionAccessTestHelper.assertRegions(modifiedAccess, expectation);
}
Also used : ITextRegionAccess(org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess) 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 3 with PrefixedUnassigned

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

the class RegionAccessDiffTest method testDeleteTwo.

@Test
public void testDeleteTwo() throws Exception {
    String model = "4/*1*/prefix/*2*/foo/*3*/\n";
    ITextRegionAccess access = regionAccessTestHelper.toTextRegionAccess(model);
    ITextRegionAccess modifiedAccess = regionAccessTestHelper.modify(access, (ITextRegionDiffBuilder it) -> {
        ITextRegionExtensions ext = access.getExtensions();
        PrefixedUnassigned rootObj = (PrefixedUnassigned) access.regionForRootEObject().getSemanticElement();
        ISemanticRegion prefix = ext.regionFor(rootObj.getDelegate()).keyword("prefix");
        ISemanticRegion foo = ext.regionFor(rootObj.getDelegate()).feature(RegionaccesstestlanguagePackage.Literals.DELEGATE__NAME);
        it.remove(prefix.getPreviousHiddenRegion(), foo.getNextHiddenRegion());
    });
    String expectation = " 0  0   H\n" + "        B PrefixedUnassigned Root\n" + " 0  1    S \"4\"        PrefixedUnassigned:'4'\n" + "        E PrefixedUnassigned Root\n" + " 1    1 H \"/*1*/\"    Comment:TerminalRule'ML_COMMENT' Association:CONTAINER\n" + "   10   \"/*3*/\"    Comment:TerminalRule'ML_COMMENT' Association:CONTAINER\n" + "------------ diff 1 ------------\n" + " 1  5  H \"/*1*/\"    Comment:TerminalRule'ML_COMMENT' Association:CONTAINER\n" + " 6  6  S \"prefix\"   PrefixedDelegate:'prefix'\n" + "12  5  H \"/*2*/\"    Comment:TerminalRule'ML_COMMENT' Association:CONTAINER\n" + "17  3  S \"foo\"      Delegate:name=ID\n" + "20  5  H \"/*3*/\"    Comment:TerminalRule'ML_COMMENT' Association:CONTAINER\n";
    regionAccessTestHelper.assertRegions(modifiedAccess, expectation);
}
Also used : ITextRegionAccess(org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess) 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 4 with PrefixedUnassigned

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

the class RegionAccessBuilderTest method testUnassignedPrefixedDelegate.

@Test
public void testUnassignedPrefixedDelegate() throws Exception {
    String model = "4 prefix foo\n".trim();
    String expectation = " 0 0 H\n" + "     B PrefixedUnassigned Root\n" + " 0 1  S \"4\"        PrefixedUnassigned:'4'\n" + " 1 1  H \" \"        Whitespace:TerminalRule'WS'\n" + "      B Delegate'foo' PrefixedUnassigned:delegate=PrefixedDelegate path:PrefixedUnassigned/delegate\n" + " 2 6   S \"prefix\"   PrefixedDelegate:'prefix'\n" + " 8 1   H \" \"        Whitespace:TerminalRule'WS'\n" + " 9 3   S \"foo\"      Delegate:name=ID\n" + "      E Delegate'foo' PrefixedUnassigned:delegate=PrefixedDelegate path:PrefixedUnassigned/delegate\n" + "     E PrefixedUnassigned Root\n" + "12 0 H\n";
    assertRegions(model, expectation);
}
Also used : TextRegionAccessToString(org.eclipse.xtext.formatting2.debug.TextRegionAccessToString) Test(org.junit.Test)

Aggregations

PrefixedUnassigned (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.PrefixedUnassigned)3 Test (org.junit.Test)3 ISemanticRegion (org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion)2 ITextRegionAccess (org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess)2 ITextRegionDiffBuilder (org.eclipse.xtext.formatting2.regionaccess.ITextRegionDiffBuilder)2 ITextRegionExtensions (org.eclipse.xtext.formatting2.regionaccess.ITextRegionExtensions)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 TextRegionAccessToString (org.eclipse.xtext.formatting2.debug.TextRegionAccessToString)1 Add (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Add)1 AssignedAction (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.AssignedAction)1 Delegate (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Delegate)1 Delegation (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Delegation)1 Mixed (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Mixed)1 Named (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Named)1 Root (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Root)1 RootAction (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.RootAction)1 Simple (org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Simple)1