Java Code Examples for org.eclipse.xtext.resource.persistence.SourceLevelURIsAdapter#setSourceLevelUris()
The following examples show how to use
org.eclipse.xtext.resource.persistence.SourceLevelURIsAdapter#setSourceLevelUris() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: N4ClusteringBuilderState.java From n4js with Eclipse Public License 1.0 | 6 votes |
protected void installSourceLevelURIs(BuildData buildData) { ResourceSet resourceSet = buildData.getResourceSet(); Iterable<URI> sourceLevelUris = Iterables.concat(buildData.getToBeUpdated(), buildData.getURIQueue()); Set<URI> sourceUris = newHashSet(); for (URI uri : sourceLevelUris) { if (buildData.getSourceLevelURICache().getOrComputeIsSource(uri, resourceServiceProviderRegistry)) { sourceUris.add(uri); // unload resources loaded from storage previously Resource resource = resourceSet.getResource(uri, false); if (resource instanceof StorageAwareResource) { if (((StorageAwareResource) resource).isLoadedFromStorage()) { resource.unload(); } } } } SourceLevelURIsAdapter.setSourceLevelUris(resourceSet, sourceUris); }
Example 2
Source File: ResourceForIEditorInputFactory.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected void configureResourceSet(ResourceSet resourceSet, URI primaryURI) { // TODO: Filter external content - primary resource should not use dirty state externalContentSupport.configureResourceSet(resourceSet, externalContentProvider); if (!(resourceServiceProvider instanceof IResourceServiceProviderExtension) || ((IResourceServiceProviderExtension)resourceServiceProvider).isSource(primaryURI)) { SourceLevelURIsAdapter.setSourceLevelUris(resourceSet, Collections.singleton(primaryURI)); resourceSet.eAdapters().add(new ResourceStorageProviderAdapter() { @Override public ResourceStorageLoadable getResourceStorageLoadable(StorageAwareResource resource) { if (!dirtyStateManager.hasContent(resource.getURI())) { return null; } return ((DirtyStateManager)dirtyStateManager).getResourceStorageLoadable(resource.getURI()); } }); } }
Example 3
Source File: ClusteringBuilderState.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected void installSourceLevelURIs(BuildData buildData) { ResourceSet resourceSet = buildData.getResourceSet(); Iterable<URI> sourceLevelUris = Iterables.concat(buildData.getToBeUpdated(), buildData.getURIQueue()); Set<URI> sourceUris = newHashSet(); for (URI uri : sourceLevelUris) { if (buildData.getSourceLevelURICache().getOrComputeIsSource(uri, resourceServiceProviderRegistry)) { sourceUris.add(uri); // unload resources loaded from storage previously Resource resource = resourceSet.getResource(uri, false); if (resource instanceof StorageAwareResource) { if (((StorageAwareResource) resource).isLoadedFromStorage()) { resource.unload(); } } } } SourceLevelURIsAdapter.setSourceLevelUris(resourceSet, sourceUris); }
Example 4
Source File: ResourceStorageTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testShouldLoadFromStorage() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("package mypack"); _builder.newLine(); _builder.newLine(); _builder.append("class MyClass {"); _builder.newLine(); _builder.append("\t"); _builder.append("public def void foo() {"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final IFile file = this.helper.createFile("mypack/MyClass.xtend", _builder.toString()); IResourcesSetupUtil.waitForBuild(); final URI uri = this.uriMapper.getUri(file); final ResourceSet resourceSet = this.resourceSetProvider.get(file.getProject()); SourceLevelURIsAdapter.setSourceLevelUris(resourceSet, Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList())); Resource _createResource = resourceSet.createResource(uri); final StorageAwareResource resource = ((StorageAwareResource) _createResource); final Procedure0 _function = () -> { Assert.assertTrue(resource.getResourceStorageFacade().shouldLoadFromStorage(resource)); }; this.doWorkInJob(_function); NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor(); file.delete(true, _nullProgressMonitor); IResourcesSetupUtil.waitForBuild(); final Procedure0 _function_1 = () -> { Assert.assertFalse(resource.getResourceStorageFacade().shouldLoadFromStorage(resource)); }; this.doWorkInJob(_function_1); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 5
Source File: ResourceStorageTest.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Test public void testUpstreamResourcesAreLoadedFromStorage() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("package mypack"); _builder.newLine(); _builder.newLine(); _builder.append("class MyClass {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this.helper.createFile("mypack/MyClass.xtend", _builder.toString()); final IProject downStreamProject = WorkbenchTestHelper.createPluginProject("downstream", this.helper.getProject().getName()); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("package downstream"); _builder_1.newLine(); _builder_1.newLine(); _builder_1.append("class SomeClass {"); _builder_1.newLine(); _builder_1.append("\t"); _builder_1.newLine(); _builder_1.append("\t"); _builder_1.append("def void foo(mypack.MyClass myClass) {"); _builder_1.newLine(); _builder_1.append("\t"); _builder_1.append("}"); _builder_1.newLine(); _builder_1.append("}"); _builder_1.newLine(); final IFile downstreamFile = this.helper.createFileImpl("/downstream/src/downstream/SomeClass.xtend", _builder_1.toString()); IResourcesSetupUtil.waitForBuild(); final URI downstreamUri = this.uriMapper.getUri(downstreamFile); final ResourceSet resourceSet = this.resourceSetProvider.get(downStreamProject); SourceLevelURIsAdapter.setSourceLevelUris(resourceSet, Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList(downstreamUri))); Resource _resource = resourceSet.getResource(downstreamUri, true); final StorageAwareResource downstreamResource = ((StorageAwareResource) _resource); EObject _get = downstreamResource.getContents().get(1); final JvmGenericType type = ((JvmGenericType) _get); final JvmType parameterType = IterableExtensions.<JvmFormalParameter>head(IterableExtensions.<JvmOperation>head(Iterables.<JvmOperation>filter(type.getMembers(), JvmOperation.class)).getParameters()).getParameterType().getType(); Assert.assertNotNull(parameterType); Resource _eResource = parameterType.eResource(); Assert.assertTrue(((StorageAwareResource) _eResource).isLoadedFromStorage()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }