Search in sources :

Example 6 with EClassInfo

use of org.eclipse.xtext.xtext.ecoreInference.EClassifierInfo.EClassInfo in project xtext-core by eclipse.

the class EClassInfoTest method testContainsCompatibleFeature_02.

@Test
public void testContainsCompatibleFeature_02() throws Exception {
    EcorePackage pack = EcorePackage.eINSTANCE;
    EClass attribute = pack.getEAttribute();
    EClassInfo objectUnderTest = new EClassifierInfo.EClassInfo(attribute, false, Collections.<String>emptySet(), null);
    assertEquals(true, objectUnderTest.containsCompatibleFeature("lowerBound", false, true, pack.getEInt(), new StringBuilder()));
    assertEquals(true, objectUnderTest.containsCompatibleFeature("lowerBound", false, true, pack.getEIntegerObject(), new StringBuilder()));
    assertEquals(false, objectUnderTest.containsCompatibleFeature("lowerBound", false, true, pack.getELong(), new StringBuilder()));
}
Also used : EClass(org.eclipse.emf.ecore.EClass) EClassInfo(org.eclipse.xtext.xtext.ecoreInference.EClassifierInfo.EClassInfo) EcorePackage(org.eclipse.emf.ecore.EcorePackage) Test(org.junit.Test)

Example 7 with EClassInfo

use of org.eclipse.xtext.xtext.ecoreInference.EClassifierInfo.EClassInfo in project xtext-core by eclipse.

the class TypeHierarchyHelperTest method testImcompatipleFeatures.

@Test
public void testImcompatipleFeatures() throws Exception {
    EClassInfo a = addClass("a");
    EClassInfo b = addClass("b");
    EClassInfo c = addClass("c");
    b.addSupertype(a);
    c.addSupertype(a);
    addAttribute(b, INT, "f1");
    addAttribute(c, STRING, "f1");
    assertEquals(0, a.getEClass().getEStructuralFeatures().size());
    assertEquals(1, b.getEClass().getEStructuralFeatures().size());
    assertEquals(1, c.getEClass().getEStructuralFeatures().size());
    liftUpFeatures();
    assertEquals(0, a.getEClass().getEStructuralFeatures().size());
    assertEquals(1, b.getEClass().getEStructuralFeatures().size());
    assertEquals(1, c.getEClass().getEStructuralFeatures().size());
}
Also used : EClassInfo(org.eclipse.xtext.xtext.ecoreInference.EClassifierInfo.EClassInfo) Test(org.junit.Test)

Example 8 with EClassInfo

use of org.eclipse.xtext.xtext.ecoreInference.EClassifierInfo.EClassInfo in project xtext-core by eclipse.

the class TypeHierarchyHelperTest method testDublicateDerivedFeature.

@Test
public void testDublicateDerivedFeature() throws Exception {
    EClassInfo a = addClass("a");
    EClassInfo b = addClass("b");
    EClassInfo c = addClass("c");
    b.addSupertype(a);
    c.addSupertype(b);
    addAttribute(a, INT, "f");
    addAttribute(c, INT, "f");
    assertEquals(1, a.getEClass().getEStructuralFeatures().size());
    assertEquals(0, b.getEClass().getEStructuralFeatures().size());
    assertEquals(1, c.getEClass().getEStructuralFeatures().size());
    initializeHelper();
    helper.removeDuplicateDerivedFeatures();
    assertEquals(1, a.getEClass().getEStructuralFeatures().size());
    assertEquals(0, b.getEClass().getEStructuralFeatures().size());
    assertEquals(0, c.getEClass().getEStructuralFeatures().size());
}
Also used : EClassInfo(org.eclipse.xtext.xtext.ecoreInference.EClassifierInfo.EClassInfo) Test(org.junit.Test)

Example 9 with EClassInfo

use of org.eclipse.xtext.xtext.ecoreInference.EClassifierInfo.EClassInfo in project xtext-core by eclipse.

the class TypeHierarchyHelperTest method testConfigurationOfLiftedReference.

@Test
public void testConfigurationOfLiftedReference() throws Exception {
    EClassInfo a = addClass("a");
    EClassInfo b = addClass("b");
    EClassInfo c = addClass("c");
    b.addSupertype(a);
    c.addSupertype(a);
    EReference refB = addReference(b, a, "ref");
    refB.setContainment(true);
    EReference refC = addReference(c, a, "ref");
    refC.setContainment(true);
    assertEquals(0, a.getEClass().getEStructuralFeatures().size());
    assertEquals(1, b.getEClass().getEStructuralFeatures().size());
    assertEquals(1, c.getEClass().getEStructuralFeatures().size());
    liftUpFeatures();
    assertEquals(1, a.getEClass().getEStructuralFeatures().size());
    assertEquals(0, b.getEClass().getEStructuralFeatures().size());
    assertEquals(0, c.getEClass().getEStructuralFeatures().size());
    EReference refA = (EReference) a.getEClass().getEStructuralFeatures().get(0);
    assertTrue(refA.isContainment());
}
Also used : EClassInfo(org.eclipse.xtext.xtext.ecoreInference.EClassifierInfo.EClassInfo) EReference(org.eclipse.emf.ecore.EReference) Test(org.junit.Test)

Example 10 with EClassInfo

use of org.eclipse.xtext.xtext.ecoreInference.EClassifierInfo.EClassInfo in project xtext-core by eclipse.

the class TypeHierarchyHelperTest method addClass.

private EClassInfo addClass(String name, boolean isGenerated) {
    EClass eClass = EcoreFactory.eINSTANCE.createEClass();
    eClass.setName(name);
    EClassInfo info = (EClassInfo) EClassifierInfo.createEClassInfo(eClass, isGenerated, Collections.<String>emptySet(), GrammarUtil.getGrammar(metamodel));
    infos.addInfo(metamodel, name, info);
    return info;
}
Also used : EClass(org.eclipse.emf.ecore.EClass) EClassInfo(org.eclipse.xtext.xtext.ecoreInference.EClassifierInfo.EClassInfo)

Aggregations

EClassInfo (org.eclipse.xtext.xtext.ecoreInference.EClassifierInfo.EClassInfo)16 Test (org.junit.Test)10 EClass (org.eclipse.emf.ecore.EClass)7 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)3 EcorePackage (org.eclipse.emf.ecore.EcorePackage)3 EReference (org.eclipse.emf.ecore.EReference)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 URI (org.eclipse.emf.common.util.URI)1 EClassifier (org.eclipse.emf.ecore.EClassifier)1 EObject (org.eclipse.emf.ecore.EObject)1 EcoreFactory (org.eclipse.emf.ecore.EcoreFactory)1