Search in sources :

Example 11 with ChunkedResourceDescriptions

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

the class AbstractIncrementalBuilderTest method newBuildRequest.

protected BuildRequest newBuildRequest(Procedure1<? super BuildRequest> init) {
    BuildRequest result = new BuildRequest();
    ResourceDescriptionsData newIndex = indexState.getResourceDescriptions().copy();
    result.setBaseDir(uri(""));
    XtextResourceSet rs = resourceSetProvider.get();
    rs.getURIConverter().getURIHandlers().clear();
    rs.getURIConverter().getURIHandlers().add(inMemoryURIHandler);
    rs.setClasspathURIContext(AbstractIncrementalBuilderTest.class.getClassLoader());
    ProjectDescription projectDescription = new ProjectDescription();
    projectDescription.setName("test-project");
    projectDescription.attachToEmfObject(rs);
    ChunkedResourceDescriptions index = new ChunkedResourceDescriptions(Collections.emptyMap(), rs);
    index.setContainer(projectDescription.getName(), newIndex);
    result.setResourceSet(rs);
    result.setDirtyFiles(new ArrayList<>());
    result.setDeletedFiles(new ArrayList<>());
    result.setAfterValidate((uri, issues) -> {
        Iterables.addAll(this.issues, issues);
        return Iterables.isEmpty(issues);
    });
    result.setAfterDeleteFile(f -> deleted.add(f));
    result.setAfterGenerateFile((source, target) -> generated.put(source, target));
    result.setState(new IndexState(newIndex, indexState.getFileMappings().copy()));
    init.apply(result);
    return result;
}
Also used : ResourceDescriptionsData(org.eclipse.xtext.resource.impl.ResourceDescriptionsData) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) ChunkedResourceDescriptions(org.eclipse.xtext.resource.impl.ChunkedResourceDescriptions) BuildRequest(org.eclipse.xtext.build.BuildRequest) ProjectDescription(org.eclipse.xtext.resource.impl.ProjectDescription) IndexState(org.eclipse.xtext.build.IndexState)

Example 12 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(IResourceDescription desc, IResourceDescriptions resourceDescriptions) {
    ChunkedResourceDescriptions descriptions = getChunkedResourceDescriptions(resourceDescriptions);
    if (descriptions == null)
        throw new IllegalArgumentException("Expected " + ChunkedResourceDescriptions.class.getName());
    ProjectDescription projectDescription = ProjectDescription.findInEmfObject(descriptions.getResourceSet());
    List<IContainer> allContainers = new ArrayList<>();
    allContainers.add(createContainer(resourceDescriptions, descriptions, projectDescription.getName()));
    for (String name : projectDescription.getDependencies()) allContainers.add(createContainer(resourceDescriptions, descriptions, name));
    return allContainers;
}
Also used : ArrayList(java.util.ArrayList) LiveShadowedChunkedResourceDescriptions(org.eclipse.xtext.resource.impl.LiveShadowedChunkedResourceDescriptions) ChunkedResourceDescriptions(org.eclipse.xtext.resource.impl.ChunkedResourceDescriptions) IContainer(org.eclipse.xtext.resource.IContainer) ProjectDescription(org.eclipse.xtext.resource.impl.ProjectDescription)

Aggregations

ChunkedResourceDescriptions (org.eclipse.xtext.resource.impl.ChunkedResourceDescriptions)12 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)6 ResourceDescriptionsData (org.eclipse.xtext.resource.impl.ResourceDescriptionsData)6 LiveShadowedChunkedResourceDescriptions (org.eclipse.xtext.resource.impl.LiveShadowedChunkedResourceDescriptions)5 ProjectDescription (org.eclipse.xtext.resource.impl.ProjectDescription)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)2 BuildRequest (org.eclipse.xtext.build.BuildRequest)2 IndexState (org.eclipse.xtext.build.IndexState)2 IContainer (org.eclipse.xtext.resource.IContainer)2 InMemoryURIHandler (org.eclipse.xtext.testing.util.InMemoryURIHandler)2 Map (java.util.Map)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 URI (org.eclipse.emf.common.util.URI)1 Resource (org.eclipse.emf.ecore.resource.Resource)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 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)1