Search in sources :

Example 1 with XtextReadonlyEditorInput

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();
    }
}
Also used : XtextReadonlyEditorInput(org.eclipse.xtext.ui.editor.XtextReadonlyEditorInput) IPackageFragment(org.eclipse.jdt.core.IPackageFragment) WrappedException(org.eclipse.emf.common.util.WrappedException) IJavaProject(org.eclipse.jdt.core.IJavaProject) NonJavaResource(org.eclipse.jdt.internal.core.NonJavaResource) IFolder(org.eclipse.core.resources.IFolder) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot) Test(org.junit.Test) AbstractWorkbenchTest(org.eclipse.xtext.ui.testing.AbstractWorkbenchTest)

Example 2 with XtextReadonlyEditorInput

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
    }
}
Also used : XtextReadonlyEditorInput(org.eclipse.xtext.ui.editor.XtextReadonlyEditorInput) IPackageFragment(org.eclipse.jdt.core.IPackageFragment) IJavaProject(org.eclipse.jdt.core.IJavaProject) IFile(org.eclipse.core.resources.IFile) TextFile(org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile) NonJavaResource(org.eclipse.jdt.internal.core.NonJavaResource) IResource(org.eclipse.core.resources.IResource) Resource(org.eclipse.emf.ecore.resource.Resource) IOException(java.io.IOException) JarEntryFile(org.eclipse.jdt.internal.core.JarEntryFile) TextFile(org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile) File(java.io.File) JarEntryFile(org.eclipse.jdt.internal.core.JarEntryFile) IFile(org.eclipse.core.resources.IFile) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot) Test(org.junit.Test) AbstractWorkbenchTest(org.eclipse.xtext.ui.testing.AbstractWorkbenchTest)

Example 3 with XtextReadonlyEditorInput

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();
    }
}
Also used : XtextReadonlyEditorInput(org.eclipse.xtext.ui.editor.XtextReadonlyEditorInput) IPackageFragment(org.eclipse.jdt.core.IPackageFragment) WrappedException(org.eclipse.emf.common.util.WrappedException) IJavaProject(org.eclipse.jdt.core.IJavaProject) IFile(org.eclipse.core.resources.IFile) TextFile(org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile) JarEntryFile(org.eclipse.jdt.internal.core.JarEntryFile) TextFile(org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile) File(java.io.File) JarEntryFile(org.eclipse.jdt.internal.core.JarEntryFile) IFile(org.eclipse.core.resources.IFile) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot) Test(org.junit.Test) AbstractWorkbenchTest(org.eclipse.xtext.ui.testing.AbstractWorkbenchTest)

Example 4 with XtextReadonlyEditorInput

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();
    }
}
Also used : XtextReadonlyEditorInput(org.eclipse.xtext.ui.editor.XtextReadonlyEditorInput) IPackageFragment(org.eclipse.jdt.core.IPackageFragment) WrappedException(org.eclipse.emf.common.util.WrappedException) IJavaProject(org.eclipse.jdt.core.IJavaProject) JarEntryFile(org.eclipse.jdt.internal.core.JarEntryFile) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot) Test(org.junit.Test) AbstractWorkbenchTest(org.eclipse.xtext.ui.testing.AbstractWorkbenchTest)

Example 5 with XtextReadonlyEditorInput

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
    }
}
Also used : XtextReadonlyEditorInput(org.eclipse.xtext.ui.editor.XtextReadonlyEditorInput) IPackageFragment(org.eclipse.jdt.core.IPackageFragment) IJavaProject(org.eclipse.jdt.core.IJavaProject) IFile(org.eclipse.core.resources.IFile) TextFile(org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile) NonJavaResource(org.eclipse.jdt.internal.core.NonJavaResource) IResource(org.eclipse.core.resources.IResource) Resource(org.eclipse.emf.ecore.resource.Resource) IOException(java.io.IOException) JarEntryFile(org.eclipse.jdt.internal.core.JarEntryFile) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot) Test(org.junit.Test) AbstractWorkbenchTest(org.eclipse.xtext.ui.testing.AbstractWorkbenchTest)

Aggregations

XtextReadonlyEditorInput (org.eclipse.xtext.ui.editor.XtextReadonlyEditorInput)9 IJavaProject (org.eclipse.jdt.core.IJavaProject)7 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)7 IPackageFragmentRoot (org.eclipse.jdt.core.IPackageFragmentRoot)7 AbstractWorkbenchTest (org.eclipse.xtext.ui.testing.AbstractWorkbenchTest)7 Test (org.junit.Test)7 JarEntryFile (org.eclipse.jdt.internal.core.JarEntryFile)6 IFile (org.eclipse.core.resources.IFile)5 WrappedException (org.eclipse.emf.common.util.WrappedException)5 TextFile (org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile)5 NonJavaResource (org.eclipse.jdt.internal.core.NonJavaResource)4 File (java.io.File)3 IResource (org.eclipse.core.resources.IResource)3 Resource (org.eclipse.emf.ecore.resource.Resource)3 IOException (java.io.IOException)2 IEditorPart (org.eclipse.ui.IEditorPart)2 IModelLocation (com.avaloq.tools.ddk.check.runtime.configuration.IModelLocation)1 IFolder (org.eclipse.core.resources.IFolder)1 EObject (org.eclipse.emf.ecore.EObject)1 IEditorInput (org.eclipse.ui.IEditorInput)1