Search in sources :

Example 1 with ResourceDescriptionsData

use of org.eclipse.xtext.resource.impl.ResourceDescriptionsData in project xtext-core by eclipse.

the class ProjectManager method newBuildRequest.

protected BuildRequest newBuildRequest(final List<URI> changedFiles, final List<URI> deletedFiles, final List<IResourceDescription.Delta> externalDeltas, final CancelIndicator cancelIndicator) {
    BuildRequest _buildRequest = new BuildRequest();
    final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
        it.setBaseDir(this.baseDir);
        ResourceDescriptionsData _copy = this.indexState.getResourceDescriptions().copy();
        Source2GeneratedMapping _copy_1 = this.indexState.getFileMappings().copy();
        IndexState _indexState = new IndexState(_copy, _copy_1);
        it.setState(_indexState);
        it.setResourceSet(this.createFreshResourceSet(it.getState().getResourceDescriptions()));
        it.setDirtyFiles(changedFiles);
        it.setDeletedFiles(deletedFiles);
        it.setExternalDeltas(externalDeltas);
        final BuildRequest.IPostValidationCallback _function_1 = (URI uri, Iterable<Issue> issues) -> {
            this.issueAcceptor.apply(uri, issues);
            return true;
        };
        it.setAfterValidate(_function_1);
        it.setCancelIndicator(cancelIndicator);
    };
    return ObjectExtensions.<BuildRequest>operator_doubleArrow(_buildRequest, _function);
}
Also used : ResourceDescriptionsData(org.eclipse.xtext.resource.impl.ResourceDescriptionsData) Source2GeneratedMapping(org.eclipse.xtext.build.Source2GeneratedMapping) BuildRequest(org.eclipse.xtext.build.BuildRequest) URI(org.eclipse.emf.common.util.URI) IndexState(org.eclipse.xtext.build.IndexState)

Example 2 with ResourceDescriptionsData

use of org.eclipse.xtext.resource.impl.ResourceDescriptionsData in project xtext-core by eclipse.

the class ChangeSerializerTestHelper method createResourceSet.

public ResourceSet createResourceSet(final InMemoryURIHandler fs) {
    final XtextResourceSet idx = new XtextResourceSet();
    idx.getURIConverter().getURIHandlers().add(0, fs);
    Collection<InMemoryURIHandler.InMemFile> _values = fs.getFiles().values();
    for (final InMemoryURIHandler.InMemFile f : _values) {
        idx.getResource(f.getUri(), true);
    }
    EcoreUtil.resolveAll(idx);
    final Consumer<XtextResource> _function = (XtextResource it) -> {
        this.validator.assertNoErrors(it);
    };
    Iterables.<XtextResource>filter(idx.getResources(), XtextResource.class).forEach(_function);
    final Function1<Resource, IResourceDescription> _function_1 = (Resource it) -> {
        return this.rdManager.getResourceDescription(it);
    };
    final List<IResourceDescription> rsd = ListExtensions.<Resource, IResourceDescription>map(idx.getResources(), _function_1);
    final ResourceDescriptionsData data = new ResourceDescriptionsData(rsd);
    final XtextResourceSet r = new XtextResourceSet();
    r.getLoadOptions().put(ResourceDescriptionsProvider.LIVE_SCOPE, Boolean.TRUE);
    r.getURIConverter().getURIHandlers().add(0, fs);
    ResourceDescriptionsData.ResourceSetAdapter.installResourceDescriptionsData(r, data);
    return r;
}
Also used : ResourceDescriptionsData(org.eclipse.xtext.resource.impl.ResourceDescriptionsData) IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) InMemoryURIHandler(org.eclipse.xtext.testing.util.InMemoryURIHandler) XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource) XtextResource(org.eclipse.xtext.resource.XtextResource)

Example 3 with ResourceDescriptionsData

use of org.eclipse.xtext.resource.impl.ResourceDescriptionsData in project xtext-core by eclipse.

the class ImportTestHelper method createResourceSet.

public ResourceSet createResourceSet(final InMemoryURIHandler fs) {
    final XtextResourceSet idx = new XtextResourceSet();
    idx.getURIConverter().getURIHandlers().add(0, fs);
    Collection<InMemoryURIHandler.InMemFile> _values = fs.getFiles().values();
    for (final InMemoryURIHandler.InMemFile f : _values) {
        idx.getResource(f.getUri(), true);
    }
    EcoreUtil.resolveAll(idx);
    final Consumer<XtextResource> _function = (XtextResource it) -> {
        this.validator.assertNoErrors(it);
    };
    Iterables.<XtextResource>filter(idx.getResources(), XtextResource.class).forEach(_function);
    final Function1<Resource, IResourceDescription> _function_1 = (Resource it) -> {
        return this.rdManager.getResourceDescription(it);
    };
    final List<IResourceDescription> rsd = ListExtensions.<Resource, IResourceDescription>map(idx.getResources(), _function_1);
    final ResourceDescriptionsData data = new ResourceDescriptionsData(rsd);
    final XtextResourceSet r = new XtextResourceSet();
    r.getLoadOptions().put(ResourceDescriptionsProvider.LIVE_SCOPE, Boolean.TRUE);
    r.getURIConverter().getURIHandlers().add(0, fs);
    ResourceDescriptionsData.ResourceSetAdapter.installResourceDescriptionsData(r, data);
    Pair<String, ResourceDescriptionsData> _mappedTo = Pair.<String, ResourceDescriptionsData>of("egal", data);
    new ChunkedResourceDescriptions(Collections.<String, ResourceDescriptionsData>unmodifiableMap(CollectionLiterals.<String, ResourceDescriptionsData>newHashMap(_mappedTo)), r);
    return r;
}
Also used : IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) InMemoryURIHandler(org.eclipse.xtext.testing.util.InMemoryURIHandler) XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource) ChunkedResourceDescriptions(org.eclipse.xtext.resource.impl.ChunkedResourceDescriptions) XtextResource(org.eclipse.xtext.resource.XtextResource) TextRegionAccessToString(org.eclipse.xtext.formatting2.debug.TextRegionAccessToString) TextDocumentChangeToString(org.eclipse.xtext.ide.serializer.debug.TextDocumentChangeToString) ResourceDescriptionsData(org.eclipse.xtext.resource.impl.ResourceDescriptionsData) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet)

Example 4 with ResourceDescriptionsData

use of org.eclipse.xtext.resource.impl.ResourceDescriptionsData in project xtext-core by eclipse.

the class FlatResourceSetBasedAllContainersState method getContainedURIs.

@Override
public Collection<URI> getContainedURIs(String containerHandle) {
    if (!HANDLE.equals(containerHandle))
        return Collections.emptySet();
    if (resourceSet instanceof XtextResourceSet) {
        ResourceDescriptionsData descriptionsData = findResourceDescriptionsData(resourceSet);
        if (descriptionsData != null) {
            return descriptionsData.getAllURIs();
        }
        return newArrayList(((XtextResourceSet) resourceSet).getNormalizationMap().values());
    }
    List<URI> uris = Lists.newArrayListWithCapacity(resourceSet.getResources().size());
    URIConverter uriConverter = resourceSet.getURIConverter();
    for (Resource r : resourceSet.getResources()) uris.add(uriConverter.normalize(r.getURI()));
    return uris;
}
Also used : ResourceDescriptionsData(org.eclipse.xtext.resource.impl.ResourceDescriptionsData) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) Resource(org.eclipse.emf.ecore.resource.Resource) URIConverter(org.eclipse.emf.ecore.resource.URIConverter) URI(org.eclipse.emf.common.util.URI)

Example 5 with ResourceDescriptionsData

use of org.eclipse.xtext.resource.impl.ResourceDescriptionsData in project xtext-core by eclipse.

the class LiveShadowedChunkedContainerTest method setUp.

@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);
    }
}
Also used : ProjectConfig(org.eclipse.xtext.resource.containers.ProjectConfig) SourceFolder(org.eclipse.xtext.resource.containers.SourceFolder) ResourceDescriptionsData(org.eclipse.xtext.resource.impl.ResourceDescriptionsData) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) WorkspaceConfig(org.eclipse.xtext.workspace.WorkspaceConfig) LiveShadowedChunkedResourceDescriptions(org.eclipse.xtext.resource.impl.LiveShadowedChunkedResourceDescriptions) ChunkedResourceDescriptions(org.eclipse.xtext.resource.impl.ChunkedResourceDescriptions) LiveShadowedChunkedContainer(org.eclipse.xtext.resource.containers.LiveShadowedChunkedContainer) Before(org.junit.Before)

Aggregations

ResourceDescriptionsData (org.eclipse.xtext.resource.impl.ResourceDescriptionsData)14 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)7 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)7 URI (org.eclipse.emf.common.util.URI)5 Resource (org.eclipse.emf.ecore.resource.Resource)5 ChunkedResourceDescriptions (org.eclipse.xtext.resource.impl.ChunkedResourceDescriptions)4 IndexState (org.eclipse.xtext.build.IndexState)3 Source2GeneratedMapping (org.eclipse.xtext.build.Source2GeneratedMapping)3 XtextResource (org.eclipse.xtext.resource.XtextResource)3 InMemoryURIHandler (org.eclipse.xtext.testing.util.InMemoryURIHandler)3 URIConverter (org.eclipse.emf.ecore.resource.URIConverter)2 BuildRequest (org.eclipse.xtext.build.BuildRequest)2 LiveShadowedChunkedContainer (org.eclipse.xtext.resource.containers.LiveShadowedChunkedContainer)2 LiveShadowedChunkedResourceDescriptions (org.eclipse.xtext.resource.impl.LiveShadowedChunkedResourceDescriptions)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 URIHandler (org.eclipse.emf.ecore.resource.URIHandler)1 BuildContext (org.eclipse.xtext.build.BuildContext)1 TextRegionAccessToString (org.eclipse.xtext.formatting2.debug.TextRegionAccessToString)1