use of org.eclipse.xtext.ui.editor.XtextReadonlyEditorInput in project xtext-eclipse by eclipse.
the class JavaClassPathResourceForIEditorInputFactoryTest method testBug463258_04.
@Test(expected = CoreException.class)
public void testBug463258_04() throws Throwable {
IFolder externalFolder = createExternalFolder("externalFolder");
IJavaProject project = createJavaProject("foo");
addExternalFolderToClasspath(project, externalFolder);
IPackageFragmentRoot root = project.getPackageFragmentRoot(externalFolder);
IPackageFragment foo = root.getPackageFragment("foo");
NonJavaResource fileInFolder = new NonJavaResource(foo, externalFolder.getFile("foo/doesNotExist.testlanguage"));
externalFolder.delete(true, null);
XtextReadonlyEditorInput editorInput = new XtextReadonlyEditorInput(fileInFolder);
try {
factory.createResource(editorInput);
} catch (WrappedException e) {
throw e.getCause();
}
}
use of org.eclipse.xtext.ui.editor.XtextReadonlyEditorInput in project xtext-eclipse by eclipse.
the class JavaClassPathResourceForIEditorInputFactoryTest method testBug463258_03a.
@Test
public void testBug463258_03a() throws Exception {
IJavaProject project = createJavaProject("foo");
IFile file = project.getProject().getFile("foo.jar");
file.create(jarInputStream(new TextFile("foo/bar.testlanguage", "//empty")), true, monitor());
addJarToClasspath(project, file);
IPackageFragmentRoot root = project.getPackageFragmentRoot(file);
IPackageFragment foo = root.getPackageFragment("foo");
JarEntryFile fileInJar = new JarEntryFile("bar.testlanguage");
fileInJar.setParent(foo);
File jarFile = file.getRawLocation().toFile();
assertTrue("exists", jarFile.exists());
assertTrue("delete", jarFile.delete());
XtextReadonlyEditorInput editorInput = new XtextReadonlyEditorInput(fileInJar);
Resource resource = factory.createResource(editorInput);
assertNotNull(resource);
try {
resource.load(null);
} catch (IOException e) {
// expected
}
}
use of org.eclipse.xtext.ui.editor.XtextReadonlyEditorInput in project xtext-eclipse by eclipse.
the class JavaClassPathResourceForIEditorInputFactoryTest method testBug463258_03c.
@Test(expected = CoreException.class)
public void testBug463258_03c() throws Throwable {
IJavaProject project = createJavaProject("foo");
IFile file = project.getProject().getFile("foo.jar");
file.create(jarInputStream(new TextFile("foo/bar.testlanguage", "//empty")), true, monitor());
addJarToClasspath(project, file);
IPackageFragmentRoot root = JarPackageFragmentRootTestUtil.getJarPackageFragmentRoot(file, (JavaProject) project);
IPackageFragment foo = root.getPackageFragment("foo");
JarEntryFile fileInJar = new JarEntryFile("bar.testlanguage");
fileInJar.setParent(foo);
File jarFile = file.getLocation().toFile();
assertTrue("exists", jarFile.exists());
assertTrue("delete", jarFile.delete());
// simulate an automated refresh
file.refreshLocal(IResource.DEPTH_ONE, null);
XtextReadonlyEditorInput editorInput = new XtextReadonlyEditorInput(fileInJar);
try {
factory.createResource(editorInput);
} catch (WrappedException e) {
throw e.getCause();
}
}
use of org.eclipse.xtext.ui.editor.XtextReadonlyEditorInput in project xtext-eclipse by eclipse.
the class JavaClassPathResourceForIEditorInputFactoryTest method testBug463258_05.
@Test(expected = CoreException.class)
public void testBug463258_05() throws Throwable {
IJavaProject project = createJavaProject("foo");
IPackageFragmentRoot root = project.getPackageFragmentRoot("does/not/exist.jar");
IPackageFragment foo = root.getPackageFragment("foo");
final JarEntryFile fileInJar = new JarEntryFile("bar.testlanguage");
fileInJar.setParent(foo);
XtextReadonlyEditorInput editorInput = new XtextReadonlyEditorInput(fileInJar);
try {
factory.createResource(editorInput);
} catch (WrappedException e) {
throw e.getCause();
}
}
use of org.eclipse.xtext.ui.editor.XtextReadonlyEditorInput in project xtext-eclipse by eclipse.
the class JavaClassPathResourceForIEditorInputFactoryTest method testBug463258_02.
@Test
public void testBug463258_02() throws Exception {
IJavaProject project = createJavaProject("foo");
IFile file = project.getProject().getFile("foo.jar");
file.create(jarInputStream(new TextFile("do/not", "care")), true, monitor());
addJarToClasspath(project, file);
IPackageFragmentRoot root = project.getPackageFragmentRoot(file);
IPackageFragment foo = root.getPackageFragment("unknown");
JarEntryFile fileInJar = new JarEntryFile("doesNotExist.testlanguage");
fileInJar.setParent(foo);
XtextReadonlyEditorInput editorInput = new XtextReadonlyEditorInput(fileInJar);
Resource resource = factory.createResource(editorInput);
assertNotNull(resource);
try {
resource.load(null);
} catch (IOException e) {
// expected
}
}
Aggregations