use of org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Add in project xtext-core by eclipse.
the class ImportTestHelper method createResourceSet.
public ResourceSet createResourceSet(InMemoryURIHandler fs) {
XtextResourceSet idx = new XtextResourceSet();
idx.getURIConverter().getURIHandlers().add(0, fs);
for (InMemoryURIHandler.InMemFile f : fs.getFiles().values()) {
idx.getResource(f.getUri(), true);
}
EcoreUtil.resolveAll(idx);
for (Resource r : idx.getResources()) {
if (r instanceof XtextResource) {
validator.assertNoErrors(r);
}
}
List<IResourceDescription> rsd = new ArrayList<>();
for (Resource r : idx.getResources()) {
rsd.add(rdManager.getResourceDescription(r));
}
ResourceDescriptionsData data = new ResourceDescriptionsData(rsd);
XtextResourceSet r = new XtextResourceSet();
r.getLoadOptions().put(ResourceDescriptionsProvider.LIVE_SCOPE, Boolean.TRUE);
r.getURIConverter().getURIHandlers().add(0, fs);
ResourceDescriptionsData.ResourceSetAdapter.installResourceDescriptionsData(r, data);
Map<String, ResourceDescriptionsData> dataMap = new HashMap<>();
dataMap.put("egal", data);
new ChunkedResourceDescriptions(Collections.unmodifiableMap(dataMap), r);
return r;
}
use of org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Add in project xtext-core by eclipse.
the class PartialSerializerTest method testOptionalChildListInsertIntoMiddle.
@Test
public void testOptionalChildListInsertIntoMiddle() {
ITextRegionAccess diff = recordDiff(OptionalChildList.class, "#13 x1 x3", (OptionalChildList it) -> {
MandatoryValue newMandatoryValue = fac.createMandatoryValue();
newMandatoryValue.setName("x2");
it.getChildren().add(1, newMandatoryValue);
});
String expectation = "0 0 H\n" + " B OptionalChildList Model\n" + " 0 3 S \"#13\" Model:'#13'\n" + " 3 1 H \" \" Whitespace:TerminalRule'WS'\n" + " B MandatoryValue'x1' OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[0]\n" + " 4 2 S \"x1\" MandatoryValue:name=ID\n" + " E MandatoryValue'x1' OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[0]\n" + " 6 1 1 H \" \" Whitespace:TerminalRule'WS'\n" + " B MandatoryValue'x2' MandatoryValue path:OptionalChildList/children[1]\n" + " 7 2 1 S \"x2\" MandatoryValue:name=ID\n" + " E MandatoryValue'x2' MandatoryValue path:OptionalChildList/children[1]\n" + " 9 0 1 H\n" + " B MandatoryValue'x3' OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[2]\n" + " 9 2 S \"x3\" MandatoryValue:name=ID\n" + " E MandatoryValue'x3' OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[2]\n" + " E OptionalChildList Model\n" + "11 0 H\n" + "------------ diff 1 ------------\n" + " 6 1 H \" \" Whitespace:TerminalRule'WS'\n" + " 7 2 S \"x3\" MandatoryValue:name=ID\n";
changeSerializerTestHelper.operator_tripleEquals(diff, expectation);
}
use of org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Add in project xtext-core by eclipse.
the class PartialSerializerTest method testOptionalChildListInsertIntoEndTwo.
@Test
public void testOptionalChildListInsertIntoEndTwo() {
ITextRegionAccess diff = recordDiff(OptionalChildList.class, "#13 a", (OptionalChildList it) -> {
MandatoryValue newMandatoryValue1 = fac.createMandatoryValue();
newMandatoryValue1.setName("b");
it.getChildren().add(newMandatoryValue1);
MandatoryValue newMandatoryValue2 = fac.createMandatoryValue();
newMandatoryValue2.setName("c");
it.getChildren().add(newMandatoryValue2);
});
String expectation = "0 0 H\n" + " B OptionalChildList Model\n" + "0 3 S \"#13\" Model:'#13'\n" + "3 1 H \" \" Whitespace:TerminalRule'WS'\n" + " B MandatoryValue'a' OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[0]\n" + "4 1 1 S \"a\" MandatoryValue:name=ID\n" + " E MandatoryValue'a' OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[0]\n" + "5 0 1 H\n" + " B MandatoryValue'b' MandatoryValue path:OptionalChildList/children[1]\n" + "5 1 1 S \"b\" MandatoryValue:name=ID\n" + " E MandatoryValue'b' MandatoryValue path:OptionalChildList/children[1]\n" + "6 0 1 H\n" + " B MandatoryValue'c' MandatoryValue path:OptionalChildList/children[2]\n" + "6 1 1 S \"c\" MandatoryValue:name=ID\n" + " E MandatoryValue'c' MandatoryValue path:OptionalChildList/children[2]\n" + " E OptionalChildList Model\n" + "7 0 1 H\n" + "------------ diff 1 ------------\n" + "4 1 S \"a\" MandatoryValue:name=ID\n" + "5 0 H\n";
changeSerializerTestHelper.operator_tripleEquals(diff, expectation);
}
use of org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Add in project xtext-core by eclipse.
the class PartialSerializerTest method testOptionalChildListInsertIntoEndOne.
@Test
public void testOptionalChildListInsertIntoEndOne() {
ITextRegionAccess diff = recordDiff(OptionalChildList.class, "#13 x1", (OptionalChildList it) -> {
MandatoryValue newMandatoryValue = fac.createMandatoryValue();
newMandatoryValue.setName("x2");
it.getChildren().add(newMandatoryValue);
});
String expectation = "0 0 H\n" + " B OptionalChildList Model\n" + "0 3 S \"#13\" Model:'#13'\n" + "3 1 H \" \" Whitespace:TerminalRule'WS'\n" + " B MandatoryValue'x1' OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[0]\n" + "4 2 1 S \"x1\" MandatoryValue:name=ID\n" + " E MandatoryValue'x1' OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[0]\n" + "6 0 1 H\n" + " B MandatoryValue'x2' MandatoryValue path:OptionalChildList/children[1]\n" + "6 2 1 S \"x2\" MandatoryValue:name=ID\n" + " E MandatoryValue'x2' MandatoryValue path:OptionalChildList/children[1]\n" + " E OptionalChildList Model\n" + "8 0 1 H\n" + "------------ diff 1 ------------\n" + "4 2 S \"x1\" MandatoryValue:name=ID\n" + "6 0 H\n";
changeSerializerTestHelper.operator_tripleEquals(diff, expectation);
}
use of org.eclipse.xtext.formatting2.regionaccess.internal.regionaccesstestlanguage.Add in project xtext-core by eclipse.
the class PartialSerializerTest method testOptionalChildListInsertIntoEndThree.
@Test
public void testOptionalChildListInsertIntoEndThree() {
ITextRegionAccess diff = recordDiff(OptionalChildList.class, "#13 a", (OptionalChildList it) -> {
MandatoryValue newMandatoryValue1 = fac.createMandatoryValue();
newMandatoryValue1.setName("b");
it.getChildren().add(newMandatoryValue1);
MandatoryValue newMandatoryValue2 = fac.createMandatoryValue();
newMandatoryValue2.setName("c");
it.getChildren().add(newMandatoryValue2);
MandatoryValue newMandatoryValue3 = fac.createMandatoryValue();
newMandatoryValue3.setName("d");
it.getChildren().add(newMandatoryValue3);
});
String expectation = "0 0 H\n" + " B OptionalChildList Model\n" + "0 3 S \"#13\" Model:'#13'\n" + "3 1 H \" \" Whitespace:TerminalRule'WS'\n" + " B MandatoryValue'a' OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[0]\n" + "4 1 1 S \"a\" MandatoryValue:name=ID\n" + " E MandatoryValue'a' OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[0]\n" + "5 0 1 H\n" + " B MandatoryValue'b' MandatoryValue path:OptionalChildList/children[1]\n" + "5 1 1 S \"b\" MandatoryValue:name=ID\n" + " E MandatoryValue'b' MandatoryValue path:OptionalChildList/children[1]\n" + "6 0 1 H\n" + " B MandatoryValue'c' MandatoryValue path:OptionalChildList/children[2]\n" + "6 1 1 S \"c\" MandatoryValue:name=ID\n" + " E MandatoryValue'c' MandatoryValue path:OptionalChildList/children[2]\n" + "7 0 1 H\n" + " B MandatoryValue'd' MandatoryValue path:OptionalChildList/children[3]\n" + "7 1 1 S \"d\" MandatoryValue:name=ID\n" + " E MandatoryValue'd' MandatoryValue path:OptionalChildList/children[3]\n" + " E OptionalChildList Model\n" + "8 0 1 H\n" + "------------ diff 1 ------------\n" + "4 1 S \"a\" MandatoryValue:name=ID\n" + "5 0 H\n";
changeSerializerTestHelper.operator_tripleEquals(diff, expectation);
}
Aggregations