Search in sources :

Example 11 with ENamedElement

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

the class NamesAreUniqueValidationHelperTest method testManyUnique_context.

@Test
public void testManyUnique_context() {
    List<ENamedElement> elements = new ArrayList<>();
    for (int i = 0; i < MANY; i++) {
        EClass c = createEClass();
        c.setName("i" + i);
        elements.add(c);
    }
    maxCallCount = 0;
    helper.checkUniqueNames(new LocalUniqueNameContext(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 12 with ENamedElement

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

the class NamesAreUniqueValidationHelperTest method testManyUnique.

@SuppressWarnings("deprecation")
@Test
public void testManyUnique() {
    List<ENamedElement> elements = new ArrayList<>();
    for (int i = 0; i < MANY; i++) {
        EClass c = createEClass();
        c.setName("i" + i);
        elements.add(c);
    }
    maxCallCount = 0;
    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 13 with ENamedElement

use of org.eclipse.emf.ecore.ENamedElement in project tdi-studio-se by Talend.

the class BusinessElementTypes method getElement.

/**
     * Returns 'type' of the ecore object associated with the hint.
     * 
     * @generated
     */
public static ENamedElement getElement(IAdaptable hint) {
    Object type = hint.getAdapter(IElementType.class);
    if (elements == null) {
        elements = new IdentityHashMap();
        elements.put(BusinessProcess_79, BusinessPackage.eINSTANCE.getBusinessProcess());
        elements.put(ActionBusinessItem_1001, BusinessPackage.eINSTANCE.getActionBusinessItem());
        elements.put(TerminalBusinessItem_1002, BusinessPackage.eINSTANCE.getTerminalBusinessItem());
        elements.put(DocumentBusinessItem_1003, BusinessPackage.eINSTANCE.getDocumentBusinessItem());
        elements.put(DatabaseBusinessItem_1004, BusinessPackage.eINSTANCE.getDatabaseBusinessItem());
        elements.put(ListBusinessItem_1005, BusinessPackage.eINSTANCE.getListBusinessItem());
        elements.put(DataBusinessItem_1006, BusinessPackage.eINSTANCE.getDataBusinessItem());
        elements.put(InputBusinessItem_1007, BusinessPackage.eINSTANCE.getInputBusinessItem());
        elements.put(DecisionBusinessItem_1008, BusinessPackage.eINSTANCE.getDecisionBusinessItem());
        elements.put(ActorBusinessItem_1009, BusinessPackage.eINSTANCE.getActorBusinessItem());
        elements.put(EllipseBusinessItem_1010, BusinessPackage.eINSTANCE.getEllipseBusinessItem());
        elements.put(GearBusinessItem_1011, BusinessPackage.eINSTANCE.getGearBusinessItem());
        elements.put(BusinessItemRelationship_3001, BusinessPackage.eINSTANCE.getBusinessItemRelationship());
        elements.put(DirectionalBusinessItemRelationship_3002, BusinessPackage.eINSTANCE.getDirectionalBusinessItemRelationship());
        elements.put(BidirectionalBusinessItemRelationship_3003, BusinessPackage.eINSTANCE.getBidirectionalBusinessItemRelationship());
    }
    return (ENamedElement) elements.get(type);
}
Also used : IdentityHashMap(java.util.IdentityHashMap) ENamedElement(org.eclipse.emf.ecore.ENamedElement)

Example 14 with ENamedElement

use of org.eclipse.emf.ecore.ENamedElement in project n4js by eclipse.

the class OrderedEmfFormatter method refToStr.

private static void refToStr(EObject obj, EReference ref, String indent, Appendable buf) throws Exception {
    Object o = obj.eGet(ref);
    if (o instanceof EObject) {
        EObject eo = (EObject) o;
        if (eo instanceof ENamedElement)
            buf.append("'").append(((ENamedElement) eo).getName()).append("' ");
        buf.append("ref: ");
        getURI(obj, eo, buf);
        return;
    }
    if (o instanceof Collection<?>) {
        String innerIndent = indent + INDENT;
        buf.append("[");
        int counter = 0;
        Collection<?> coll = (Collection<?>) o;
        for (Iterator<?> i = coll.iterator(); i.hasNext(); ) {
            Object item = i.next();
            if (counter == 0)
                buf.append('\n');
            buf.append(innerIndent);
            printInt(counter++, coll.size(), buf);
            buf.append(": ");
            getURI(obj, (EObject) item, buf);
            if (i.hasNext())
                buf.append(",\n");
            else
                buf.append('\n').append(indent);
        }
        buf.append("]");
        return;
    }
    buf.append("?????");
}
Also used : EObject(org.eclipse.emf.ecore.EObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject) ENamedElement(org.eclipse.emf.ecore.ENamedElement) Collection(java.util.Collection) EObject(org.eclipse.emf.ecore.EObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject)

Example 15 with ENamedElement

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

the class NamesAreUniqueValidationHelperTest method testCreatedErrors_06_context.

@Test
public void testCreatedErrors_06_context() {
    maxCallCount = 1;
    ImmutableList<ENamedElement> elements = ImmutableList.of(createEPackage(), createEDataType(), createEPackage());
    for (ENamedElement classifier : elements) {
        classifier.setName("Same");
    }
    try {
        helper.checkUniqueNames(new LocalUniqueNameContext(elements, this), this);
        fail("cancellation expected");
    } catch (OperationCanceledError e) {
    }
    assertEquals(1, callCount);
}
Also used : OperationCanceledError(org.eclipse.xtext.service.OperationCanceledError) 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