use of org.eclipse.xtext.generator.OutputConfiguration in project applause by applause.
the class ApplauseEclipseResourceFileSystemAccess2 method getFile.
protected IFile getFile(String fileName, String outputName) {
OutputConfiguration configuration = getOutputConfig(outputName);
IContainer container = getContainer(configuration);
IFile result = container.getFile(new Path(fileName));
syncIfNecessary(result);
return result;
}
use of org.eclipse.xtext.generator.OutputConfiguration in project applause by applause.
the class ApplauseEclipseResourceFileSystemAccess2 method generateFile.
public void generateFile(String fileName, String outputName, CharSequence contents) {
if (monitor.isCanceled())
throw new OperationCanceledException();
OutputConfiguration outputConfig = getOutputConfig(outputName);
if (!ensureOutputConfigurationDirectoryExists(outputConfig))
return;
IFile file = getFile(fileName, outputName);
IFile traceFile = getTraceFile(file);
try {
String encoding = getEncoding(file);
CharSequence postProcessedContent = postProcess(fileName, outputName, contents, encoding);
String contentsAsString = postProcessedContent.toString();
if (file.exists()) {
if (outputConfig.isOverrideExistingResources()) {
StringInputStream newContent = getInputStream(contentsAsString, encoding);
if (hasContentsChanged(file, newContent)) {
// reset to offset zero allows to reuse internal byte[]
// no need to convert the string twice
newContent.reset();
file.setContents(newContent, true, true, monitor);
} else {
file.touch(getMonitor());
}
if (file.isDerived() != outputConfig.isSetDerivedProperty()) {
setDerived(file, outputConfig.isSetDerivedProperty());
}
if (traceFile != null)
updateTraceInformation(traceFile, postProcessedContent, outputConfig.isSetDerivedProperty());
if (callBack != null)
callBack.afterFileUpdate(file);
}
} else {
ensureParentExists(file);
file.create(getInputStream(contentsAsString, encoding), true, monitor);
if (outputConfig.isSetDerivedProperty()) {
setDerived(file, true);
}
if (traceFile != null)
updateTraceInformation(traceFile, postProcessedContent, outputConfig.isSetDerivedProperty());
if (callBack != null)
callBack.afterFileCreation(file);
}
} catch (CoreException e) {
throw new RuntimeIOException(e);
} catch (IOException e) {
throw new RuntimeIOException(e);
}
}
use of org.eclipse.xtext.generator.OutputConfiguration in project xtext-xtend by eclipse.
the class FileLocationsImpl method getTargetFolder.
@Override
public Path getTargetFolder(final Path path) {
Path _xblockexpression = null;
{
final Path projectFolder = this.getProjectFolder(path);
if ((projectFolder == null)) {
return null;
}
final OutputConfiguration outputConfiguration = IterableExtensions.<OutputConfiguration>head(this.outputConfigurationProvider.getOutputConfigurations(this.context));
final Path sourceFolder = this.getSourceFolder(path);
String _xifexpression = null;
if ((sourceFolder == null)) {
_xifexpression = outputConfiguration.getOutputDirectory();
} else {
String _xblockexpression_1 = null;
{
final String projectRelativeSourceFolder = IterableExtensions.join(IterableExtensions.<String>tail(sourceFolder.getSegments()), "/");
_xblockexpression_1 = outputConfiguration.getOutputDirectory(projectRelativeSourceFolder);
}
_xifexpression = _xblockexpression_1;
}
final String outputFolder = _xifexpression;
_xblockexpression = projectFolder.append(outputFolder);
}
return _xblockexpression;
}
use of org.eclipse.xtext.generator.OutputConfiguration in project xtext-xtend by eclipse.
the class TestBatchCompiler method testProjectConfigMultipleSourceDirs4.
@Test
public void testProjectConfigMultipleSourceDirs4() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("ws/prj1/src");
_builder.append(File.pathSeparator);
_builder.append("ws/prj1/dir1/src-gen");
this.batchCompiler.setSourcePath(_builder.toString());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("ws/prj1/bin");
this.batchCompiler.setOutputPath(_builder_1.toString());
this.batchCompiler.compile();
final FileProjectConfig project = this.batchCompiler.getProjectConfig();
Assert.assertEquals("prj1", project.getName());
final OutputConfiguration output = this.batchCompiler.getOutputConfiguration();
Assert.assertEquals(2, project.getSourceFolders().size());
final Function1<FileSourceFolder, String> _function = (FileSourceFolder it) -> {
return it.getName();
};
final List<String> keyPaths = IterableExtensions.<String>sort(IterableExtensions.<FileSourceFolder, String>map(project.getSourceFolders(), _function));
String _get = keyPaths.get(0);
final Procedure1<String> _function_1 = (String it) -> {
Assert.assertEquals("dir1/src-gen", it);
Assert.assertEquals("bin", output.getOutputDirectory(it));
};
ObjectExtensions.<String>operator_doubleArrow(_get, _function_1);
String _get_1 = keyPaths.get(1);
final Procedure1<String> _function_2 = (String it) -> {
Assert.assertEquals("src", it);
Assert.assertEquals("bin", output.getOutputDirectory(it));
};
ObjectExtensions.<String>operator_doubleArrow(_get_1, _function_2);
}
use of org.eclipse.xtext.generator.OutputConfiguration in project xtext-xtend by eclipse.
the class TestBatchCompiler method testProjectConfigMultipleSourceDirs1.
@Test
public void testProjectConfigMultipleSourceDirs1() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("ws/prj1/src");
_builder.append(File.pathSeparator);
_builder.append("ws/prj1/src-gen");
this.batchCompiler.setSourcePath(_builder.toString());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("ws/prj1/bin");
this.batchCompiler.setOutputPath(_builder_1.toString());
this.batchCompiler.compile();
final FileProjectConfig project = this.batchCompiler.getProjectConfig();
Assert.assertEquals("prj1", project.getName());
final OutputConfiguration output = this.batchCompiler.getOutputConfiguration();
Assert.assertEquals(2, project.getSourceFolders().size());
final Function1<FileSourceFolder, String> _function = (FileSourceFolder it) -> {
return it.getName();
};
final List<String> keyPaths = IterableExtensions.<String>sort(IterableExtensions.<FileSourceFolder, String>map(project.getSourceFolders(), _function));
String _get = keyPaths.get(0);
final Procedure1<String> _function_1 = (String it) -> {
Assert.assertEquals("src", it);
Assert.assertEquals("bin", output.getOutputDirectory(it).toString());
};
ObjectExtensions.<String>operator_doubleArrow(_get, _function_1);
String _get_1 = keyPaths.get(1);
final Procedure1<String> _function_2 = (String it) -> {
Assert.assertEquals("src-gen", it);
Assert.assertEquals("bin", output.getOutputDirectory(it).toString());
};
ObjectExtensions.<String>operator_doubleArrow(_get_1, _function_2);
}
Aggregations