[105079] hyperlink navigation tries to open folders in editors
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/hyperlink/JSPJavaHyperlinkDetector.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/hyperlink/JSPJavaHyperlinkDetector.java
index 088b648..d89caf0 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/hyperlink/JSPJavaHyperlinkDetector.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/hyperlink/JSPJavaHyperlinkDetector.java
@@ -80,7 +80,7 @@
}
}
- if (range != null && file != null && file.exists()) {
+ if (range != null && file != null) {
jspOffset = jspTranslation.getJspOffset(range.getOffset());
if (jspOffset >= 0) {
link = new WorkspaceFileHyperlink(region, file, new Region(jspOffset, range.getLength()));
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/hyperlink/TaglibHyperlinkDetector.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/hyperlink/TaglibHyperlinkDetector.java
index bd39186..ae634a7 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/hyperlink/TaglibHyperlinkDetector.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/hyperlink/TaglibHyperlinkDetector.java
@@ -141,27 +141,18 @@
}
/**
- * Returns an IFile from the given uri if possible, null if cannot find
- * file from uri.
+ * Returns an IFile from the given uri.
*
* @param fileString
- * file system or workspace-relative path
- * @return returns IFile if fileString exists in the workspace
+ * workspace-relative path to an existing file in the workspace
+ * @return returns existing IFile
*/
private IFile getFile(String fileString) {
- IFile file = null;
-
- if (fileString != null) {
- IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(fileString));
- for (int i = 0; i < files.length && file == null; i++)
- if (files[i].exists())
- file = files[i];
- }
- if (file == null) {
- file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(fileString));
- }
-
- return file;
+ /*
+ * Note at this point, fileString is already guaranteed to be pointing
+ * to an existing file in the workspace, so we can just call getFile.
+ */
+ return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(fileString));
}
/**
@@ -183,7 +174,7 @@
// try to locate the file in the workspace
IFile file = getFile(uriString);
- if (file != null && file.exists()) {
+ if (file != null) {
// this is a WorkspaceFileHyperlink since file exists in
// workspace
link = new WorkspaceFileHyperlink(hyperlinkRegion, file);
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/hyperlink/XMLHyperlinkDetector.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/hyperlink/XMLHyperlinkDetector.java
index fb4765c..c863d0b 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/hyperlink/XMLHyperlinkDetector.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/hyperlink/XMLHyperlinkDetector.java
@@ -74,7 +74,7 @@
if (systemFile != null) {
String systemPath = systemFile.getPath();
IFile file = getFile(systemPath);
- if (file != null && file.exists()) {
+ if (file != null) {
// this is a WorkspaceFileHyperlink since file exists in
// workspace
link = new WorkspaceFileHyperlink(hyperlinkRegion, file);
@@ -481,7 +481,7 @@
else {
File file = getFileFromUriString(uriString);
if (file != null)
- isValid = file.exists();
+ isValid = file.isFile();
}
return isValid;
}
diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/hyperlink/XMLHyperlinkDetector.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/hyperlink/XMLHyperlinkDetector.java
index 54f9baa..a772010 100644
--- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/hyperlink/XMLHyperlinkDetector.java
+++ b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/hyperlink/XMLHyperlinkDetector.java
@@ -74,7 +74,7 @@
if (systemFile != null) {
String systemPath = systemFile.getPath();
IFile file = getFile(systemPath);
- if (file != null && file.exists()) {
+ if (file != null) {
// this is a WorkspaceFileHyperlink since file exists in
// workspace
link = new WorkspaceFileHyperlink(hyperlinkRegion, file);
@@ -481,7 +481,7 @@
else {
File file = getFileFromUriString(uriString);
if (file != null)
- isValid = file.exists();
+ isValid = file.isFile();
}
return isValid;
}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java
index cb48441..469044c 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java
@@ -74,7 +74,7 @@
if (systemFile != null) {
String systemPath = systemFile.getPath();
IFile file = getFile(systemPath);
- if (file != null && file.exists()) {
+ if (file != null) {
// this is a WorkspaceFileHyperlink since file exists in
// workspace
link = new WorkspaceFileHyperlink(hyperlinkRegion, file);
@@ -481,7 +481,7 @@
else {
File file = getFileFromUriString(uriString);
if (file != null)
- isValid = file.exists();
+ isValid = file.isFile();
}
return isValid;
}