当前位置: 首页>>代码示例>>Java>>正文


Java GrammarUtil.allMetamodelDeclarations方法代码示例

本文整理汇总了Java中org.eclipse.xtext.GrammarUtil.allMetamodelDeclarations方法的典型用法代码示例。如果您正苦于以下问题:Java GrammarUtil.allMetamodelDeclarations方法的具体用法?Java GrammarUtil.allMetamodelDeclarations怎么用?Java GrammarUtil.allMetamodelDeclarations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.xtext.GrammarUtil的用法示例。


在下文中一共展示了GrammarUtil.allMetamodelDeclarations方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEPackages

import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
@Override
protected List<EPackage> getEPackages() {
	List<EPackage> pkg = new ArrayList<EPackage>();
	for (AbstractMetamodelDeclaration a : GrammarUtil.allMetamodelDeclarations(grammar.getGrammar()))
		pkg.add(a.getEPackage());
	return pkg;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:8,代码来源:ConcreteSyntaxEValidator.java

示例2: getTypeRef

import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
TypeRef getTypeRef(EClassifier classifier) {
	TypeRef result = XtextFactory.eINSTANCE.createTypeRef();
	result.setClassifier(classifier);
	EPackage pack = classifier.getEPackage();
	for(AbstractMetamodelDeclaration decl: GrammarUtil.allMetamodelDeclarations(grammar)) {
		if (pack.equals(decl.getEPackage())) {
			result.setMetamodel(decl);
			return result;
		}
	}
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:13,代码来源:Xtext2EcoreTransformer.java

示例3: validateAllImports

import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
protected void validateAllImports(final Grammar grammar) {
  List<AbstractMetamodelDeclaration> _allMetamodelDeclarations = GrammarUtil.allMetamodelDeclarations(grammar);
  for (final AbstractMetamodelDeclaration amd : _allMetamodelDeclarations) {
    if ((amd instanceof ReferencedMetamodel)) {
      this.validateReferencedMetamodel(((ReferencedMetamodel)amd));
    }
  }
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:9,代码来源:XtextGeneratorLanguage.java

示例4: testAllMetamodelDeclarations_01

import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
@Test
public void testAllMetamodelDeclarations_01() throws Exception {
  this.with(XtextStandaloneSetup.class);
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("grammar foo with org.eclipse.xtext.common.Terminals");
  _builder.newLine();
  _builder.append("import \'http://www.eclipse.org/emf/2002/Ecore\' as ecore");
  _builder.newLine();
  _builder.append("generate g \'http://3\' as ecore");
  _builder.newLine();
  _builder.append("startrule returns ecore::startrule: name=ID;");
  _builder.newLine();
  String model = _builder.toString();
  Resource r = this.getResourceFromString(model);
  EObject _get = r.getContents().get(0);
  Grammar g = ((Grammar) _get);
  List<AbstractMetamodelDeclaration> decls = GrammarUtil.allMetamodelDeclarations(g);
  Assert.assertEquals(2, decls.size());
  AbstractMetamodelDeclaration decl = decls.get(0);
  Assert.assertTrue((decl instanceof ReferencedMetamodel));
  Assert.assertNotNull(decl.getEPackage());
  Assert.assertEquals("http://www.eclipse.org/emf/2002/Ecore", decl.getEPackage().getNsURI());
  Assert.assertEquals("ecore", decl.getAlias());
  decl = decls.get(1);
  Assert.assertEquals("ecore", decl.getAlias());
  Assert.assertNotNull(decl.getEPackage());
  Assert.assertEquals("http://3", decl.getEPackage().getNsURI());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:29,代码来源:GrammarUtilTest.java

示例5: testAllMetamodelDeclarations_02

import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
@Test
public void testAllMetamodelDeclarations_02() throws Exception {
  this.with(XtextStandaloneSetup.class);
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("grammar foo with org.eclipse.xtext.common.Terminals");
  _builder.newLine();
  _builder.append("import \'http://www.eclipse.org/emf/2002/Ecore\' as bar");
  _builder.newLine();
  _builder.append("generate g \'http://3\' as bar");
  _builder.newLine();
  _builder.append("startrule returns bar::startrule: name=ID;");
  _builder.newLine();
  String model = _builder.toString();
  Resource r = this.getResourceFromString(model);
  EObject _get = r.getContents().get(0);
  Grammar g = ((Grammar) _get);
  List<AbstractMetamodelDeclaration> decls = GrammarUtil.allMetamodelDeclarations(g);
  Assert.assertEquals(3, decls.size());
  AbstractMetamodelDeclaration decl = decls.get(0);
  Assert.assertTrue((decl instanceof ReferencedMetamodel));
  Assert.assertNotNull(decl.getEPackage());
  Assert.assertEquals("http://www.eclipse.org/emf/2002/Ecore", decl.getEPackage().getNsURI());
  Assert.assertEquals("bar", decl.getAlias());
  decl = decls.get(1);
  Assert.assertEquals("bar", decl.getAlias());
  Assert.assertNotNull(decl.getEPackage());
  Assert.assertEquals("http://3", decl.getEPackage().getNsURI());
  decl = decls.get(2);
  Assert.assertTrue((decl instanceof ReferencedMetamodel));
  Assert.assertNotNull(decl.getEPackage());
  Assert.assertEquals("http://www.eclipse.org/emf/2002/Ecore", decl.getEPackage().getNsURI());
  Assert.assertEquals("ecore", decl.getAlias());
  AbstractRule abstractRule = g.getRules().get(0);
  Assert.assertSame(decls.get(1), abstractRule.getType().getMetamodel());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:36,代码来源:GrammarUtilTest.java

示例6: testAllMetamodelDeclarations_03

import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
@Test
public void testAllMetamodelDeclarations_03() throws Exception {
  this.with(XtextStandaloneSetup.class);
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("grammar foo with org.eclipse.xtext.common.Terminals");
  _builder.newLine();
  _builder.append("generate g \'http://3\' as bar");
  _builder.newLine();
  _builder.append("import \'http://www.eclipse.org/emf/2002/Ecore\' as bar");
  _builder.newLine();
  _builder.append("startrule returns bar::startrule: name=ID;");
  _builder.newLine();
  String model = _builder.toString();
  Resource r = this.getResourceFromString(model);
  EObject _get = r.getContents().get(0);
  Grammar g = ((Grammar) _get);
  List<AbstractMetamodelDeclaration> decls = GrammarUtil.allMetamodelDeclarations(g);
  Assert.assertEquals(3, decls.size());
  AbstractMetamodelDeclaration decl = decls.get(0);
  Assert.assertTrue((decl instanceof GeneratedMetamodel));
  Assert.assertEquals("bar", decl.getAlias());
  Assert.assertNotNull(decl.getEPackage());
  Assert.assertEquals("http://3", decl.getEPackage().getNsURI());
  decl = decls.get(1);
  Assert.assertTrue((decl instanceof ReferencedMetamodel));
  Assert.assertNotNull(decl.getEPackage());
  Assert.assertEquals("http://www.eclipse.org/emf/2002/Ecore", decl.getEPackage().getNsURI());
  Assert.assertEquals("bar", decl.getAlias());
  decl = decls.get(2);
  Assert.assertTrue((decl instanceof ReferencedMetamodel));
  Assert.assertNotNull(decl.getEPackage());
  Assert.assertEquals("http://www.eclipse.org/emf/2002/Ecore", decl.getEPackage().getNsURI());
  Assert.assertEquals("ecore", decl.getAlias());
  AbstractRule abstractRule = g.getRules().get(0);
  Assert.assertSame(decls.get(0), abstractRule.getType().getMetamodel());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:37,代码来源:GrammarUtilTest.java

示例7: getRequiredBundleSymbolicNames

import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
/**
 * Gets the name of the bundles required for this grammar.
 * 
 * @return the required bundle symbolic names
 */
public Set<String> getRequiredBundleSymbolicNames() {
  Set<String> set = new HashSet<String>();
  for (AbstractMetamodelDeclaration declaration : GrammarUtil.allMetamodelDeclarations(getGrammar())) {
    set.add(getBundleSymbolicName(getFirstInterface(declaration)));
    for (EClassifier classifier : declaration.getEPackage().getEClassifiers()) {
      if (classifier instanceof EClass) {
        for (EClass superType : ((EClass) classifier).getEAllSuperTypes()) {
          set.add(getBundleSymbolicName(getFirstInterface(superType.getEPackage())));
        }
      }
    }
  }
  return set;
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:20,代码来源:GrammarHelper.java

示例8: validateAllImports

import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
/**
 * @since 2.3
 */
protected void validateAllImports(Grammar grammar) {
	for (AbstractMetamodelDeclaration amd : GrammarUtil.allMetamodelDeclarations(grammar))
		if (amd instanceof ReferencedMetamodel)
			validateReferencedMetamodel((ReferencedMetamodel) amd);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:9,代码来源:LanguageConfig.java


注:本文中的org.eclipse.xtext.GrammarUtil.allMetamodelDeclarations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。