Search in sources :

Example 6 with ENamedElement

use of org.eclipse.emf.ecore.ENamedElement in project xtext-core by eclipse.

the class NamesAreUniqueValidationHelperTest method testManyOneDup.

@SuppressWarnings("deprecation")
@Test
public void testManyOneDup() {
    List<ENamedElement> elements = new ArrayList<>();
    for (int i = 0; i < MANY; i++) {
        EClass c = createEClass();
        if (i == MANY - 1) {
            c.setName("i1234");
        } else {
            c.setName("i" + i);
        }
        elements.add(c);
    }
    maxCallCount = 0;
    expected.add(elements.get(1_234));
    expected.add(elements.get(MANY - 1));
    helper.checkUniqueNames(Scopes.scopedElementsFor(elements), this, this);
}
Also used : EClass(org.eclipse.emf.ecore.EClass) ENamedElement(org.eclipse.emf.ecore.ENamedElement) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with ENamedElement

use of org.eclipse.emf.ecore.ENamedElement in project xtext-core by eclipse.

the class NamesAreUniqueValidationHelperTest method testCreatedErrors_03_context.

@Test
public void testCreatedErrors_03_context() {
    maxCallCount = 0;
    ImmutableList<ENamedElement> elements = ImmutableList.of(createEClass(), createEDataType(), createEPackage());
    for (ENamedElement classifier : elements) {
        classifier.setName("Same");
    }
    expected.addAll(elements.subList(0, 2));
    helper.checkUniqueNames(new LocalUniqueNameContext(elements, this), this);
    assertEquals(elements.size(), callCount);
    assertTrue(expected.isEmpty());
}
Also used : ENamedElement(org.eclipse.emf.ecore.ENamedElement) Test(org.junit.Test)

Example 8 with ENamedElement

use of org.eclipse.emf.ecore.ENamedElement in project xtext-core by eclipse.

the class NamesAreUniqueValidationHelperTest method testCreatedErrors_04.

@SuppressWarnings("deprecation")
@Test
public void testCreatedErrors_04() {
    maxCallCount = 0;
    ImmutableList<ENamedElement> elements = ImmutableList.of(createEClass(), createEDataType(), createEPackage(), createEPackage());
    for (ENamedElement classifier : elements) {
        classifier.setName("Same");
    }
    expected.addAll(elements);
    helper.checkUniqueNames(Scopes.scopedElementsFor(elements), this, this);
    assertEquals(elements.size(), callCount);
    assertTrue(expected.isEmpty());
}
Also used : ENamedElement(org.eclipse.emf.ecore.ENamedElement) Test(org.junit.Test)

Example 9 with ENamedElement

use of org.eclipse.emf.ecore.ENamedElement in project xtext-core by eclipse.

the class NamesAreUniqueValidationHelperTest method testCreatedErrors_07.

@SuppressWarnings("deprecation")
@Test
public void testCreatedErrors_07() {
    maxCallCount = 0;
    ImmutableList<ENamedElement> elements = ImmutableList.of(createEPackage(), createEDataType(), EcoreFactory.eINSTANCE.createEEnumLiteral());
    for (ENamedElement classifier : elements) {
        classifier.setName("Same");
    }
    expected.add(elements.get(0));
    expected.add(elements.get(2));
    helper.checkUniqueNames(Scopes.scopedElementsFor(elements), this, this);
    assertEquals(elements.size(), callCount);
    assertTrue(expected.isEmpty());
}
Also used : ENamedElement(org.eclipse.emf.ecore.ENamedElement) Test(org.junit.Test)

Example 10 with ENamedElement

use of org.eclipse.emf.ecore.ENamedElement in project xtext-core by eclipse.

the class NamesAreUniqueValidationHelperTest method testCreatedErrors_03.

@SuppressWarnings("deprecation")
@Test
public void testCreatedErrors_03() {
    maxCallCount = 0;
    ImmutableList<ENamedElement> elements = ImmutableList.of(createEClass(), createEDataType(), createEPackage());
    for (ENamedElement classifier : elements) {
        classifier.setName("Same");
    }
    expected.addAll(elements.subList(0, 2));
    helper.checkUniqueNames(Scopes.scopedElementsFor(elements), this, this);
    assertEquals(elements.size(), callCount);
    assertTrue(expected.isEmpty());
}
Also used : ENamedElement(org.eclipse.emf.ecore.ENamedElement) Test(org.junit.Test)

Aggregations

ENamedElement (org.eclipse.emf.ecore.ENamedElement)26 Test (org.junit.Test)19 EClass (org.eclipse.emf.ecore.EClass)10 ArrayList (java.util.ArrayList)6 EObject (org.eclipse.emf.ecore.EObject)4 QualifiedName (org.eclipse.xtext.naming.QualifiedName)4 Collection (java.util.Collection)3 Resource (org.eclipse.emf.ecore.resource.Resource)3 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)3 EClassifier (org.eclipse.emf.ecore.EClassifier)2 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)2 InternalEObject (org.eclipse.emf.ecore.InternalEObject)2 IQualifiedNameProvider (org.eclipse.xtext.naming.IQualifiedNameProvider)2 OperationCanceledError (org.eclipse.xtext.service.OperationCanceledError)2 Before (org.junit.Before)2 IdentityHashMap (java.util.IdentityHashMap)1 EPackage (org.eclipse.emf.ecore.EPackage)1 EcoreFactory (org.eclipse.emf.ecore.EcoreFactory)1 ResourceImpl (org.eclipse.emf.ecore.resource.impl.ResourceImpl)1 XMLResourceImpl (org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl)1