Search in sources :

Example 1 with UriValidator

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

the class UriValidatorBug406208Test method testExtensionIsEncoded.

@Test
public void testExtensionIsEncoded() throws Exception {
    UriValidator validator = new UriValidator();
    new ReflectExtensions().set(validator, "registry", this);
    Assert.assertTrue(validator.isPossiblyManaged(this));
}
Also used : ReflectExtensions(org.eclipse.xtext.xbase.lib.util.ReflectExtensions) UriValidator(org.eclipse.xtext.ui.resource.UriValidator) Test(org.junit.Test)

Example 2 with UriValidator

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

the class StateBasedContainerManagerTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    IResourcesSetupUtil.setReference(project1, project2);
    uri1 = createFileAndRegisterResource(project1, "file1");
    uri2 = createFileAndRegisterResource(project1, "file2");
    uri3 = createFileAndRegisterResource(project2, "file3");
    Storage2UriMapperImpl mapper = new Storage2UriMapperImpl() {

        @Override
        public boolean isValidUri(URI uri, IStorage storage) {
            return uri != null && !uri.toString().endsWith("/.project");
        }
    };
    mapper.setUriValidator(new UriValidator() {

        @Override
        public boolean isPossiblyManaged(IStorage storage) {
            return true;
        }

        @Override
        public boolean isValid(URI uri, IStorage storage) {
            return true;
        }
    });
    projectsState = new WorkspaceProjectsState();
    projectsState.setMapper(mapper);
    WorkspaceProjectsStateHelper helper = new WorkspaceProjectsStateHelper();
    helper.setMapper(mapper);
    helper.setWorkspace(ResourcesPlugin.getWorkspace());
    projectsState.setHelper(helper);
    containerManager = new StateBasedContainerManager();
    containerManager.setStateProvider(this);
    containerManager.setDelegate(new ProjectDescriptionBasedContainerManager());
}
Also used : WorkspaceProjectsState(org.eclipse.xtext.ui.containers.WorkspaceProjectsState) StateBasedContainerManager(org.eclipse.xtext.resource.containers.StateBasedContainerManager) ProjectDescriptionBasedContainerManager(org.eclipse.xtext.resource.containers.ProjectDescriptionBasedContainerManager) Storage2UriMapperImpl(org.eclipse.xtext.ui.resource.Storage2UriMapperImpl) WorkspaceProjectsStateHelper(org.eclipse.xtext.ui.containers.WorkspaceProjectsStateHelper) UriValidator(org.eclipse.xtext.ui.resource.UriValidator) IStorage(org.eclipse.core.resources.IStorage) URI(org.eclipse.emf.common.util.URI)

Example 3 with UriValidator

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

the class Storage2UriMapperJdtImplTest method getStorage2UriMapper.

protected Storage2UriMapperJavaImpl getStorage2UriMapper() {
    Storage2UriMapperJavaImpl impl = new Storage2UriMapperJavaImpl();
    impl.setUriValidator(new UriValidator() {

        @Override
        public boolean isPossiblyManaged(IStorage storage) {
            return "indexed".equals(storage.getFullPath().getFileExtension());
        }

        @Override
        public boolean isValid(URI uri, IStorage storage) {
            return "indexed".equals(storage.getFullPath().getFileExtension());
        }
    });
    impl.setLocator(new JarEntryLocator());
    return impl;
}
Also used : Storage2UriMapperJavaImpl(org.eclipse.xtext.ui.resource.Storage2UriMapperJavaImpl) JarEntryLocator(org.eclipse.xtext.ui.resource.JarEntryLocator) UriValidator(org.eclipse.xtext.ui.resource.UriValidator) IStorage(org.eclipse.core.resources.IStorage) URI(org.eclipse.emf.common.util.URI)

Example 4 with UriValidator

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

the class Storage2UriMapperJavaImplTest method createFreshStorage2UriMapper.

protected Storage2UriMapperJavaImpl createFreshStorage2UriMapper() {
    Storage2UriMapperJavaImpl mapper = new Storage2UriMapperJavaImpl();
    mapper.setUriValidator(new UriValidator() {

        @Override
        public boolean isPossiblyManaged(IStorage storage) {
            return "indexed".equals(storage.getFullPath().getFileExtension());
        }

        @Override
        public boolean isValid(URI uri, IStorage storage) {
            return "indexed".equals(storage.getFullPath().getFileExtension());
        }
    });
    mapper.setLocator(new JarEntryLocator());
    mapper.setWorkspace(ResourcesPlugin.getWorkspace());
    mapper.setWorkspaceLockAccess(new WorkspaceLockAccess());
    mapper.setJavaProjectClasspathChangeAnalyzer(new JavaProjectClasspathChangeAnalyzer());
    return mapper;
}
Also used : WorkspaceLockAccess(org.eclipse.xtext.ui.workspace.WorkspaceLockAccess) Storage2UriMapperJavaImpl(org.eclipse.xtext.ui.resource.Storage2UriMapperJavaImpl) JarEntryLocator(org.eclipse.xtext.ui.resource.JarEntryLocator) UriValidator(org.eclipse.xtext.ui.resource.UriValidator) IStorage(org.eclipse.core.resources.IStorage) JavaProjectClasspathChangeAnalyzer(org.eclipse.xtext.ui.util.JavaProjectClasspathChangeAnalyzer) URI(org.eclipse.emf.common.util.URI)

Example 5 with UriValidator

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

the class WorkspaceProjectsStateTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    uri1 = createFileAndRegisterResource(project1, "file1");
    uri2 = createFileAndRegisterResource(project1, "file2");
    uri3 = createFileAndRegisterResource(project2, "file3");
    Storage2UriMapperImpl mapper = new Storage2UriMapperImpl() {

        @Override
        public boolean isValidUri(URI uri, IStorage storage) {
            return uri != null && !uri.toString().endsWith("/.project");
        }
    };
    mapper.setUriValidator(new UriValidator() {

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

        @Override
        public boolean isPossiblyManaged(IStorage storage) {
            return true;
        }
    });
    projectsState = new WorkspaceProjectsState();
    projectsState.setMapper(mapper);
    WorkspaceProjectsStateHelper helper = new WorkspaceProjectsStateHelper();
    helper.setMapper(mapper);
    helper.setWorkspace(ResourcesPlugin.getWorkspace());
    projectsState.setHelper(helper);
}
Also used : WorkspaceProjectsState(org.eclipse.xtext.ui.containers.WorkspaceProjectsState) Storage2UriMapperImpl(org.eclipse.xtext.ui.resource.Storage2UriMapperImpl) WorkspaceProjectsStateHelper(org.eclipse.xtext.ui.containers.WorkspaceProjectsStateHelper) UriValidator(org.eclipse.xtext.ui.resource.UriValidator) IStorage(org.eclipse.core.resources.IStorage) URI(org.eclipse.emf.common.util.URI)

Aggregations

UriValidator (org.eclipse.xtext.ui.resource.UriValidator)7 IStorage (org.eclipse.core.resources.IStorage)6 URI (org.eclipse.emf.common.util.URI)6 Storage2UriMapperImpl (org.eclipse.xtext.ui.resource.Storage2UriMapperImpl)4 JarEntryLocator (org.eclipse.xtext.ui.resource.JarEntryLocator)3 Storage2UriMapperJavaImpl (org.eclipse.xtext.ui.resource.Storage2UriMapperJavaImpl)3 WorkspaceProjectsState (org.eclipse.xtext.ui.containers.WorkspaceProjectsState)2 WorkspaceProjectsStateHelper (org.eclipse.xtext.ui.containers.WorkspaceProjectsStateHelper)2 WorkspaceLockAccess (org.eclipse.xtext.ui.workspace.WorkspaceLockAccess)2 Test (org.junit.Test)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 JdtHelper (org.eclipse.xtext.ui.shared.JdtHelper)1 JavaProjectClasspathChangeAnalyzer (org.eclipse.xtext.ui.util.JavaProjectClasspathChangeAnalyzer)1 ReflectExtensions (org.eclipse.xtext.xbase.lib.util.ReflectExtensions)1