Search in sources :

Example 6 with ResourceDescriptionsData

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

the class ProjectManager method createFreshResourceSet.

protected XtextResourceSet createFreshResourceSet(final ResourceDescriptionsData newIndex) {
    if ((this.resourceSet == null)) {
        this.resourceSet = this.createNewResourceSet(newIndex);
    } else {
        final ChunkedResourceDescriptions resDescs = ChunkedResourceDescriptions.findInEmfObject(this.resourceSet);
        Set<Map.Entry<String, ResourceDescriptionsData>> _entrySet = this.indexProvider.get().entrySet();
        for (final Map.Entry<String, ResourceDescriptionsData> entry : _entrySet) {
            resDescs.setContainer(entry.getKey(), entry.getValue());
        }
        resDescs.setContainer(this.projectDescription.getName(), newIndex);
    }
    return this.resourceSet;
}
Also used : ResourceDescriptionsData(org.eclipse.xtext.resource.impl.ResourceDescriptionsData) ChunkedResourceDescriptions(org.eclipse.xtext.resource.impl.ChunkedResourceDescriptions) Map(java.util.Map)

Example 7 with ResourceDescriptionsData

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

the class AbstractIncrementalBuilderTest method newBuildRequest.

protected BuildRequest newBuildRequest(final Procedure1<? super BuildRequest> init) {
    BuildRequest _buildRequest = new BuildRequest();
    final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
        final ResourceDescriptionsData newIndex = this.indexState.getResourceDescriptions().copy();
        it.setBaseDir(this.uri(""));
        XtextResourceSet _get = this.resourceSetProvider.get();
        final Procedure1<XtextResourceSet> _function_1 = (XtextResourceSet it_1) -> {
            it_1.getURIConverter().getURIHandlers().clear();
            EList<URIHandler> _uRIHandlers = it_1.getURIConverter().getURIHandlers();
            _uRIHandlers.add(this.inMemoryURIHandler);
            it_1.setClasspathURIContext(AbstractIncrementalBuilderTest.class.getClassLoader());
            ProjectDescription _projectDescription = new ProjectDescription();
            final Procedure1<ProjectDescription> _function_2 = (ProjectDescription it_2) -> {
                it_2.setName("test-project");
            };
            final ProjectDescription projectDescription = ObjectExtensions.<ProjectDescription>operator_doubleArrow(_projectDescription, _function_2);
            projectDescription.attachToEmfObject(it_1);
            Map<String, ResourceDescriptionsData> _emptyMap = CollectionLiterals.<String, ResourceDescriptionsData>emptyMap();
            final ChunkedResourceDescriptions index = new ChunkedResourceDescriptions(_emptyMap, it_1);
            index.setContainer(projectDescription.getName(), newIndex);
        };
        XtextResourceSet _doubleArrow = ObjectExtensions.<XtextResourceSet>operator_doubleArrow(_get, _function_1);
        it.setResourceSet(_doubleArrow);
        it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList()));
        it.setDeletedFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList()));
        final BuildRequest.IPostValidationCallback _function_2 = (URI uri, Iterable<Issue> issues) -> {
            Iterables.<Issue>addAll(this.issues, issues);
            return IterableExtensions.isEmpty(issues);
        };
        it.setAfterValidate(_function_2);
        final Procedure1<URI> _function_3 = (URI it_1) -> {
            this.deleted.add(it_1);
        };
        it.setAfterDeleteFile(_function_3);
        final Procedure2<URI, URI> _function_4 = (URI source, URI target) -> {
            this.generated.put(source, target);
        };
        it.setAfterGenerateFile(_function_4);
        Source2GeneratedMapping _copy = this.indexState.getFileMappings().copy();
        IndexState _indexState = new IndexState(newIndex, _copy);
        it.setState(_indexState);
    };
    final BuildRequest result = ObjectExtensions.<BuildRequest>operator_doubleArrow(_buildRequest, _function);
    init.apply(result);
    return result;
}
Also used : Issue(org.eclipse.xtext.validation.Issue) Source2GeneratedMapping(org.eclipse.xtext.build.Source2GeneratedMapping) ChunkedResourceDescriptions(org.eclipse.xtext.resource.impl.ChunkedResourceDescriptions) BuildRequest(org.eclipse.xtext.build.BuildRequest) URI(org.eclipse.emf.common.util.URI) IndexState(org.eclipse.xtext.build.IndexState) ResourceDescriptionsData(org.eclipse.xtext.resource.impl.ResourceDescriptionsData) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) Procedure2(org.eclipse.xtext.xbase.lib.Procedures.Procedure2) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) URIHandler(org.eclipse.emf.ecore.resource.URIHandler) InMemoryURIHandler(org.eclipse.xtext.testing.util.InMemoryURIHandler) ProjectDescription(org.eclipse.xtext.resource.impl.ProjectDescription)

Example 8 with ResourceDescriptionsData

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

the class XtextGeneratorLanguage method installIndex.

private void installIndex() {
    List<IResourceDescription> _emptyList = Collections.<IResourceDescription>emptyList();
    final ResourceDescriptionsData index = new ResourceDescriptionsData(_emptyList);
    final ArrayList<Resource> resources = Lists.<Resource>newArrayList(this.resourceSet.getResources());
    for (final Resource resource : resources) {
        this.index(resource, resource.getURI(), index);
    }
    ResourceDescriptionsData.ResourceSetAdapter.installResourceDescriptionsData(this.resourceSet, index);
}
Also used : ResourceDescriptionsData(org.eclipse.xtext.resource.impl.ResourceDescriptionsData) IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) Resource(org.eclipse.emf.ecore.resource.Resource) XtextResource(org.eclipse.xtext.resource.XtextResource)

Example 9 with ResourceDescriptionsData

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

the class FlatResourceSetBasedAllContainersState method containsURI.

@Override
public boolean containsURI(String containerHandle, URI candidateURI) {
    if (!HANDLE.equals(containerHandle))
        return false;
    if (resourceSet instanceof XtextResourceSet) {
        ResourceDescriptionsData descriptionsData = findResourceDescriptionsData(resourceSet);
        if (descriptionsData != null) {
            return descriptionsData.getResourceDescription(candidateURI) != null;
        }
        Collection<URI> allUris = ((XtextResourceSet) resourceSet).getNormalizationMap().values();
        for (URI uri : allUris) {
            if (uri.equals(candidateURI)) {
                return true;
            }
        }
        return false;
    }
    URIConverter uriConverter = resourceSet.getURIConverter();
    for (Resource r : resourceSet.getResources()) {
        URI normalized = uriConverter.normalize(r.getURI());
        if (normalized.equals(candidateURI)) {
            return true;
        }
    }
    return false;
}
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 10 with ResourceDescriptionsData

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

the class IncrementalBuilder method build.

public IncrementalBuilder.Result build(final BuildRequest request, final Function1<? super URI, ? extends IResourceServiceProvider> languages, final IResourceClusteringPolicy clusteringPolicy) {
    try {
        final XtextResourceSet resourceSet = request.getResourceSet();
        ResourceDescriptionsData _copy = request.getState().getResourceDescriptions().copy();
        Source2GeneratedMapping _copy_1 = request.getState().getFileMappings().copy();
        final IndexState oldState = new IndexState(_copy, _copy_1);
        CancelIndicator _cancelIndicator = request.getCancelIndicator();
        final BuildContext context = new BuildContext(languages, resourceSet, oldState, clusteringPolicy, _cancelIndicator);
        final IncrementalBuilder.InternalStatefulIncrementalBuilder builder = this.provider.get();
        builder.context = context;
        builder.request = request;
        try {
            return builder.launch();
        } catch (final Throwable _t) {
            if (_t instanceof Throwable) {
                final Throwable t = (Throwable) _t;
                this._operationCanceledManager.propagateIfCancelException(t);
                throw t;
            } else {
                throw Exceptions.sneakyThrow(_t);
            }
        }
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : ResourceDescriptionsData(org.eclipse.xtext.resource.impl.ResourceDescriptionsData) BuildContext(org.eclipse.xtext.build.BuildContext) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) Source2GeneratedMapping(org.eclipse.xtext.build.Source2GeneratedMapping) CancelIndicator(org.eclipse.xtext.util.CancelIndicator) IndexState(org.eclipse.xtext.build.IndexState)

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