use of org.eclipse.xtext.generator.OutputConfigurationAdapter in project xtext-core by eclipse.
the class AbstractIncrementalBuilderTest method withOutputConfig.
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);
}
use of org.eclipse.xtext.generator.OutputConfigurationAdapter in project xtext-xtend by eclipse.
the class XtendBatchCompiler method configureWorkspace.
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;
}
Aggregations