use of org.eclipse.xtext.serializer.impl.Serializer in project xtext-core by eclipse.
the class CommentAssociationTest method checkReplaceRegion.
private void checkReplaceRegion(Element element, String expectedText, String completeModel) {
Serializer serializer = get(Serializer.class);
ReplaceRegion replacement = serializer.serializeReplacement(element, SaveOptions.defaultOptions());
assertEquals(expectedText, replacement.getText());
assertEquals(completeModel.indexOf(expectedText), replacement.getOffset());
assertEquals(expectedText.length(), replacement.getLength());
}
use of org.eclipse.xtext.serializer.impl.Serializer in project xtext-core by eclipse.
the class PartialParserTest method testBug370426.
@Test
public void testBug370426() throws Exception {
with(SimpleExpressionsTestLanguageStandaloneSetup.class);
String model = "a/b\n+c";
XtextResource resource = getResourceFromString(model);
assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
// turn /b into a comment
resource.update(model.indexOf("/"), 0, "/");
assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
Serializer serializer = get(Serializer.class);
String newModel = serializer.serialize(EcoreUtil.copy(resource.getContents().get(0)));
assertEquals("a + c", newModel);
// change comment back into /b
resource.update(model.indexOf("/"), 1, "");
assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
assertEquals(model, serialize(resource.getContents().get(0)));
}
Aggregations