use of org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.ValueList 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));
}
use of org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.ValueList in project xtext-core by eclipse.
the class RegionAccessBuilderTest method testComments1.
@Test
public void testComments1() throws Exception {
String model = "/*xxxx*/\n" + "8\n" + "/*aaaaa*/\n" + "c\n" + "// last\n".trim();
String expectation = " 0 H \"/*xxxx*/\" Comment:TerminalRule'ML_COMMENT' Association:NEXT\n" + " 9 \"\\n" + "\" Whitespace:TerminalRule'WS'\n" + " B ValueList'[c]' Root\n" + " 9 1 S \"8\" Root:'8'\n" + "10 H \"\\n" + "\" Whitespace:TerminalRule'WS'\n" + " \"/*aaa...\" Comment:TerminalRule'ML_COMMENT' Association:NEXT\n" + " 11 \"\\n" + "\" Whitespace:TerminalRule'WS'\n" + "21 1 S \"c\" ValueList:name+=ID\n" + " E ValueList'[c]' Root\n" + "22 H \"\\n" + "\" Whitespace:TerminalRule'WS'\n" + " 8 \"// last\" Comment:TerminalRule'SL_COMMENT' Association:CONTAINER\n";
assertRegions(model, expectation);
}
use of org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.ValueList in project xtext-core by eclipse.
the class RegionAccessDiffTest method testInsertReplaceReplace.
@Test
public void testInsertReplaceReplace() throws Exception {
String model = "8 a\n";
ITextRegionAccess access = regionAccessTestHelper.toTextRegionAccess(model);
ITextRegionAccess modifiedAccess = regionAccessTestHelper.modify(access, (ITextRegionDiffBuilder it) -> {
ITextRegionExtensions ext = access.getExtensions();
ValueList rootObj = (ValueList) access.regionForRootEObject().getSemanticElement();
ISemanticRegion a = ext.regionFor(rootObj).keyword("8").getNextSemanticRegion();
it.replace(a, "b");
it.replace(a, "c");
});
String expectation = "0 0 H\n" + " B ValueList'[a]' Root\n" + "0 1 S \"8\" Root:'8'\n" + "1 1 H \" \" Whitespace:TerminalRule'WS'\n" + "2 1 1 S \"c\" ValueList:name+=ID\n" + " E ValueList'[a]' Root\n" + "3 0 H\n" + "------------ diff 1 ------------\n" + "2 1 S \"a\" ValueList:name+=ID\n";
regionAccessTestHelper.assertRegions(modifiedAccess, expectation);
}
use of org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.ValueList in project xtext-core by eclipse.
the class RegionAccessDiffTest method testInsertInsertReplace.
@Test
public void testInsertInsertReplace() throws Exception {
String model = "8 a\n";
ITextRegionAccess access = regionAccessTestHelper.toTextRegionAccess(model);
ITextRegionAccess modifiedAccess = regionAccessTestHelper.modify(access, (ITextRegionDiffBuilder it) -> {
ITextRegionExtensions ext = access.getExtensions();
ValueList rootObj = (ValueList) access.regionForRootEObject().getSemanticElement();
ISemanticRegion a = ext.regionFor(rootObj).keyword("8").getNextSemanticRegion();
it.replace(a.getNextHiddenRegion(), a.getNextHiddenRegion(), a.getPreviousHiddenRegion(), a.getNextHiddenRegion());
it.replace(a.getNextHiddenRegion(), a.getNextHiddenRegion(), a.getPreviousHiddenRegion(), a.getNextHiddenRegion());
it.replace(a, "new");
});
String expectation = " 0 0 H\n" + " B ValueList'[a]' Root\n" + " 0 1 S \"8\" Root:'8'\n" + " 1 1 H \" \" Whitespace:TerminalRule'WS'\n" + " 2 3 2 S \"new\" ValueList:name+=ID\n" + " 5 0 2 H\n" + " 5 3 2 S \"new\" ValueList:name+=ID\n" + " 8 0 2 H\n" + " 8 3 2 S \"new\" ValueList:name+=ID\n" + " E ValueList'[a]' Root\n" + "11 0 2 H\n" + "------------ diff 1 ------------\n" + " 2 1 S \"a\" ValueList:name+=ID\n" + "------------ diff 2 ------------\n" + " 2 1 S \"a\" ValueList:name+=ID\n" + " 3 0 H\n";
regionAccessTestHelper.assertRegions(modifiedAccess, expectation);
}
use of org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.ValueList in project xtext-core by eclipse.
the class RegionAccessDiffTest method testInsertBeforeComment.
@Test
public void testInsertBeforeComment() throws Exception {
String model = "8\n" + "/**/\n" + "a b\n";
ITextRegionAccess access = regionAccessTestHelper.toTextRegionAccess(model);
ITextRegionAccess modifiedAccess = regionAccessTestHelper.modify(access, (ITextRegionDiffBuilder it) -> {
ITextRegionExtensions ext = access.getExtensions();
ValueList rootObj = (ValueList) access.regionForRootEObject().getSemanticElement();
ISemanticRegion a = ext.regionFor(rootObj).keyword("8").getNextSemanticRegion();
ISemanticRegion b = a.getNextSemanticRegion();
it.replace(a.getPreviousHiddenRegion(), a.getPreviousHiddenRegion(), b.getPreviousHiddenRegion(), b.getNextHiddenRegion());
});
String expectation = " 0 0 H\n" + " B ValueList'[a, b]' Root\n" + " 0 1 S \"8\" Root:'8'\n" + " 1 1 1 H \"\\n" + "\" Whitespace:TerminalRule'WS'\n" + " 2 1 1 S \"b\" ValueList:name+=ID\n" + " 3 1 H \"/**/\" Comment:TerminalRule'ML_COMMENT' Association:PREVIOUS\n" + " 5 \"\\n" + "\" Whitespace:TerminalRule'WS'\n" + " 8 1 S \"a\" ValueList:name+=ID\n" + " 9 1 H \" \" Whitespace:TerminalRule'WS'\n" + "10 1 S \"b\" ValueList:name+=ID\n" + " E ValueList'[a, b]' Root\n" + "11 0 H\n" + "------------ diff 1 ------------\n" + " 1 H \"\\n" + "\" Whitespace:TerminalRule'WS'\n" + " \"/**/\" Comment:TerminalRule'ML_COMMENT' Association:NEXT\n" + " 6 \"\\n" + "\" Whitespace:TerminalRule'WS'\n";
regionAccessTestHelper.assertRegions(modifiedAccess, expectation);
}
Aggregations