Search in sources :

Example 6 with ChunkedResourceDescriptions

use of org.eclipse.xtext.resource.impl.ChunkedResourceDescriptions 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 ChunkedResourceDescriptions

use of org.eclipse.xtext.resource.impl.ChunkedResourceDescriptions 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 ChunkedResourceDescriptions

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

the class ProjectDescriptionBasedContainerManager method getContainer.

@Override
public IContainer getContainer(final IResourceDescription desc, final IResourceDescriptions resourceDescriptions) {
    final ChunkedResourceDescriptions chunkedResourceDescriptions = this.getChunkedResourceDescriptions(resourceDescriptions);
    if ((chunkedResourceDescriptions == null)) {
        String _name = ChunkedResourceDescriptions.class.getName();
        String _plus = ("expected " + _name);
        throw new IllegalArgumentException(_plus);
    }
    final ResourceSet resourceSet = chunkedResourceDescriptions.getResourceSet();
    final ProjectDescription projectDescription = ProjectDescription.findInEmfObject(resourceSet);
    final IContainer container = this.createContainer(resourceDescriptions, chunkedResourceDescriptions, projectDescription.getName());
    return container;
}
Also used : LiveShadowedChunkedResourceDescriptions(org.eclipse.xtext.resource.impl.LiveShadowedChunkedResourceDescriptions) ChunkedResourceDescriptions(org.eclipse.xtext.resource.impl.ChunkedResourceDescriptions) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) IContainer(org.eclipse.xtext.resource.IContainer) ProjectDescription(org.eclipse.xtext.resource.impl.ProjectDescription)

Example 9 with ChunkedResourceDescriptions

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

the class ProjectDescriptionBasedContainerManager method getVisibleContainers.

@Override
public List<IContainer> getVisibleContainers(final IResourceDescription desc, final IResourceDescriptions resourceDescriptions) {
    final ChunkedResourceDescriptions chunkedResourceDescriptions = this.getChunkedResourceDescriptions(resourceDescriptions);
    if ((chunkedResourceDescriptions == null)) {
        String _name = ChunkedResourceDescriptions.class.getName();
        String _plus = ("expected " + _name);
        throw new IllegalArgumentException(_plus);
    }
    final ResourceSet resourceSet = chunkedResourceDescriptions.getResourceSet();
    final ProjectDescription projectDescription = ProjectDescription.findInEmfObject(resourceSet);
    final ArrayList<IContainer> allContainers = CollectionLiterals.<IContainer>newArrayList();
    allContainers.add(this.createContainer(resourceDescriptions, chunkedResourceDescriptions, projectDescription.getName()));
    List<String> _dependencies = projectDescription.getDependencies();
    for (final String name : _dependencies) {
        allContainers.add(this.createContainer(resourceDescriptions, chunkedResourceDescriptions, name));
    }
    return allContainers;
}
Also used : LiveShadowedChunkedResourceDescriptions(org.eclipse.xtext.resource.impl.LiveShadowedChunkedResourceDescriptions) ChunkedResourceDescriptions(org.eclipse.xtext.resource.impl.ChunkedResourceDescriptions) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) IContainer(org.eclipse.xtext.resource.IContainer) ProjectDescription(org.eclipse.xtext.resource.impl.ProjectDescription)

Example 10 with ChunkedResourceDescriptions

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

the class LiveShadowedChunkedContainerTest method assertGlobalDescriptionsAreUnaffected.

private void assertGlobalDescriptionsAreUnaffected() {
    IResourceDescriptions _globalDescriptions = this.liveShadowedChunkedResourceDescriptions.getGlobalDescriptions();
    final Function1<IEObjectDescription, String> _function = (IEObjectDescription it) -> {
        return it.getQualifiedName().toString();
    };
    Assert.assertEquals("foo", IterableExtensions.join(IterableExtensions.<IEObjectDescription, String>map(((ChunkedResourceDescriptions) _globalDescriptions).getContainer("foo").getExportedObjects(), _function), ","));
    IResourceDescriptions _globalDescriptions_1 = this.liveShadowedChunkedResourceDescriptions.getGlobalDescriptions();
    final Function1<IEObjectDescription, String> _function_1 = (IEObjectDescription it) -> {
        return it.getQualifiedName().toString();
    };
    Assert.assertEquals("bar", IterableExtensions.join(IterableExtensions.<IEObjectDescription, String>map(((ChunkedResourceDescriptions) _globalDescriptions_1).getContainer("bar").getExportedObjects(), _function_1), ","));
}
Also used : IResourceDescriptions(org.eclipse.xtext.resource.IResourceDescriptions) LiveShadowedChunkedResourceDescriptions(org.eclipse.xtext.resource.impl.LiveShadowedChunkedResourceDescriptions) ChunkedResourceDescriptions(org.eclipse.xtext.resource.impl.ChunkedResourceDescriptions) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Aggregations

ChunkedResourceDescriptions (org.eclipse.xtext.resource.impl.ChunkedResourceDescriptions)10 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)5 LiveShadowedChunkedResourceDescriptions (org.eclipse.xtext.resource.impl.LiveShadowedChunkedResourceDescriptions)5 ResourceDescriptionsData (org.eclipse.xtext.resource.impl.ResourceDescriptionsData)4 ProjectDescription (org.eclipse.xtext.resource.impl.ProjectDescription)3 Map (java.util.Map)2 URI (org.eclipse.emf.common.util.URI)2 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)2 BuildRequest (org.eclipse.xtext.build.BuildRequest)2 IContainer (org.eclipse.xtext.resource.IContainer)2 InMemoryURIHandler (org.eclipse.xtext.testing.util.InMemoryURIHandler)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 URIHandler (org.eclipse.emf.ecore.resource.URIHandler)1 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)1 IndexState (org.eclipse.xtext.build.IndexState)1 Source2GeneratedMapping (org.eclipse.xtext.build.Source2GeneratedMapping)1 TextRegionAccessToString (org.eclipse.xtext.formatting2.debug.TextRegionAccessToString)1 TextDocumentChangeToString (org.eclipse.xtext.ide.serializer.debug.TextDocumentChangeToString)1 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)1