Update of /cvsroot/e-p-i-c/org.epic.perleditor/src/org/epic/perleditor/actions
In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv5898/src/org/epic/perleditor/actions
Modified Files:
OpenDeclarationAction.java
Log Message:
Updated the algorithm for finding modules to be smarter about the current working directory entry (.) in the @INC path. If the current source file is a Perl script, this @INC entry will now be interpreted as the script's parent directory, as is the case during compilation.
Index: OpenDeclarationAction.java
===================================================================
RCS file: /cvsroot/e-p-i-c/org.epic.perleditor/src/org/epic/perleditor/actions/OpenDeclarationAction.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- OpenDeclarationAction.java 25 Jun 2006 16:17:24 -0000 1.3
+++ OpenDeclarationAction.java 12 Jul 2006 19:15:57 -0000 1.4
@@ -112,7 +112,9 @@
}
else messageBox(
"Module file not found",
- "Could not locate module file for prefix " + modulePrefix);
+ "Could not locate module file for prefix " + modulePrefix + "\n" +
+ "Check Perl Include Path in Project Properties."
+ );
}
else
{
@@ -141,7 +143,8 @@
messageBox(
"Declaration not found",
- "Could not locate declaration for \"" + subName + "\"");
+ "Could not locate declaration for \"" + subName + "\".\n" +
+ "Check Perl Include Path in Project Properties.");
}
private void messageBox(String title, String message)
@@ -166,7 +169,9 @@
for (Iterator i = dirs.iterator(); i.hasNext();)
{
- File f = new File((File) i.next(), modulePath);
+ File dir = (File) i.next();
+ if (".".equals(dir.getName())) dir = getCurrentDir();
+ File f = new File(dir, modulePath);
if (f.exists() && f.isFile()) return f;
}
return null;
@@ -205,6 +210,27 @@
}
/**
+ * @return the script's parent directory, if the action is executing
+ * on a .pl script (to simulate the @INC entry used when actually
+ * executing or compiling the script); '.' otherwise
+ */
+ private File getCurrentDir()
+ {
+ IEditorInput input = getEditor().getEditorInput();
+ if (!(input instanceof IFileEditorInput)) return new File(".");
+
+ IPath scriptFilePath = ((IFileEditorInput) input).getFile().getLocation();
+ if (scriptFilePath == null) return new File(".");
+
+ String ext = scriptFilePath.getFileExtension();
+ if (ext == null || !ext.toLowerCase().equals("pm")) // not a module = script
+ {
+ return scriptFilePath.toFile().getParentFile();
+ }
+ else return new File(".");
+ }
+
+ /**
* @return project with the edited source file from which
* OpenDeclaration was invoked
*/
|