Search in sources :

Example 6 with Storage2UriMapperImpl

use of org.eclipse.xtext.ui.resource.Storage2UriMapperImpl in project xtext-eclipse by eclipse.

the class Storage2UriMapperTest method testSimpleFileInProject.

@Test
public void testSimpleFileInProject() throws Exception {
    createProject("foo");
    IFile file = createFile("foo/bar/baz.txt", "");
    Storage2UriMapperImpl mapper = new Storage2UriMapperImpl() {

        @Override
        public boolean isValidUri(URI uri, IStorage storage) {
            return true;
        }
    };
    mapper.setUriValidator(new UriValidator() {

        @Override
        public boolean isValid(URI uri, IStorage storage) {
            return true;
        }

        @Override
        public boolean isPossiblyManaged(IStorage storage) {
            return true;
        }
    });
    URI uri = mapper.getUri(file);
    assertEquals(URI.createPlatformResourceURI(file.getFullPath().toString(), true), uri);
    assertEquals(file, mapper.getStorages(uri).iterator().next().getFirst());
}
Also used : IFile(org.eclipse.core.resources.IFile) Storage2UriMapperImpl(org.eclipse.xtext.ui.resource.Storage2UriMapperImpl) UriValidator(org.eclipse.xtext.ui.resource.UriValidator) IStorage(org.eclipse.core.resources.IStorage) URI(org.eclipse.emf.common.util.URI) Test(org.junit.Test)

Aggregations

Storage2UriMapperImpl (org.eclipse.xtext.ui.resource.Storage2UriMapperImpl)6 IStorage (org.eclipse.core.resources.IStorage)4 URI (org.eclipse.emf.common.util.URI)4 UriValidator (org.eclipse.xtext.ui.resource.UriValidator)4 WorkspaceProjectsStateHelper (org.eclipse.xtext.ui.containers.WorkspaceProjectsStateHelper)3 JdtHelper (org.eclipse.xtext.ui.shared.JdtHelper)3 JavaProjectsStateHelper (org.eclipse.xtext.ui.containers.JavaProjectsStateHelper)2 WorkspaceProjectsState (org.eclipse.xtext.ui.containers.WorkspaceProjectsState)2 IFile (org.eclipse.core.resources.IFile)1 IResource (org.eclipse.core.resources.IResource)1 ProjectDescriptionBasedContainerManager (org.eclipse.xtext.resource.containers.ProjectDescriptionBasedContainerManager)1 StateBasedContainerManager (org.eclipse.xtext.resource.containers.StateBasedContainerManager)1 JavaProjectsState (org.eclipse.xtext.ui.containers.JavaProjectsState)1 StrictJavaProjectsState (org.eclipse.xtext.ui.containers.StrictJavaProjectsState)1 JarEntryLocator (org.eclipse.xtext.ui.resource.JarEntryLocator)1 Storage2UriMapperJavaImpl (org.eclipse.xtext.ui.resource.Storage2UriMapperJavaImpl)1 Test (org.junit.Test)1