org.eclipse.xtext.generator.OutputConfigurationAdapter Java Examples
The following examples show how to use
org.eclipse.xtext.generator.OutputConfigurationAdapter.
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: AbstractIncrementalBuilderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected void withOutputConfig(final BuildRequest it, final Procedure1<? super OutputConfiguration> init) { final OutputConfiguration config = IterableExtensions.<OutputConfiguration>head(this.configurationProvider.getOutputConfigurations()); init.apply(config); Pair<String, Set<OutputConfiguration>> _mappedTo = Pair.<String, Set<OutputConfiguration>>of(this.languageName, Collections.<OutputConfiguration>unmodifiableSet(CollectionLiterals.<OutputConfiguration>newHashSet(config))); final OutputConfigurationAdapter adapter = new OutputConfigurationAdapter(Collections.<String, Set<OutputConfiguration>>unmodifiableMap(CollectionLiterals.<String, Set<OutputConfiguration>>newHashMap(_mappedTo))); EList<Adapter> _eAdapters = it.getResourceSet().eAdapters(); _eAdapters.add(adapter); }
Example #2
Source File: AbstractIncrementalBuilderTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected void withOutputConfig(BuildRequest it, Procedure1<? super OutputConfiguration> init) { OutputConfiguration config = Iterables.getFirst(configurationProvider.getOutputConfigurations(), null); init.apply(config); Map<String, Set<OutputConfiguration>> outputConfigurationsPerLanguage = new HashMap<>(); outputConfigurationsPerLanguage.put(languageName, Sets.newHashSet(config)); OutputConfigurationAdapter adapter = new OutputConfigurationAdapter(outputConfigurationsPerLanguage); it.getResourceSet().eAdapters().add(adapter); }
Example #3
Source File: XtendBatchCompiler.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
private boolean configureWorkspace(ResourceSet resourceSet) { List<File> sourceFileList = getSourcePathFileList(); File outputFile = getOutputPathFile(); if (sourceFileList == null || outputFile == null) { return false; } File commonRoot = determineCommonRoot(outputFile, sourceFileList); // We don't want to use root ("/") as a workspace folder, didn't we? if (commonRoot == null || commonRoot.getParent() == null || commonRoot.getParentFile().getParent() == null) { log.error("All source folders and the output folder should have " + "a common parent non-top level folder (like project folder)"); for (File sourceFile : sourceFileList) { log.error("(Source folder: '" + sourceFile + "')"); } log.error("(Output folder: '" + outputFile + "')"); return false; } projectConfig = new FileProjectConfig(commonRoot, commonRoot.getName()); java.net.URI commonURI = commonRoot.toURI(); java.net.URI relativizedTarget = commonURI.relativize(outputFile.toURI()); if (relativizedTarget.isAbsolute()) { log.error("Target folder '" + outputFile + "' must be a child of the project folder '" + commonRoot + "'"); return false; } CharMatcher slash = CharMatcher.is('/'); String relativeTargetFolder = slash.trimTrailingFrom(relativizedTarget.getPath()); outputConfiguration = Iterables.getOnlyElement(outputConfigurationProvider.getOutputConfigurations()); outputConfiguration.setOutputDirectory(relativeTargetFolder); for (File source : sourceFileList) { java.net.URI relativizedSrc = commonURI.relativize(source.toURI()); if (relativizedSrc.isAbsolute()) { log.error("Source folder '" + source + "' must be a child of the project folder '" + commonRoot + "'"); return false; } projectConfig.addSourceFolder(slash.trimTrailingFrom(relativizedSrc.getPath())); } Map<String, Set<OutputConfiguration>> outputConfigurations = newHashMap(); outputConfigurations.put(languageName, newHashSet(outputConfiguration)); ProjectConfigAdapter.install(resourceSet, projectConfig); resourceSet.eAdapters().add(new OutputConfigurationAdapter(outputConfigurations)); return true; }