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()));
}
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());
}
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());
}
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());
}
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;
}
Aggregations