improved include detection
authorkhartlage <khartlage>
Fri, 11 Jun 2004 17:58:43 +0000 (17:58 +0000)
committerkhartlage <khartlage>
Fri, 11 Jun 2004 17:58:43 +0000 (17:58 +0000)
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPOpenIncludeEditorAction.java

index fdb8907..77173a7 100644 (file)
@@ -71,10 +71,27 @@ public class PHPOpenIncludeEditorAction extends ActionDelegate implements IEdito
     return editorInput.getFile().getParent();
   }
   private IFile getIncludeFile(IProject project, IFileEditorInput editorInput, String relativeFilename) {
-    //         IContainer container = getWorkingLocation(editorInput);
-    //         String fullPath = project.getLocation().toString();
-    Path path = new Path(relativeFilename);
-    IFile file = project.getFile(path);
+    IContainer container = getWorkingLocation(editorInput);
+    String fullPath = project.getLocation().toString();
+    IFile file = null;
+    if (relativeFilename.startsWith("../")) {
+      Path path = new Path(relativeFilename);
+         file = container.getFile(path);
+         return file;
+    }
+    int index = relativeFilename.lastIndexOf('/');
+    
+    if (index >= 0) {
+      Path path = new Path(relativeFilename);
+      file = project.getFile(path);
+      if (file.exists()) {
+           return file;
+         }
+    } 
+    
+       Path path = new Path(relativeFilename);
+       file = container.getFile(path);
+    
     return file;
   }
 
@@ -105,7 +122,7 @@ public class PHPOpenIncludeEditorAction extends ActionDelegate implements IEdito
             return;
           }
         } catch (Exception e) {
-// ignore
+          // ignore
         }
 
         try {