/** * 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 IProjectConfig getProjectConfig(final ResourceSet context) { ProjectConfigAdapter _findInEmfObject = ProjectConfigAdapter.findInEmfObject(context); IProjectConfig _projectConfig = null; if (_findInEmfObject!=null) { _projectConfig=_findInEmfObject.getProjectConfig(); } return _projectConfig; }
@Before public void setUp() { try { WorkspaceConfig _workspaceConfig = new WorkspaceConfig(); this.workspaceConfig = _workspaceConfig; ProjectConfig _projectConfig = new ProjectConfig("foo", this.workspaceConfig); this.fooProject = _projectConfig; ProjectConfig _projectConfig_1 = new ProjectConfig("bar", this.workspaceConfig); this.barProject = _projectConfig_1; final XtextResourceSet rs0 = this.resourceSetProvider.get(); this.fooURI = IterableExtensions.<SourceFolder>head(this.fooProject.getSourceFolders()).getPath().trimSegments(1).appendSegment("foo.livecontainertestlanguage"); this.barURI = IterableExtensions.<SourceFolder>head(this.barProject.getSourceFolders()).getPath().trimSegments(1).appendSegment("bar.livecontainertestlanguage"); ResourceDescriptionsData _createResourceDescriptionData = this.createResourceDescriptionData(this._parseHelper.parse("foo", this.fooURI, rs0).eResource()); Pair<String, ResourceDescriptionsData> _mappedTo = Pair.<String, ResourceDescriptionsData>of("foo", _createResourceDescriptionData); ResourceDescriptionsData _createResourceDescriptionData_1 = this.createResourceDescriptionData(this._parseHelper.parse("bar", this.barURI, rs0).eResource()); Pair<String, ResourceDescriptionsData> _mappedTo_1 = Pair.<String, ResourceDescriptionsData>of("bar", _createResourceDescriptionData_1); final Map<String, ResourceDescriptionsData> chunks = Collections.<String, ResourceDescriptionsData>unmodifiableMap(CollectionLiterals.<String, ResourceDescriptionsData>newHashMap(_mappedTo, _mappedTo_1)); this.rs1 = this.resourceSetProvider.get(); new ChunkedResourceDescriptions(chunks, this.rs1); ProjectConfigAdapter.install(this.rs1, this.fooProject); this.liveShadowedChunkedResourceDescriptions = this.provider.get(); this.liveShadowedChunkedResourceDescriptions.setContext(this.rs1); LiveShadowedChunkedContainer _liveShadowedChunkedContainer = new LiveShadowedChunkedContainer(this.liveShadowedChunkedResourceDescriptions, "foo"); this.fooContainer = _liveShadowedChunkedContainer; LiveShadowedChunkedContainer _liveShadowedChunkedContainer_1 = new LiveShadowedChunkedContainer(this.liveShadowedChunkedResourceDescriptions, "bar"); this.barContainer = _liveShadowedChunkedContainer_1; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
public XtextResourceSet createNewResourceSet(final ResourceDescriptionsData newIndex) { XtextResourceSet _get = this.resourceSetProvider.get(); final Procedure1<XtextResourceSet> _function = (XtextResourceSet it) -> { this.projectDescription.attachToEmfObject(it); ProjectConfigAdapter.install(it, this.projectConfig); Map<String, ResourceDescriptionsData> _get_1 = this.indexProvider.get(); final ChunkedResourceDescriptions index = new ChunkedResourceDescriptions(_get_1, it); index.setContainer(this.projectDescription.getName(), newIndex); this.externalContentSupport.configureResourceSet(it, this.openedDocumentsContentProvider); }; return ObjectExtensions.<XtextResourceSet>operator_doubleArrow(_get, _function); }