use of org.eclipse.emf.ecore.EClass in project xtext-core by eclipse.
the class DeclarativeScopeProviderTest method testScopeByReference.
@SuppressWarnings("unused")
@Test
public void testScopeByReference() throws Exception {
final IScope a = new SimpleScope(IScope.NULLSCOPE, Collections.<IEObjectDescription>emptySet());
final IScope b = new SimpleScope(IScope.NULLSCOPE, Collections.<IEObjectDescription>emptySet());
final IScope c = new SimpleScope(IScope.NULLSCOPE, Collections.<IEObjectDescription>emptySet());
AbstractDeclarativeScopeProvider provider = new AbstractDeclarativeScopeProvider() {
private IScope scope_EClass_eSuperTypes(EClassifier clazz, EReference ref) {
return a;
}
private IScope scope_EClass(EClass clazz, EReference ref) {
return c;
}
private IScope scope_EClass(EReference ctx, EReference ref) {
return b;
}
};
EReference details = EcorePackage.eINSTANCE.getEClass_ESuperTypes();
assertEquals(a, provider.getScope(details, details));
assertEquals(a, provider.getScope(details.getEContainingClass(), details));
}
use of org.eclipse.emf.ecore.EClass in project xtext-core by eclipse.
the class DeclarativeScopeProviderTest method testPolymorphic.
@SuppressWarnings("unused")
@Test
public void testPolymorphic() throws Exception {
final IScope a = new SimpleScope(IScope.NULLSCOPE, Collections.<IEObjectDescription>emptySet());
final IScope b = new SimpleScope(IScope.NULLSCOPE, Collections.<IEObjectDescription>emptySet());
final IScope c = new SimpleScope(IScope.NULLSCOPE, Collections.<IEObjectDescription>emptySet());
AbstractDeclarativeScopeProvider provider = new AbstractDeclarativeScopeProvider() {
private IScope scope_EClass(EClassifier clazz, EReference ref) {
return a;
}
private IScope scope_EClass(EClass clazz, EReference ref) {
return c;
}
private IScope scope_EClass(EReference ctx, EReference ref) {
return b;
}
};
EReference details = EcorePackage.eINSTANCE.getEClass_ESuperTypes();
assertEquals(b, provider.getScope(details, details));
assertEquals(c, provider.getScope(details.getEContainingClass(), details));
}
use of org.eclipse.emf.ecore.EClass in project xtext-core by eclipse.
the class DeclarativeScopeProviderTest method testScopeByType2.
@SuppressWarnings("unused")
@Test
public void testScopeByType2() throws Exception {
final IScope a = new SimpleScope(IScope.NULLSCOPE, Collections.<IEObjectDescription>emptySet());
final IScope b = new SimpleScope(IScope.NULLSCOPE, Collections.<IEObjectDescription>emptySet());
final IScope c = new SimpleScope(IScope.NULLSCOPE, Collections.<IEObjectDescription>emptySet());
AbstractDeclarativeScopeProvider provider = new AbstractDeclarativeScopeProvider() {
private IScope scope_EClass(EClassifier clazz, EReference ref) {
return a;
}
private IScope scope_EClass(EClass clazz, EReference ref) {
return c;
}
private IScope scope_EClass(EReference ctx, EReference ref) {
return b;
}
};
EReference details = EcorePackage.eINSTANCE.getEClass_ESuperTypes();
assertEquals(b, provider.getScope(details, details));
assertEquals(c, provider.getScope(details.getEContainingClass(), details));
}
use of org.eclipse.emf.ecore.EClass in project xtext-core by eclipse.
the class Xtext2EcoreTransformerTest method testCommonTerminalsFeatureTypes.
@Test
public void testCommonTerminalsFeatureTypes() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("grammar test with org.eclipse.xtext.common.Terminals generate test \'http://test\' RuleA: featureA=ID featureB=INT featureC=STRING;");
final String grammar = _builder.toString();
EPackage ePackage = this.getEPackageFromGrammar(grammar);
EClassifier _type = this.<EClassifier>type(ePackage, "RuleA");
EClass ruleA = ((EClass) _type);
Assert.assertNotNull(ruleA);
Assert.assertEquals(3, ruleA.getEAttributes().size());
this.assertAttributeConfiguration(ruleA, 0, "featureA", "EString");
this.assertAttributeConfiguration(ruleA, 1, "featureB", "EInt");
this.assertAttributeConfiguration(ruleA, 2, "featureC", "EString");
}
use of org.eclipse.emf.ecore.EClass in project xtext-core by eclipse.
the class Xtext2EcoreTransformerTest method testBug346685_b04.
@Test
public void testBug346685_b04() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("grammar test with org.eclipse.xtext.common.Terminals generate test \'http://test\'");
String grammar = _builder.toString();
String _grammar = grammar;
grammar = (_grammar + " Model: A? ({D.a = current} b = B) c=C? ;\n");
String _grammar_1 = grammar;
grammar = (_grammar_1 + " A: {A} \'a\';\n");
String _grammar_2 = grammar;
grammar = (_grammar_2 + " B: {B} \'c\';\n");
String _grammar_3 = grammar;
grammar = (_grammar_3 + " C: {C} \'b\';\n");
EPackage ePackage = this.getEPackageFromGrammar(grammar);
Assert.assertEquals(5, ePackage.getEClassifiers().size());
EClassifier _type = this.<EClassifier>type(ePackage, "Model");
EClass typeModel = ((EClass) _type);
Assert.assertNotNull(typeModel);
Assert.assertTrue(this.features(typeModel).isEmpty());
EClassifier _type_1 = this.<EClassifier>type(ePackage, "A");
EClass typeA = ((EClass) _type_1);
Assert.assertNotNull(typeA);
Assert.assertTrue(this.features(typeA).isEmpty());
Assert.assertEquals(1, typeA.getESuperTypes().size());
Assert.assertSame(typeModel, IterableExtensions.<EClass>head(typeA.getESuperTypes()));
EClassifier _type_2 = this.<EClassifier>type(ePackage, "B");
EClass typeB = ((EClass) _type_2);
Assert.assertNotNull(typeB);
Assert.assertTrue(this.features(typeB).isEmpty());
EClassifier _type_3 = this.<EClassifier>type(ePackage, "C");
EClass typeC = ((EClass) _type_3);
Assert.assertNotNull(typeC);
Assert.assertTrue(this.features(typeC).isEmpty());
EClassifier _type_4 = this.<EClassifier>type(ePackage, "D");
EClass typeD = ((EClass) _type_4);
Assert.assertNotNull(typeD);
Assert.assertNotNull(this.<EStructuralFeature>feature(typeD, "a"));
Assert.assertNotNull(this.<EStructuralFeature>feature(typeD, "b"));
Assert.assertNotNull(this.<EStructuralFeature>feature(typeD, "c"));
Assert.assertEquals(3, this.features(typeD).size());
}
Aggregations