Search in sources :

Example 11 with ResourceDescriptionsData

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

the class Indexer method computeAndIndexAffected.

public Indexer.IndexResult computeAndIndexAffected(final BuildRequest request, @Extension final BuildContext context) {
    final ResourceDescriptionsData previousIndex = context.getOldState().getResourceDescriptions();
    final ResourceDescriptionsData newIndex = request.getState().getResourceDescriptions();
    final List<IResourceDescription.Delta> deltas = CollectionLiterals.<IResourceDescription.Delta>newArrayList();
    boolean _isInfoEnabled = Indexer.LOG.isInfoEnabled();
    if (_isInfoEnabled) {
        Set<URI> _set = IterableExtensions.<URI>toSet(request.getDeletedFiles());
        String _plus = ("Creating Deltas for changes. Deleted : " + _set);
        String _plus_1 = (_plus + ", Changed : ");
        Set<URI> _set_1 = IterableExtensions.<URI>toSet(request.getDirtyFiles());
        String _plus_2 = (_plus_1 + _set_1);
        String _plus_3 = (_plus_2 + ".");
        Indexer.LOG.info(_plus_3);
    }
    deltas.addAll(this.getDeltasForDeletedResources(request, previousIndex, context));
    deltas.addAll(this.getDeltasForChangedResources(request.getDirtyFiles(), previousIndex, context));
    for (final IResourceDescription.Delta delta : deltas) {
        newIndex.register(delta);
    }
    final HashSet<IResourceDescription.Delta> allDeltas = new HashSet<IResourceDescription.Delta>(deltas);
    boolean _isEmpty = request.getExternalDeltas().isEmpty();
    boolean _not = (!_isEmpty);
    if (_not) {
        allDeltas.addAll(request.getExternalDeltas());
    }
    final Function1<IResourceDescription, URI> _function = (IResourceDescription it) -> {
        return it.getURI();
    };
    final Set<URI> remainingURIs = IterableExtensions.<URI>toSet(IterableExtensions.<IResourceDescription, URI>map(previousIndex.getAllResourceDescriptions(), _function));
    final Function1<IResourceDescription.Delta, URI> _function_1 = (IResourceDescription.Delta it) -> {
        return it.getUri();
    };
    remainingURIs.removeAll(ListExtensions.<IResourceDescription.Delta, URI>map(deltas, _function_1));
    final Function1<URI, Boolean> _function_2 = (URI it) -> {
        final IResourceDescription.Manager manager = context.getResourceServiceProvider(it).getResourceDescriptionManager();
        final IResourceDescription resourceDescription = previousIndex.getResourceDescription(it);
        final boolean isAffected = this.isAffected(resourceDescription, manager, allDeltas, allDeltas, newIndex);
        return Boolean.valueOf(isAffected);
    };
    final List<URI> allAffected = IterableExtensions.<URI>toList(IterableExtensions.<URI>filter(remainingURIs, _function_2));
    if ((Indexer.LOG.isInfoEnabled() && (!allAffected.isEmpty()))) {
        Set<URI> _set_2 = IterableExtensions.<URI>toSet(allAffected);
        String _plus_4 = ("Creating Deltas for affected resources : " + _set_2);
        String _plus_5 = (_plus_4 + ".");
        Indexer.LOG.info(_plus_5);
    }
    deltas.addAll(this.getDeltasForChangedResources(allAffected, previousIndex, context));
    return new Indexer.IndexResult(deltas, newIndex);
}
Also used : IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) OperationCanceledManager(org.eclipse.xtext.service.OperationCanceledManager) URI(org.eclipse.emf.common.util.URI) ResourceDescriptionsData(org.eclipse.xtext.resource.impl.ResourceDescriptionsData) DefaultResourceDescriptionDelta(org.eclipse.xtext.resource.impl.DefaultResourceDescriptionDelta) HashSet(java.util.HashSet)

Example 12 with ResourceDescriptionsData

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

the class LiveShadowedChunkedContainer method getChunk.

protected ResourceDescriptionsData getChunk() {
    ResourceDescriptionsData _elvis = null;
    ResourceDescriptionsData _container = this.getChunkedResourceDescriptions().getContainer(this.containerName);
    if (_container != null) {
        _elvis = _container;
    } else {
        ResourceDescriptionsData _resourceDescriptionsData = new ResourceDescriptionsData(Collections.<IResourceDescription>unmodifiableList(CollectionLiterals.<IResourceDescription>newArrayList()));
        _elvis = _resourceDescriptionsData;
    }
    return _elvis;
}
Also used : ResourceDescriptionsData(org.eclipse.xtext.resource.impl.ResourceDescriptionsData) IResourceDescription(org.eclipse.xtext.resource.IResourceDescription)

Example 13 with ResourceDescriptionsData

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

the class ProjectDescriptionBasedContainerManager method createContainer.

protected IContainer createContainer(final IResourceDescriptions resourceDescriptions, final ChunkedResourceDescriptions chunkedResourceDescriptions, final String projectName) {
    IContainer _xifexpression = null;
    if ((resourceDescriptions instanceof LiveShadowedChunkedResourceDescriptions)) {
        _xifexpression = new LiveShadowedChunkedContainer(((LiveShadowedChunkedResourceDescriptions) resourceDescriptions), projectName);
    } else {
        ResourceDescriptionsData _elvis = null;
        ResourceDescriptionsData _container = chunkedResourceDescriptions.getContainer(projectName);
        if (_container != null) {
            _elvis = _container;
        } else {
            Set<IResourceDescription> _emptySet = CollectionLiterals.<IResourceDescription>emptySet();
            ResourceDescriptionsData _resourceDescriptionsData = new ResourceDescriptionsData(_emptySet);
            _elvis = _resourceDescriptionsData;
        }
        _xifexpression = new ResourceDescriptionsBasedContainer(_elvis);
    }
    return _xifexpression;
}
Also used : ResourceDescriptionsData(org.eclipse.xtext.resource.impl.ResourceDescriptionsData) LiveShadowedChunkedResourceDescriptions(org.eclipse.xtext.resource.impl.LiveShadowedChunkedResourceDescriptions) IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) ResourceDescriptionsBasedContainer(org.eclipse.xtext.resource.impl.ResourceDescriptionsBasedContainer) IContainer(org.eclipse.xtext.resource.IContainer) LiveShadowedChunkedContainer(org.eclipse.xtext.resource.containers.LiveShadowedChunkedContainer)

Example 14 with ResourceDescriptionsData

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

the class ChunkedResourceDescriptions method readExternal.

@Override
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
    final int numChunks = in.readInt();
    ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, numChunks, true);
    for (final Integer i : _doubleDotLessThan) {
        {
            final String chunkName = in.readUTF();
            final int numDescriptions = in.readInt();
            final ArrayList<IResourceDescription> descriptions = new ArrayList<IResourceDescription>(numDescriptions);
            ExclusiveRange _doubleDotLessThan_1 = new ExclusiveRange(0, numDescriptions, true);
            for (final Integer j : _doubleDotLessThan_1) {
                Object _readObject = in.readObject();
                descriptions.add(((IResourceDescription) _readObject));
            }
            ResourceDescriptionsData _resourceDescriptionsData = new ResourceDescriptionsData(descriptions);
            this.chunk2resourceDescriptions.put(chunkName, _resourceDescriptionsData);
        }
    }
}
Also used : ResourceDescriptionsData(org.eclipse.xtext.resource.impl.ResourceDescriptionsData) IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) ArrayList(java.util.ArrayList) ExclusiveRange(org.eclipse.xtext.xbase.lib.ExclusiveRange)

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