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


Java GenModel.getGenPackages方法代码示例

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


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

示例1: loadReferencedGenModels

import org.eclipse.emf.codegen.ecore.genmodel.GenModel; //导入方法依赖的package包/类
/**
 * Use {@link GenModelAccess#getGenPackage(EPackage)}
 */
@Deprecated
protected List<GenPackage> loadReferencedGenModels(ResourceSet rs) {
	List<GenPackage> result = Lists.newArrayList();
	if (getReferencedGenModels() != null) {
		for (String uri : getReferencedGenModels().split(",")) {
			try {
				Resource resource = rs.getResource(URI.createURI(uri.trim()), true);
				GenModel genmodel = (GenModel) resource.getContents().get(0);
				EList<GenPackage> genPackages = genmodel.getGenPackages();
				for (GenPackage genPackage : genPackages) {
					genPackage.getEcorePackage().getEClassifiers();
					result.add(genPackage);
				}
			} catch (Exception e) {
				log.error("Couldn't find genmodel for uri '" + uri + "'");
				throw new WrappedException(e);
			}
		}
	}
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:25,代码来源:EcoreGeneratorFragment.java

示例2: getGenPackagesForPackages

import org.eclipse.emf.codegen.ecore.genmodel.GenModel; //导入方法依赖的package包/类
/**
 * @since 2.0
 */
protected List<GenPackage> getGenPackagesForPackages(GenModel existingGenModel, Collection<EPackage> packs) {
	List<GenPackage> result = Lists.newArrayList();
	for (EPackage pkg : packs) {
		boolean found = false;
		for (GenPackage gp : existingGenModel.getGenPackages())
			if (gp.getEcorePackage() != null && gp.getEcorePackage().getNsURI() != null
					&& gp.getEcorePackage().getNsURI().equals(pkg.getNsURI()))
				found = true;
		if (!found)
			result.add(GenModelAccess.getGenPackage(pkg, existingGenModel.eResource().getResourceSet()));
	}
	Collections.sort(result, new Comparator<GenPackage>() {
		@Override
		public int compare(GenPackage o1, GenPackage o2) {
			return EcoreUtil.getURI(o1).toString().compareTo(EcoreUtil.getURI(o2).toString());
		}
	});
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:23,代码来源:EMFGeneratorFragment.java

示例3: getSaveAndReconcileGenModel

import org.eclipse.emf.codegen.ecore.genmodel.GenModel; //导入方法依赖的package包/类
/**
 * @since 2.0
 */
protected GenModel getSaveAndReconcileGenModel(ResourceSet rs, Grammar grammar, XpandExecutionContext ctx,
		List<EPackage> packs) throws ConfigurationException {
	GenModel genModel = getGenModel(rs, grammar, ctx, packs);
	genModel.initialize(packs);
	for (GenPackage genPackage : genModel.getGenPackages()) {
		genPackage.setBasePackage(getBasePackage(grammar));
		if (isSuppressLoadInitialization()) {
			genPackage.setLoadInitialization(false);
		}
		if (getFileExtensions() != null && packs.contains(genPackage.getEcorePackage())) {
			genPackage.setFileExtensions(getFileExtensions());
		}
	}
	Set<EPackage> referencedEPackages = getReferencedEPackages(packs);
	List<GenPackage> usedGenPackages = getGenPackagesForPackages(genModel, referencedEPackages);
	reconcileMissingGenPackagesInUsedModels(usedGenPackages);
	genModel.getUsedGenPackages().addAll(usedGenPackages);
	try {
		saveResource(genModel.eResource());
	} catch (IOException e) {
		throw new WrappedException(e);
	}
	new GenModelHelper().registerGenModel(genModel);
	return genModel;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:29,代码来源:EMFGeneratorFragment.java

示例4: getSaveAndReconcileGenModel

import org.eclipse.emf.codegen.ecore.genmodel.GenModel; //导入方法依赖的package包/类
protected GenModel getSaveAndReconcileGenModel(final Grammar grammar, final List<EPackage> packs, final ResourceSet rs) {
  final GenModel genModel = this.getGenModel(rs, grammar);
  genModel.initialize(packs);
  EList<GenPackage> _genPackages = genModel.getGenPackages();
  for (final GenPackage genPackage : _genPackages) {
    {
      genPackage.setBasePackage(this.getBasePackage(grammar));
      if (this.suppressLoadInitialization) {
        genPackage.setLoadInitialization(false);
      }
      if (((!this.getLanguage().getFileExtensions().isEmpty()) && packs.contains(genPackage.getEcorePackage()))) {
        genPackage.setFileExtensions(IterableExtensions.join(this.getLanguage().getFileExtensions(), ","));
      }
    }
  }
  final Set<EPackage> referencedEPackages = this.getReferencedEPackages(packs);
  final List<GenPackage> usedGenPackages = this.getGenPackagesForPackages(genModel, referencedEPackages);
  this.reconcileMissingGenPackagesInUsedModels(usedGenPackages);
  genModel.getUsedGenPackages().addAll(usedGenPackages);
  this.saveResource(genModel.eResource());
  new GenModelHelper().registerGenModel(genModel);
  return genModel;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:24,代码来源:EMFGeneratorFragment2.java

示例5: generate

import org.eclipse.emf.codegen.ecore.genmodel.GenModel; //导入方法依赖的package包/类
/**
   * Call the generator for each package in GenModel.
   *
   * @param genmod
   *            the root GenModel to check.
   * @param outputPath
   *            the path to the folder where files will be wrote.
   * @param testPath
   *            the path to the folder where tests files will be wrote.
   * @param isTooling
   *            true if tool building is active
   */
  public final void generate(GenModel genmod, String outputPath,
          String testPath, String isTooling) {

      log = LogMaster.giveLogger("HLAPI");
      log
              .info("---------------------------------------------------------------------------------");
      log.info("Begining High-Level API generation");
      setOutputfolder(outputPath);
      setTestoutputfolder(testPath);
      setTooling(isTooling);
      log.info("All files will be generated in " + getOutputfolder());
      final EList<GenPackage> paks = genmod.getGenPackages();
      log.info("There are " + paks.size() + " Packages to process");

      for (GenPackage genPackage2 : paks) {
          final GenPackage genPackage = (GenPackage) genPackage2;
          generate(genPackage);
      }

      if (tooling != null && !tooling.trim().equals("")) {
          log.info("generating tools");
          produceToolsFor(genmod);
          if (getTestoutputfolder() != null
                  && !getTestoutputfolder().trim().equals("")) {
              log.info("generating tests tools");
              produceToolTestCodeFor(genmod);
          }
      }
      log.info("End of Hight-Level API generation");
      LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
loggerContext.stop();
  }
 
开发者ID:lip6,项目名称:pnmlframework,代码行数:45,代码来源:GenerateHLAPI.java

示例6: test

import org.eclipse.emf.codegen.ecore.genmodel.GenModel; //导入方法依赖的package包/类
@Test
public void test() throws IOException {
	File locationFile;
	Bundle bundle = Platform.getBundle("org.eclipse.emf.examples.library");
	URL bundleURL = bundle.getEntry("model/extlibrary.genmodel");
	URL fileURL = FileLocator.toFileURL(bundleURL);

	URI locationURI = URI.createFileURI(fileURL.getPath());

	ResourceSet resourceSet = new ResourceSetImpl();
	Resource resource = resourceSet.getResource(locationURI, true);
	GenModel genModel = (GenModel) resource.getContents().get(0);

	locationFile = new File("src-gen");
	clearDir(locationFile);
	AcceleoPreferences.switchQueryCache(false);

	for (GenPackage genPackage : genModel.getGenPackages()) {
		String basePackage = genPackage.getBasePackage() + "."
				+ genPackage.getEcorePackage().getName();
		Utility.setBasePackage(basePackage);
		Utility.setFactory(genPackage.getPrefix() + "Factory");
		Utility.setPackage(genPackage.getPrefix() + "Package");

		String avroDir = locationFile.toString() + File.separator
				+ basePackage.replace('.', '/') + File.separator + "avro";
		File avroLocation = new File(avroDir);
		GenerateResourceFactory factoryGenerator;
		try {
			factoryGenerator = new GenerateResourceFactory(
					genPackage.getEcorePackage(), avroLocation,
					new ArrayList<Object>());
			factoryGenerator.generate(new BasicMonitor());
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:LangleyStudios,项目名称:eclipse-avro,代码行数:39,代码来源:TestResourceFactoryGen.java

示例7: test

import org.eclipse.emf.codegen.ecore.genmodel.GenModel; //导入方法依赖的package包/类
@Test
public void test() throws IOException {
	File locationFile;
	Bundle bundle = Platform.getBundle("org.eclipse.emf.examples.library");
	URL bundleURL = bundle.getEntry("model/extlibrary.genmodel");
	URL fileURL = FileLocator.toFileURL(bundleURL);

	URI locationURI = URI.createFileURI(fileURL.getPath());

	ResourceSet resourceSet = new ResourceSetImpl();
	Resource resource = resourceSet.getResource(locationURI, true);
	GenModel genModel = (GenModel) resource.getContents().get(0);

	locationFile = new File("src-gen");
	clearDir(locationFile);
	AcceleoPreferences.switchQueryCache(false);

	for (GenPackage genPackage : genModel.getGenPackages()) {
		String basePackage = genPackage.getBasePackage() + "."
				+ genPackage.getEcorePackage().getName();
		Utility.setBasePackage(basePackage);
		Utility.setFactory(genPackage.getPrefix() + "Factory");
		Utility.setPackage(genPackage.getPrefix() + "Package");

		String avroDir = locationFile.toString() + File.separator
				+ basePackage.replace('.', '/') + File.separator + "avro";
		File avroLocation = new File(avroDir);
		GenerateAvroConverter generator;
		try {
			generator = new GenerateAvroConverter(
					genPackage.getEcorePackage(), avroLocation,
					new ArrayList<Object>());
			generator.addGenerationListener(this);
			Map<String, String> results = generator.generate(new BasicMonitor());
			assertNotNull(results);
			assertTrue(textGenerated);
			assertTrue(fileGenerated);
			assertTrue(generationComplete);
		} catch (IOException e) {
			fail(e.getMessage());
		}
	}
}
 
开发者ID:LangleyStudios,项目名称:eclipse-avro,代码行数:44,代码来源:TestConverterGen.java


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