use of org.eclipse.xtext.example.domainmodel.domainmodel.DomainModel in project xtext-eclipse by eclipse.
the class ValidationTests method testDuplicatedOperation.
@Test
public void testDuplicatedOperation() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("entity E {");
_builder.newLine();
_builder.append("\t");
_builder.append("op foo() {}");
_builder.newLine();
_builder.append("\t");
_builder.append("op foo() {}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final String model = _builder.toString();
DomainModel _parse = this._parseHelper.parse(model);
final Procedure1<DomainModel> _function = (DomainModel it) -> {
this.assertNumberOfIssues(it, 2);
this._validationTestHelper.assertError(it, DomainmodelPackage.Literals.OPERATION, org.eclipse.xtext.example.domainmodel.validation.IssueCodes.DUPLICATE_OPERATION, model.indexOf("foo"), 3, "Duplicate operation foo");
this._validationTestHelper.assertError(it, DomainmodelPackage.Literals.OPERATION, org.eclipse.xtext.example.domainmodel.validation.IssueCodes.DUPLICATE_OPERATION, model.lastIndexOf("foo"), 3, "Duplicate operation foo");
};
ObjectExtensions.<DomainModel>operator_doubleArrow(_parse, _function);
}
use of org.eclipse.xtext.example.domainmodel.domainmodel.DomainModel in project xtext-eclipse by eclipse.
the class ValidationTests method testDuplicatedOperationWithDifferentSignatureWithSameTypeErasure.
@Test
public void testDuplicatedOperationWithDifferentSignatureWithSameTypeErasure() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("entity E {");
_builder.newLine();
_builder.append("\t");
_builder.append("op m(java.util.List<String> l1) {}");
_builder.newLine();
_builder.append("\t");
_builder.append("op m(java.util.List<Integer> l2) {}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final String model = _builder.toString();
DomainModel _parse = this._parseHelper.parse(model);
final Procedure1<DomainModel> _function = (DomainModel it) -> {
this.assertNumberOfIssues(it, 2);
this._validationTestHelper.assertError(it, DomainmodelPackage.Literals.OPERATION, org.eclipse.xtext.example.domainmodel.validation.IssueCodes.DUPLICATE_OPERATION, model.indexOf("m"), 1, "Duplicate operation m");
this._validationTestHelper.assertError(it, DomainmodelPackage.Literals.OPERATION, org.eclipse.xtext.example.domainmodel.validation.IssueCodes.DUPLICATE_OPERATION, model.lastIndexOf("m"), 1, "Duplicate operation m");
};
ObjectExtensions.<DomainModel>operator_doubleArrow(_parse, _function);
}
use of org.eclipse.xtext.example.domainmodel.domainmodel.DomainModel in project xtext-eclipse by eclipse.
the class ValidationTests method testDuplicatedProperty.
@Test
public void testDuplicatedProperty() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("entity E {");
_builder.newLine();
_builder.append("\t");
_builder.append("p : String");
_builder.newLine();
_builder.append("\t");
_builder.append("p : String");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final String model = _builder.toString();
DomainModel _parse = this._parseHelper.parse(model);
final Procedure1<DomainModel> _function = (DomainModel it) -> {
this.assertNumberOfIssues(it, 2);
this._validationTestHelper.assertError(it, DomainmodelPackage.Literals.PROPERTY, org.eclipse.xtext.example.domainmodel.validation.IssueCodes.DUPLICATE_PROPERTY, model.indexOf("p"), 1, "Duplicate property p");
this._validationTestHelper.assertError(it, DomainmodelPackage.Literals.PROPERTY, org.eclipse.xtext.example.domainmodel.validation.IssueCodes.DUPLICATE_PROPERTY, model.lastIndexOf("p"), 1, "Duplicate property p");
};
ObjectExtensions.<DomainModel>operator_doubleArrow(_parse, _function);
}
use of org.eclipse.xtext.example.domainmodel.domainmodel.DomainModel in project xtext-eclipse by eclipse.
the class OrganizeImportsTest method assertIsOrganizedTo.
protected void assertIsOrganizedTo(final CharSequence model, final CharSequence expected) throws Exception {
final DomainModel domainModel = this._parseHelper.parse(model.toString());
Resource _eResource = domainModel.eResource();
final List<ReplaceRegion> changes = this.importOrganizer.getOrganizedImportChanges(((XtextResource) _eResource));
final StringBuilder builder = new StringBuilder(model);
final Function1<ReplaceRegion, Integer> _function = (ReplaceRegion it) -> {
return Integer.valueOf(it.getOffset());
};
final List<ReplaceRegion> sortedChanges = IterableExtensions.<ReplaceRegion, Integer>sortBy(changes, _function);
ReplaceRegion lastChange = null;
for (final ReplaceRegion it : sortedChanges) {
{
if (((lastChange != null) && (lastChange.getEndOffset() > it.getOffset()))) {
Assert.fail(((("Overlapping text edits: " + lastChange) + " and ") + it));
}
lastChange = it;
}
}
List<ReplaceRegion> _reverse = ListExtensions.<ReplaceRegion>reverse(sortedChanges);
for (final ReplaceRegion it_1 : _reverse) {
int _offset = it_1.getOffset();
int _offset_1 = it_1.getOffset();
int _length = it_1.getLength();
int _plus = (_offset_1 + _length);
builder.replace(_offset, _plus, it_1.getText());
}
Assert.assertEquals(expected.toString(), builder.toString());
}
Aggregations