org.eclipse.xtext.xbase.compiler.GeneratorConfigProvider Java Examples

The following examples show how to use org.eclipse.xtext.xbase.compiler.GeneratorConfigProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CompilationTestHelper.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Parses, validates and compiles the given source. Calls the given acceptor for each
 * resource which is generated from the source.
 *  
 * @param resourceSet - the {@link ResourceSet} to use
 * @param acceptor gets called once for each file generated in {@link IGenerator}
 */
public void compile(final ResourceSet resourceSet, IAcceptor<Result> acceptor) {
	try {
		List<Resource> resourcesToCheck = newArrayList(resourceSet.getResources());
		if (generatorConfigProvider instanceof GeneratorConfigProvider) {
			GeneratorConfigProvider configProvider = (GeneratorConfigProvider) generatorConfigProvider;
			GeneratorConfig config = generatorConfigProvider.get(null);
			config.setJavaSourceVersion(javaCompiler.getJavaVersion());
			GeneratorConfig existent = configProvider.install(resourceSet, config);
			if (existent != null) {
				existent.setJavaSourceVersion(javaCompiler.getJavaVersion());
				configProvider.install(resourceSet, existent);
			}
		}
		Result result = resultProvider.get();
		result.setJavaCompiler(javaCompiler);
		result.setCheckMode(getCheckMode());
		result.setResources(resourcesToCheck);
		result.setResourceSet(resourceSet);
		result.setOutputConfigurations(getOutputConfigurations());
		result.doGenerate();
		acceptor.accept(result);
	} catch (Exception e) {
		Exceptions.throwUncheckedException(e);
	}
}
 
Example #2
Source File: SARLGeneratorConfigProvider.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
public GeneratorConfig get(EObject context) {
	// Search for the Eclipse configuration
	final ResourceSet resourceSet = EcoreUtil2.getResourceSet(context);
	if (resourceSet != null) {
		final GeneratorConfigProvider.GeneratorConfigAdapter adapter =
				GeneratorConfigProvider.GeneratorConfigAdapter.findInEmfObject(resourceSet);
		if (adapter != null && adapter.getLanguage2GeneratorConfig().containsKey(this.languageId)) {
			return adapter.getLanguage2GeneratorConfig().get(this.languageId);
		}
	}
	// Create the default configuration
	final GeneratorConfig config = createDefaultGeneratorConfig();
	return config;
}
 
Example #3
Source File: CheckUiModule.java    From dsl-devkit with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Fix for NPE in EclipseGeneratorConfigProvider.
 *
 * @return GeneratorConfigProvider
 */
@Override
public Class<? extends IGeneratorConfigProvider> bindIGeneratorConfigProvider() {
  return GeneratorConfigProvider.class;
}
 
Example #4
Source File: CheckCfgUiModule.java    From dsl-devkit with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Fix for NPE in EclipseGeneratorConfigProvider.
 *
 * @return GeneratorConfigProvider
 */
@Override
public Class<? extends IGeneratorConfigProvider> bindIGeneratorConfigProvider() {
  return GeneratorConfigProvider.class;
}