use of org.eclipse.emf.ecore.EClass in project xtext-core by eclipse.
the class NamesAreUniqueValidationHelperTest method testErrorMessage_04.
@Test
public void testErrorMessage_04() {
EClass eClass = createEClass();
eClass.setName("EClassName");
EAttribute attribute = EcoreFactory.eINSTANCE.createEAttribute();
attribute.setName("Attribute");
eClass.getEStructuralFeatures().add(attribute);
IEObjectDescription description = EObjectDescription.create(QualifiedName.create(attribute.getName()), attribute);
String errorMessage = helper.getDuplicateNameErrorMessage(description, EcorePackage.Literals.EATTRIBUTE, EcorePackage.Literals.ENAMED_ELEMENT__NAME);
assertEquals("Duplicate EAttribute 'Attribute' in EClass 'EClassName'", errorMessage);
}
use of org.eclipse.emf.ecore.EClass in project xtext-core by eclipse.
the class NamesAreUniqueValidationHelperTest method testErrorMessage_01.
@Test
public void testErrorMessage_01() {
EClass eClass = createEClass();
eClass.setName("EClassName");
IEObjectDescription description = EObjectDescription.create(QualifiedName.create(eClass.getName()), eClass);
String errorMessage = helper.getDuplicateNameErrorMessage(description, EcorePackage.Literals.ECLASSIFIER, EcorePackage.Literals.ENAMED_ELEMENT__NAME);
assertEquals("Duplicate EClassifier 'EClassName'", errorMessage);
}
use of org.eclipse.emf.ecore.EClass in project xtext-core by eclipse.
the class NamesAreUniqueValidationHelperTest method testErrorMessage_03.
@Test
public void testErrorMessage_03() {
EClass eClass = createEClass();
eClass.setName("EClassName");
EAttribute attribute = EcoreFactory.eINSTANCE.createEAttribute();
attribute.setName("Attribute");
eClass.getEStructuralFeatures().add(attribute);
IEObjectDescription description = EObjectDescription.create(QualifiedName.create(eClass.getName(), attribute.getName()), attribute);
String errorMessage = helper.getDuplicateNameErrorMessage(description, EcorePackage.Literals.EATTRIBUTE, EcorePackage.Literals.ENAMED_ELEMENT__NAME);
assertEquals("Duplicate EAttribute 'Attribute' in EClass 'EClassName'", errorMessage);
}
use of org.eclipse.emf.ecore.EClass in project xtext-core by eclipse.
the class NamesAreUniqueValidatorTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
context = Maps.newHashMap();
validator = new NamesAreUniqueValidator() {
@Override
protected Map<Object, Object> getContext() {
return context;
}
};
validator.setResourceServiceProviderRegistry(this);
validator.setHelper(this);
final DefaultResourceDescriptionStrategy strategy = new DefaultResourceDescriptionStrategy();
strategy.setQualifiedNameProvider(new IQualifiedNameProvider.AbstractImpl() {
@Override
public QualifiedName getFullyQualifiedName(EObject obj) {
return QualifiedName.create(SimpleAttributeResolver.NAME_RESOLVER.getValue(obj));
}
});
resourceDescriptionManager = new DefaultResourceDescriptionManager() {
@Override
public IResourceDescription getResourceDescription(Resource resource) {
DefaultResourceDescription resourceDescription = new DefaultResourceDescription(resource, strategy);
return resourceDescription;
}
};
callCount = 0;
resource = new ResourceImpl();
resource.getContents().add(EcoreFactory.eINSTANCE.createEClass());
resource.getContents().add(EcoreFactory.eINSTANCE.createEClass());
resource.getContents().add(EcoreFactory.eINSTANCE.createEClass());
for (int i = 0; i < resource.getContents().size(); i++) {
EClass clazz = (EClass) resource.getContents().get(i);
clazz.setName(String.valueOf(i));
}
}
use of org.eclipse.emf.ecore.EClass in project xtext-core by eclipse.
the class ResourceValidatorImplTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
with(new LangATestLanguageStandaloneSetup());
EValidator.Registry.INSTANCE.put(LangATestLanguagePackage.eINSTANCE, new EValidator() {
@Override
public boolean validate(EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context) {
if (eObject instanceof Type) {
String name = ((Type) eObject).getName();
if (name.equals("Foo"))
diagnostics.add(new BasicDiagnostic(Diagnostic.ERROR, "", 12, "Foo", null));
if (name.equals("Bar"))
diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING, "", 12, "Foo", null));
}
return true;
}
@Override
public boolean validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context) {
return validate(eObject, diagnostics, context);
}
@Override
public boolean validate(EDataType eDataType, Object value, DiagnosticChain diagnostics, Map<Object, Object> context) {
return false;
}
});
}
Aggregations