use of org.eclipse.emf.ecore.EClass in project xtext-core by eclipse.
the class Xtext2EcoreTransformerTest method testBug346685_a09.
@Test
public void testBug346685_a09() 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 + " RuleA returns TypeA: RuleB ({TypeC.x=current} \'x\' | {TypeD.x=current} \'y\' | \'z\')? name+=STRING;");
String _grammar_1 = grammar;
grammar = (_grammar_1 + " RuleB returns TypeB: {TypeB} \'ignore\';");
EPackage ePackage = this.getEPackageFromGrammar(grammar);
Assert.assertEquals(4, ePackage.getEClassifiers().size());
EClassifier _type = this.<EClassifier>type(ePackage, "TypeA");
EClass typeA = ((EClass) _type);
Assert.assertNotNull(typeA);
Assert.assertNotNull(this.<EStructuralFeature>feature(typeA, "name"));
Assert.assertEquals(1, this.features(typeA).size());
EClassifier _type_1 = this.<EClassifier>type(ePackage, "TypeB");
EClass typeB = ((EClass) _type_1);
Assert.assertNotNull(typeB);
Assert.assertTrue(this.features(typeB).isEmpty());
EClassifier _type_2 = this.<EClassifier>type(ePackage, "TypeC");
EClass typeC = ((EClass) _type_2);
Assert.assertNotNull(typeC);
Assert.assertNotNull(this.<EStructuralFeature>feature(typeC, "x"));
Assert.assertEquals(1, this.features(typeC).size());
EClassifier _type_3 = this.<EClassifier>type(ePackage, "TypeD");
EClass typeD = ((EClass) _type_3);
Assert.assertNotNull(typeD);
Assert.assertNotNull(this.<EStructuralFeature>feature(typeD, "x"));
Assert.assertEquals(1, this.features(typeD).size());
}
use of org.eclipse.emf.ecore.EClass in project xtext-core by eclipse.
the class Xtext2EcoreTransformerTest method testBug346685_a03.
@Test
public void testBug346685_a03() 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 + " RuleA returns TypeA: RuleB ({TypeC.x=current} \'x\' | {TypeD.x=current} \'y\')? name+=STRING;");
String _grammar_1 = grammar;
grammar = (_grammar_1 + " RuleB returns TypeB: {TypeB} name+=ID;");
EPackage ePackage = this.getEPackageFromGrammar(grammar);
Assert.assertEquals(4, ePackage.getEClassifiers().size());
EClassifier _type = this.<EClassifier>type(ePackage, "TypeA");
EClass typeA = ((EClass) _type);
Assert.assertNotNull(typeA);
Assert.assertNotNull(this.<EStructuralFeature>feature(typeA, "name"));
Assert.assertEquals(1, this.features(typeA).size());
EClassifier _type_1 = this.<EClassifier>type(ePackage, "TypeB");
EClass typeB = ((EClass) _type_1);
Assert.assertNotNull(typeB);
Assert.assertTrue(this.features(typeB).isEmpty());
EClassifier _type_2 = this.<EClassifier>type(ePackage, "TypeC");
EClass typeC = ((EClass) _type_2);
Assert.assertNotNull(typeC);
Assert.assertNotNull(this.<EStructuralFeature>feature(typeC, "x"));
Assert.assertEquals(1, this.features(typeC).size());
EClassifier _type_3 = this.<EClassifier>type(ePackage, "TypeD");
EClass typeD = ((EClass) _type_3);
Assert.assertNotNull(typeD);
Assert.assertNotNull(this.<EStructuralFeature>feature(typeD, "x"));
Assert.assertEquals(1, this.features(typeD).size());
}
use of org.eclipse.emf.ecore.EClass in project xtext-core by eclipse.
the class Xtext2EcoreTransformerTest method testFeaturesAndInheritanceOfNestedRuleCalls_02.
@Test
public void testFeaturesAndInheritanceOfNestedRuleCalls_02() 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 + " RuleA: ((RuleB|RuleC featureC1=ID)? featureABC=ID | (RuleC|RuleD featureD1=ID) featureCD=ID) featureA=ID;");
String _grammar_1 = grammar;
grammar = (_grammar_1 + " RuleB: featureB2=ID;");
String _grammar_2 = grammar;
grammar = (_grammar_2 + " RuleC: featureC2=ID;");
String _grammar_3 = grammar;
grammar = (_grammar_3 + " RuleD: featureD2=ID;");
EPackage ePackage = this.getEPackageFromGrammar(grammar);
Assert.assertEquals(4, ePackage.getEClassifiers().size());
EClassifier _type = this.<EClassifier>type(ePackage, "RuleA");
EClass ruleA = ((EClass) _type);
Assert.assertNotNull(ruleA);
EClassifier _type_1 = this.<EClassifier>type(ePackage, "RuleB");
EClass ruleB = ((EClass) _type_1);
Assert.assertNotNull(ruleB);
EClassifier _type_2 = this.<EClassifier>type(ePackage, "RuleC");
EClass ruleC = ((EClass) _type_2);
Assert.assertNotNull(ruleC);
EClassifier _type_3 = this.<EClassifier>type(ePackage, "RuleD");
EClass ruleD = ((EClass) _type_3);
Assert.assertNotNull(ruleD);
Assert.assertTrue(ruleA.getESuperTypes().isEmpty());
Assert.assertEquals(1, ruleB.getESuperTypes().size());
Assert.assertEquals(ruleA, IterableExtensions.<EClass>head(ruleB.getESuperTypes()));
Assert.assertEquals(1, ruleC.getESuperTypes().size());
Assert.assertEquals(ruleA, IterableExtensions.<EClass>head(ruleC.getESuperTypes()));
Assert.assertEquals(1, ruleD.getESuperTypes().size());
Assert.assertEquals(ruleA, IterableExtensions.<EClass>head(ruleD.getESuperTypes()));
Assert.assertEquals(2, ruleA.getEAttributes().size());
this.assertAttributeConfiguration(ruleA, 0, "featureABC", "EString");
this.assertAttributeConfiguration(ruleA, 1, "featureA", "EString");
Assert.assertEquals(1, ruleB.getEAttributes().size());
this.assertAttributeConfiguration(ruleB, 0, "featureB2", "EString");
Assert.assertEquals(3, ruleC.getEAttributes().size());
this.assertAttributeConfiguration(ruleC, 0, "featureC1", "EString");
this.assertAttributeConfiguration(ruleC, 1, "featureCD", "EString");
this.assertAttributeConfiguration(ruleC, 2, "featureC2", "EString");
Assert.assertEquals(3, ruleD.getEAttributes().size());
this.assertAttributeConfiguration(ruleD, 0, "featureD1", "EString");
this.assertAttributeConfiguration(ruleD, 1, "featureCD", "EString");
this.assertAttributeConfiguration(ruleD, 2, "featureD2", "EString");
}
use of org.eclipse.emf.ecore.EClass in project xtext-core by eclipse.
the class Xtext2EcoreTransformerTest method testSingleFeatures.
@Test
public void testSingleFeatures() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("grammar test with org.eclipse.xtext.common.Terminals generate test \'http://test\' RuleA: featureA=INT;");
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(1, ruleA.getEAttributes().size());
this.assertAttributeConfiguration(ruleA, 0, "featureA", "EInt");
}
use of org.eclipse.emf.ecore.EClass in project xtext-core by eclipse.
the class Xtext2EcoreTransformerTest method testClassNameEString.
@Test
public void testClassNameEString() 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 + "Start returns EString: id=ID;");
EPackage ePackage = this.getEPackageFromGrammar(grammar);
EClassifier _type = this.<EClassifier>type(ePackage, "EString");
EClass classifier = ((EClass) _type);
Assert.assertEquals("EString", classifier.getName());
EStructuralFeature feature = this.<EStructuralFeature>feature(classifier, "id");
Assert.assertNotNull(feature);
Assert.assertEquals("EString", feature.getEType().getName());
Assert.assertFalse(feature.getEType().equals(classifier));
Assert.assertEquals(EcorePackage.Literals.ESTRING, feature.getEType());
}
Aggregations