aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorszarnekow2009-02-12 16:10:14 (EST)
committersefftinge2009-02-12 16:10:14 (EST)
commita36bd663673f670998eb5870505f67905c89e7d1 (patch)
tree0bb279df3c43b5788e9b3f92c04d9f1731a32bda
parentddbf823889cd236b30a9b76631492d8c2bae1984 (diff)
downloadorg.eclipse.xtext-a36bd663673f670998eb5870505f67905c89e7d1.zip
org.eclipse.xtext-a36bd663673f670998eb5870505f67905c89e7d1.tar.gz
org.eclipse.xtext-a36bd663673f670998eb5870505f67905c89e7d1.tar.bz2
Workaround for jdt bug #264776
-rw-r--r--plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/util/JdtClasspathUriResolver.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/util/JdtClasspathUriResolver.java b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/util/JdtClasspathUriResolver.java
index f8cbb27..9ab0140 100644
--- a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/util/JdtClasspathUriResolver.java
+++ b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/util/JdtClasspathUriResolver.java
@@ -7,6 +7,7 @@
*******************************************************************************/
package org.eclipse.xtext.ui.core.util;
+import java.io.File;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -14,6 +15,7 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.emf.common.util.URI;
import org.eclipse.jdt.core.IJavaElement;
@@ -73,23 +75,36 @@ public class JdtClasspathUriResolver implements IClasspathUriResolver {
else {
// folder
IFolder rootFolder = null;
+ // path as fallback necessary due to jdt bug #264776
+ IPath path = null;
if (correspondingResource instanceof IFolder) {
rootFolder = (IFolder) correspondingResource;
}
else if (packageFragmentRoot instanceof ExternalPackageFragmentRoot) {
IResource resource = ((ExternalPackageFragmentRoot) packageFragmentRoot).resource();
+ path = ((ExternalPackageFragmentRoot) packageFragmentRoot).getPath();
if (resource instanceof IFolder) {
rootFolder = (IFolder) resource;
}
}
if (rootFolder != null) {
IResource modelFile = rootFolder.findMember(projectRelativePath);
+ // modelFile.exists() is sometimes false, even if it exists
if (modelFile != null && modelFile.exists() && modelFile instanceof IFile) {
URI platformResourceUri = URI.createPlatformResourceURI(modelFile.getFullPath().toString(),
true);
return platformResourceUri;
}
}
+ // fallback for jdt bug #264776
+ if (path != null) {
+ path = path.append(fullPath);
+ File f = path.toFile();
+ if (f.exists() && f.isFile()) {
+ URI fileUri = URI.createFileURI(f.getAbsolutePath());
+ return fileUri;
+ }
+ }
}
}
}