use of org.eclipse.xtext.workspace.FileProjectConfig in project xtext-xtend by eclipse.
the class TestBatchCompiler method testProjectConfigMultipleSourceDirs3.
@Test
public void testProjectConfigMultipleSourceDirs3() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("ws/prj1/dir1/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/dir2/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", it);
Assert.assertEquals("dir2/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-gen", it);
Assert.assertEquals("dir2/bin", output.getOutputDirectory(it));
};
ObjectExtensions.<String>operator_doubleArrow(_get_1, _function_2);
}
use of org.eclipse.xtext.workspace.FileProjectConfig in project xtext-core by eclipse.
the class MultiProjectWorkspaceConfigFactory method findProjects.
@Override
public void findProjects(final WorkspaceConfig workspaceConfig, final URI uri) {
if ((uri == null)) {
return;
}
String _fileString = uri.toFileString();
final File baseFile = new File(_fileString);
boolean _isDirectory = baseFile.isDirectory();
boolean _not = (!_isDirectory);
if (_not) {
return;
}
final Function1<File, Boolean> _function = (File it) -> {
return Boolean.valueOf(it.isDirectory());
};
Iterable<File> _filter = IterableExtensions.<File>filter(((Iterable<File>) Conversions.doWrapArray(baseFile.listFiles())), _function);
for (final File file : _filter) {
{
final FileProjectConfig project = new FileProjectConfig(file, workspaceConfig);
project.addSourceFolder(".");
workspaceConfig.addProject(project);
}
}
}
use of org.eclipse.xtext.workspace.FileProjectConfig in project xtext-xtend by eclipse.
the class JavaIoFileSystemTest method setUp.
@Before
public void setUp() {
try {
final File tempDir = this.temporaryFolder.newFolder();
JavaIOFileSystemSupport _javaIOFileSystemSupport = new JavaIOFileSystemSupport();
final Procedure1<JavaIOFileSystemSupport> _function = (JavaIOFileSystemSupport it) -> {
final IProjectConfigProvider _function_1 = (ResourceSet it_1) -> {
File _file = new File(tempDir, "foo");
FileProjectConfig _fileProjectConfig = new FileProjectConfig(_file);
final Procedure1<FileProjectConfig> _function_2 = (FileProjectConfig it_2) -> {
it_2.addSourceFolder("src");
};
return ObjectExtensions.<FileProjectConfig>operator_doubleArrow(_fileProjectConfig, _function_2);
};
it.setProjectConfigProvider(_function_1);
IEncodingProvider.Runtime _runtime = new IEncodingProvider.Runtime();
it.setEncodingProvider(_runtime);
XtextResourceSet _xtextResourceSet = new XtextResourceSet();
it.setContext(_xtextResourceSet);
};
JavaIOFileSystemSupport _doubleArrow = ObjectExtensions.<JavaIOFileSystemSupport>operator_doubleArrow(_javaIOFileSystemSupport, _function);
this.fs = _doubleArrow;
this.createProject("foo");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.workspace.FileProjectConfig 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;
}
use of org.eclipse.xtext.workspace.FileProjectConfig in project xtext-xtend by eclipse.
the class TestBatchCompiler method testProjectConfig.
@Test
public void testProjectConfig() {
try {
this.batchCompiler.compile();
final FileProjectConfig project = this.batchCompiler.getProjectConfig();
final String projectPath = new File(".").getCanonicalFile().getName();
Assert.assertEquals(projectPath, project.getName());
final OutputConfiguration output = this.batchCompiler.getOutputConfiguration();
final String src = IterableExtensions.<FileSourceFolder>head(project.getSourceFolders()).getName();
Assert.assertEquals("batch-compiler-data/test data", src.toString());
final String target = output.getOutputDirectory(src);
Assert.assertEquals("test-result", target.toString());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations