use of org.eclipse.xtext.ui.resource.UriValidator in project xtext-eclipse by eclipse.
the class AbstractJavaProjectsStateTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
javaProject1 = makeJavaProject(project1);
addSourceFolder(javaProject1, "src2");
uri1 = createFileAndRegisterResource(project1, "src/file1");
uri2 = createFileAndRegisterResource(project1, "src/file2");
uri3 = createFileAndRegisterResource(project2, "src2/file3");
IResource member = javaProject1.getProject().findMember("src");
srcRoot = javaProject1.getPackageFragmentRoot(member);
Storage2UriMapperImpl mapper = new Storage2UriMapperImpl() {
@Override
public boolean isValidUri(URI uri, IStorage storage) {
return uri != null && !uri.toString().endsWith("/.project") && !uri.toString().endsWith("/.classpath");
}
};
UriValidator uriValidator = new UriValidator() {
@Override
public boolean isValid(URI uri, IStorage storage) {
return "name".equals(uri.fileExtension());
}
@Override
public boolean isPossiblyManaged(IStorage storage) {
return "name".equals(storage.getFullPath().getFileExtension());
}
};
mapper.setUriValidator(uriValidator);
Storage2UriMapperJavaImpl contribution = new Storage2UriMapperJavaImpl();
contribution.setUriValidator(uriValidator);
contribution.setJdtHelper(new JdtHelper());
contribution.setWorkspaceLockAccess(new WorkspaceLockAccess());
contribution.setLocator(new JarEntryLocator());
contribution.setHost(mapper);
mapper.setContribution(contribution);
projectsState = createProjectsState(mapper);
}
use of org.eclipse.xtext.ui.resource.UriValidator in project xtext-eclipse by eclipse.
the class Storage2UriMapperTest method testSimpleFileInProject.
@Test
public void testSimpleFileInProject() throws Exception {
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());
}
Aggregations