Parser detects wrong include files now
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / actions / PHPOpenIncludeEditorAction.java
index fdb8907..12aa5c6 100644 (file)
@@ -4,10 +4,11 @@
  * the Common Public License v1.0 which accompanies this distribution, and is
  * available at http://www.eclipse.org/legal/cpl-v10.html
  * 
- * Contributors: Klaus Hartlage - www.eclipseproject.de
+ * Contributors: www.phpeclipse.de
  ******************************************************************************/
 package net.sourceforge.phpeclipse.actions;
 
+import java.io.File;
 import java.util.List;
 
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
@@ -71,10 +72,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 +123,7 @@ public class PHPOpenIncludeEditorAction extends ActionDelegate implements IEdito
             return;
           }
         } catch (Exception e) {
-// ignore
+          // ignore
         }
 
         try {
@@ -113,9 +131,10 @@ public class PHPOpenIncludeEditorAction extends ActionDelegate implements IEdito
           IdentifierIndexManager indexManager = PHPeclipsePlugin.getDefault().getIndexManager(fProject);
           //            filename = StringUtil.replaceRegExChars(filename);
           List list = indexManager.getFileList(filename);
-          if (list != null && list.size() > 0) {
-            String workspaceLocation = PHPeclipsePlugin.getWorkspace().getRoot().getLocation().toString();
-
+          if (list != null && list.size() > 0) { 
+            //String workspaceLocation = PHPeclipsePlugin.getWorkspace().getRoot().getLocation().toString();
+            String workspaceLocation = fProject.getLocation().toString()+File.separatorChar;
+            
             ListSelectionDialog listSelectionDialog = new ListSelectionDialog(PHPeclipsePlugin.getDefault().getWorkbench()
                 .getActiveWorkbenchWindow().getShell(), list, new ListContentProvider(), new LabelProvider(),
                 "Select the includes to open.");