/** * creates a fresh resource set with the given resources * * @param resources - pairs of file names and their contents * @return a ResourceSet, containing the given resources. * @throws IOException if the resource loading fails */ public ResourceSet resourceSet(Pair<String,? extends CharSequence> ...resources ) throws IOException { XtextResourceSet result = resourceSetProvider.get(); result.setClasspathURIContext(classpathUriContext); FileProjectConfig projectConfig = new FileProjectConfig(new File(workspaceRoot,PROJECT_NAME), PROJECT_NAME); projectConfig.addSourceFolder("src"); ProjectConfigAdapter.install(result, projectConfig); for (Pair<String, ? extends CharSequence> entry : resources) { URI uri = copyToWorkspace(getSourceFolderPath()+"/"+entry.getKey(), entry.getValue()); Resource resource = result.createResource(uri); if (resource == null) throw new IllegalStateException("Couldn't create resource for URI "+uri+". Resource.Factory not registered?"); resource.load(newHashMap()); } return result; }
@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); } } }
public void findProjects(final WorkspaceConfig workspaceConfig, final URI uri) { if ((uri != null)) { final FileProjectConfig project = new FileProjectConfig(uri, workspaceConfig); project.addSourceFolder("."); workspaceConfig.addProject(project); } }
public FileSourceFolder(final FileProjectConfig parent, final String name) { super(); this.parent = parent; this.name = name; }