Search in sources :

Example 1 with LiveShadowedChunkedContainer

use of org.eclipse.xtext.resource.containers.LiveShadowedChunkedContainer in project xtext-core by eclipse.

the class LiveShadowedChunkedContainerTest method testAddToNewContainer.

@Test
public void testAddToNewContainer() {
    try {
        final ProjectConfig bazProject = new ProjectConfig("baz", this.workspaceConfig);
        final URI newURI = IterableExtensions.<SourceFolder>head(bazProject.getSourceFolders()).getPath().trimSegments(1).appendSegment("baz.livecontainertestlanguage");
        this._parseHelper.parse("baz", newURI, this.rs1);
        final LiveShadowedChunkedContainer bazContainer = new LiveShadowedChunkedContainer(this.liveShadowedChunkedResourceDescriptions, "baz");
        Assert.assertEquals(1, IterableExtensions.size(this.fooContainer.getResourceDescriptions()));
        Assert.assertEquals(1, this.fooContainer.getResourceDescriptionCount());
        final Function1<IEObjectDescription, String> _function = (IEObjectDescription it) -> {
            return it.getQualifiedName().toString();
        };
        Assert.assertEquals("foo", IterableExtensions.join(IterableExtensions.<String>sort(IterableExtensions.<IEObjectDescription, String>map(this.fooContainer.getExportedObjects(), _function)), ","));
        Assert.assertEquals(1, IterableExtensions.size(this.barContainer.getResourceDescriptions()));
        Assert.assertEquals(1, this.barContainer.getResourceDescriptionCount());
        final Function1<IEObjectDescription, String> _function_1 = (IEObjectDescription it) -> {
            return it.getQualifiedName().toString();
        };
        Assert.assertEquals("bar", IterableExtensions.join(IterableExtensions.<String>sort(IterableExtensions.<IEObjectDescription, String>map(this.barContainer.getExportedObjects(), _function_1)), ","));
        Assert.assertEquals(1, IterableExtensions.size(bazContainer.getResourceDescriptions()));
        Assert.assertEquals(1, bazContainer.getResourceDescriptionCount());
        final Function1<IEObjectDescription, String> _function_2 = (IEObjectDescription it) -> {
            return it.getQualifiedName().toString();
        };
        Assert.assertEquals("baz", IterableExtensions.join(IterableExtensions.<String>sort(IterableExtensions.<IEObjectDescription, String>map(bazContainer.getExportedObjects(), _function_2)), ","));
        Assert.assertEquals(newURI, IterableExtensions.<IEObjectDescription>head(bazContainer.getExportedObjects(LiveContainerTestLanguagePackage.Literals.MODEL, QualifiedName.create("baz"), false)).getEObjectURI().trimFragment());
        this.assertGlobalDescriptionsAreUnaffected();
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : ProjectConfig(org.eclipse.xtext.resource.containers.ProjectConfig) LiveShadowedChunkedContainer(org.eclipse.xtext.resource.containers.LiveShadowedChunkedContainer) URI(org.eclipse.emf.common.util.URI) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Test(org.junit.Test)

Example 2 with LiveShadowedChunkedContainer

use of org.eclipse.xtext.resource.containers.LiveShadowedChunkedContainer 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)

Example 3 with LiveShadowedChunkedContainer

use of org.eclipse.xtext.resource.containers.LiveShadowedChunkedContainer 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)

Aggregations

LiveShadowedChunkedContainer (org.eclipse.xtext.resource.containers.LiveShadowedChunkedContainer)3 ProjectConfig (org.eclipse.xtext.resource.containers.ProjectConfig)2 LiveShadowedChunkedResourceDescriptions (org.eclipse.xtext.resource.impl.LiveShadowedChunkedResourceDescriptions)2 ResourceDescriptionsData (org.eclipse.xtext.resource.impl.ResourceDescriptionsData)2 URI (org.eclipse.emf.common.util.URI)1 IContainer (org.eclipse.xtext.resource.IContainer)1 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)1 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)1 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)1 SourceFolder (org.eclipse.xtext.resource.containers.SourceFolder)1 ChunkedResourceDescriptions (org.eclipse.xtext.resource.impl.ChunkedResourceDescriptions)1 ResourceDescriptionsBasedContainer (org.eclipse.xtext.resource.impl.ResourceDescriptionsBasedContainer)1 WorkspaceConfig (org.eclipse.xtext.workspace.WorkspaceConfig)1 Before (org.junit.Before)1 Test (org.junit.Test)1