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


Java AbstractGenericModule类代码示例

本文整理汇总了Java中org.eclipse.xtext.service.AbstractGenericModule的典型用法代码示例。如果您正苦于以下问题:Java AbstractGenericModule类的具体用法?Java AbstractGenericModule怎么用?Java AbstractGenericModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: generate

import org.eclipse.xtext.service.AbstractGenericModule; //导入依赖的package包/类
/**
 * Start the Code generator
 * 
 * @param path
 *            the path where the files will be saves
 * @param modelPath
 *            the path to the model form with the code will be generated
 * @param language
 *            the language in which the Code will be generated
 * @return true if the code was generated
 * @throws NoSidlFileException
 *             Throws this Exception when the given file is not a sidl file
 * @throws FileNotFoundException
 *             Throws this Exception when there is no file at the given path
 * 
 */
public static boolean generate(String path, String modelPath, String language, Resource sensidlmodel)
		throws NoSidlFileException, FileNotFoundException {
	setGenerationLanguage(language);
	Injector injector = new SensidlStandaloneSetup().createInjectorAndDoEMFRegistration();

	// get resource
	Resource resource = null;
	if (sensidlmodel != null) {
		resource = sensidlmodel;
	} else {
		ResourceSet rs = new ResourceSetImpl();
		File file = new File(modelPath);

		// Exception handling for not existing input files
		if (!file.exists()) {
			throw new FileNotFoundException("File not found");
		}
		// Exception handling for input files in the wrong format
		if (!FilenameUtils.getExtension(modelPath).equals("sidl")) {
			throw new NoSidlFileException("No SIDL file found");
		}

		resource = rs.getResource(URI.createURI(file.toURI().toString()), true);
	}
	// Use the JavaIoFileSystemAccess and set the path
	final JavaIoFileSystemAccess fsa = new JavaIoFileSystemAccess();
	fsa.setOutputPath(path);

	generator = injector.getInstance(SensidlGenerator.class); // set up the
	// generator
	generator.setGenerationLanguage(generationLanguage);

	// inject fsa
	Guice.createInjector(new AbstractGenericModule() {
		@SuppressWarnings("unused")
		public Class<? extends IEncodingProvider> bindIEncodingProvider() {
			return IEncodingProvider.Runtime.class;
		}
	}).injectMembers(fsa);

	// generate
	generator.doGenerate(resource, fsa);

	return true;

}
 
开发者ID:SENSIDL-PROJECT,项目名称:SensIDL,代码行数:63,代码来源:GenerationHandler.java


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