use of org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess in project xtext-core by eclipse.
the class PartialSerializerTest method testOptionalChildListInsertIntoMiddle.
@Test
public void testOptionalChildListInsertIntoMiddle() {
final IChangeSerializer.IModification<OptionalChildList> _function = (OptionalChildList it) -> {
EList<MandatoryValue> _children = it.getChildren();
MandatoryValue _createMandatoryValue = this.fac.createMandatoryValue();
final Procedure1<MandatoryValue> _function_1 = (MandatoryValue it_1) -> {
it_1.setName("x2");
};
MandatoryValue _doubleArrow = ObjectExtensions.<MandatoryValue>operator_doubleArrow(_createMandatoryValue, _function_1);
_children.add(1, _doubleArrow);
};
ITextRegionAccess _recordDiff = this.<OptionalChildList>recordDiff(OptionalChildList.class, "#13 x1 x3", _function);
StringConcatenation _builder = new StringConcatenation();
_builder.append("0 0 H");
_builder.newLine();
_builder.append(" ");
_builder.append("B OptionalChildList Model");
_builder.newLine();
_builder.append(" ");
_builder.append("0 3 S \"#13\" Model:\'#13\'");
_builder.newLine();
_builder.append(" ");
_builder.append("3 1 H \" \" Whitespace:TerminalRule\'WS\'");
_builder.newLine();
_builder.append(" ");
_builder.append("B MandatoryValue\'x1\' OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[0]");
_builder.newLine();
_builder.append(" ");
_builder.append("4 2 S \"x1\" MandatoryValue:name=ID");
_builder.newLine();
_builder.append(" ");
_builder.append("E MandatoryValue\'x1\' OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[0]");
_builder.newLine();
_builder.append(" ");
_builder.append("6 1 1 H \" \" Whitespace:TerminalRule\'WS\'");
_builder.newLine();
_builder.append(" ");
_builder.append("B MandatoryValue\'x2\' MandatoryValue path:OptionalChildList/children[1]");
_builder.newLine();
_builder.append(" ");
_builder.append("7 2 1 S \"x2\" MandatoryValue:name=ID");
_builder.newLine();
_builder.append(" ");
_builder.append("E MandatoryValue\'x2\' MandatoryValue path:OptionalChildList/children[1]");
_builder.newLine();
_builder.append(" ");
_builder.append("9 0 1 H");
_builder.newLine();
_builder.append(" ");
_builder.append("B MandatoryValue\'x3\' OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[2]");
_builder.newLine();
_builder.append(" ");
_builder.append("9 2 S \"x3\" MandatoryValue:name=ID");
_builder.newLine();
_builder.append(" ");
_builder.append("E MandatoryValue\'x3\' OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[2]");
_builder.newLine();
_builder.append(" ");
_builder.append("E OptionalChildList Model");
_builder.newLine();
_builder.append("11 0 H");
_builder.newLine();
_builder.append("------------ diff 1 ------------");
_builder.newLine();
_builder.append(" ");
_builder.append("6 1 H \" \" Whitespace:TerminalRule\'WS\'");
_builder.newLine();
_builder.append(" ");
_builder.append("7 2 S \"x3\" MandatoryValue:name=ID");
_builder.newLine();
this._changeSerializerTestHelper.operator_tripleEquals(_recordDiff, _builder);
}
use of org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess in project xtext-core by eclipse.
the class PartialSerializerTest method testOptionalChildRemoveListAllOne.
@Test
public void testOptionalChildRemoveListAllOne() {
final IChangeSerializer.IModification<OptionalChildList> _function = (OptionalChildList it) -> {
EcoreUtil.remove(it.getChildren().get(0));
};
ITextRegionAccess _recordDiff = this.<OptionalChildList>recordDiff(OptionalChildList.class, "#13 x1", _function);
StringConcatenation _builder = new StringConcatenation();
_builder.append("0 0 H");
_builder.newLine();
_builder.append(" ");
_builder.append("B OptionalChildList Model");
_builder.newLine();
_builder.append("0 3 S \"#13\" Model:\'#13\'");
_builder.newLine();
_builder.append(" ");
_builder.append("E OptionalChildList Model");
_builder.newLine();
_builder.append("3 1 1 H \" \" Whitespace:TerminalRule\'WS\'");
_builder.newLine();
_builder.append("------------ diff 1 ------------");
_builder.newLine();
_builder.append("3 1 H \" \" Whitespace:TerminalRule\'WS\'");
_builder.newLine();
_builder.append("4 2 S \"x1\" MandatoryValue:name=ID");
_builder.newLine();
_builder.append("6 0 H");
_builder.newLine();
this._changeSerializerTestHelper.operator_tripleEquals(_recordDiff, _builder);
}
use of org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess in project xtext-core by eclipse.
the class PartialSerializerTest method testOptionalChildListInsertIntoEndOne.
@Test
public void testOptionalChildListInsertIntoEndOne() {
final IChangeSerializer.IModification<OptionalChildList> _function = (OptionalChildList it) -> {
EList<MandatoryValue> _children = it.getChildren();
MandatoryValue _createMandatoryValue = this.fac.createMandatoryValue();
final Procedure1<MandatoryValue> _function_1 = (MandatoryValue it_1) -> {
it_1.setName("x2");
};
MandatoryValue _doubleArrow = ObjectExtensions.<MandatoryValue>operator_doubleArrow(_createMandatoryValue, _function_1);
_children.add(_doubleArrow);
};
ITextRegionAccess _recordDiff = this.<OptionalChildList>recordDiff(OptionalChildList.class, "#13 x1", _function);
StringConcatenation _builder = new StringConcatenation();
_builder.append("0 0 H");
_builder.newLine();
_builder.append(" ");
_builder.append("B OptionalChildList Model");
_builder.newLine();
_builder.append("0 3 S \"#13\" Model:\'#13\'");
_builder.newLine();
_builder.append("3 1 H \" \" Whitespace:TerminalRule\'WS\'");
_builder.newLine();
_builder.append(" ");
_builder.append("B MandatoryValue\'x1\' OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[0]");
_builder.newLine();
_builder.append("4 2 1 S \"x1\" MandatoryValue:name=ID");
_builder.newLine();
_builder.append(" ");
_builder.append("E MandatoryValue\'x1\' OptionalChildList:children+=MandatoryValue path:OptionalChildList/children[0]");
_builder.newLine();
_builder.append("6 0 1 H");
_builder.newLine();
_builder.append(" ");
_builder.append("B MandatoryValue\'x2\' MandatoryValue path:OptionalChildList/children[1]");
_builder.newLine();
_builder.append("6 2 1 S \"x2\" MandatoryValue:name=ID");
_builder.newLine();
_builder.append(" ");
_builder.append("E MandatoryValue\'x2\' MandatoryValue path:OptionalChildList/children[1]");
_builder.newLine();
_builder.append(" ");
_builder.append("E OptionalChildList Model");
_builder.newLine();
_builder.append("8 0 1 H");
_builder.newLine();
_builder.append("------------ diff 1 ------------");
_builder.newLine();
_builder.append("4 2 S \"x1\" MandatoryValue:name=ID");
_builder.newLine();
_builder.append("6 0 H");
_builder.newLine();
this._changeSerializerTestHelper.operator_tripleEquals(_recordDiff, _builder);
}
use of org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess in project xtext-core by eclipse.
the class ImportTestHelper method operator_tripleEquals.
public void operator_tripleEquals(final ITextRegionAccess actual, final CharSequence expected) {
final String actualString = new TextRegionAccessToString().withRegionAccess(actual).hideColumnExplanation().toString();
Assert.assertEquals(expected.toString().trim(), actualString.trim());
}
use of org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess in project xtext-core by eclipse.
the class RegionAccessBuilderTest method assertToStringDoesNotCrash.
private void assertToStringDoesNotCrash(final ITextRegionAccess access) {
IHiddenRegion _previousHiddenRegion = access.regionForRootEObject().getPreviousHiddenRegion();
ISequentialRegion current = ((ISequentialRegion) _previousHiddenRegion);
while ((current != null)) {
{
Assert.assertNotNull(current.toString());
boolean _matched = false;
if (current instanceof IHiddenRegion) {
_matched = true;
current = ((IHiddenRegion) current).getNextSemanticRegion();
}
if (!_matched) {
if (current instanceof ISemanticRegion) {
_matched = true;
Assert.assertNotNull(((ISemanticRegion) current).getEObjectRegion().toString());
current = ((ISemanticRegion) current).getNextHiddenRegion();
}
}
}
}
}
Aggregations