Search in sources :

Example 1 with EClassifierInfos

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

the class Xtext2EcoreTransformerTest method testTypesOfImplicitSuperGrammar.

@Test
public void testTypesOfImplicitSuperGrammar() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("grammar test with org.eclipse.xtext.common.Terminals");
    _builder.newLine();
    _builder.append("generate test \'http://test\'");
    _builder.newLine();
    _builder.append("MyRule: myFeature=INT;");
    _builder.newLine();
    final String xtextGrammar = _builder.toString();
    EObject _model = this.getModel(xtextGrammar);
    final Grammar grammar = ((Grammar) _model);
    final Xtext2EcoreTransformer transformer = new Xtext2EcoreTransformer(grammar);
    transformer.removeGeneratedPackages();
    transformer.transform();
    final AbstractRule rule = IterableExtensions.<AbstractRule>head(grammar.getRules());
    TypeRef type = rule.getType();
    Assert.assertNotNull(type);
    Assert.assertNotNull(transformer.getEClassifierInfos().getInfo(type));
    AbstractMetamodelDeclaration _get = GrammarUtil.allMetamodelDeclarations(grammar).get(1);
    final ReferencedMetamodel referenced = ((ReferencedMetamodel) _get);
    Assert.assertNotNull(referenced);
    Assert.assertEquals("ecore", referenced.getAlias());
    Assert.assertNull(transformer.getEClassifierInfos().getInfo(referenced, "EString"));
    Assert.assertNull(transformer.getEClassifierInfos().getInfo(referenced, "EInt"));
    EClassifierInfos parentInfos = IterableExtensions.<EClassifierInfos>head(transformer.getEClassifierInfos().getParents());
    Assert.assertNotNull(parentInfos.getInfo(referenced, "EString"));
    Assert.assertNotNull(parentInfos.getInfo(referenced, "EInt"));
}
Also used : Xtext2EcoreTransformer(org.eclipse.xtext.xtext.ecoreInference.Xtext2EcoreTransformer) TypeRef(org.eclipse.xtext.TypeRef) EObject(org.eclipse.emf.ecore.EObject) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Grammar(org.eclipse.xtext.Grammar) AbstractMetamodelDeclaration(org.eclipse.xtext.AbstractMetamodelDeclaration) AbstractRule(org.eclipse.xtext.AbstractRule) EClassifierInfos(org.eclipse.xtext.xtext.ecoreInference.EClassifierInfos) ReferencedMetamodel(org.eclipse.xtext.ReferencedMetamodel) Test(org.junit.Test)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)1 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)1 AbstractMetamodelDeclaration (org.eclipse.xtext.AbstractMetamodelDeclaration)1 AbstractRule (org.eclipse.xtext.AbstractRule)1 Grammar (org.eclipse.xtext.Grammar)1 ReferencedMetamodel (org.eclipse.xtext.ReferencedMetamodel)1 TypeRef (org.eclipse.xtext.TypeRef)1 EClassifierInfos (org.eclipse.xtext.xtext.ecoreInference.EClassifierInfos)1 Xtext2EcoreTransformer (org.eclipse.xtext.xtext.ecoreInference.Xtext2EcoreTransformer)1 Test (org.junit.Test)1