* Added browser like links (Ctrl+Mouseclick on identifier; same as F3 shortcut)
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / actions / IncludesScanner.java
index 439f302..a556aef 100644 (file)
@@ -6,6 +6,7 @@ import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import net.sourceforge.phpdt.core.compiler.ITerminalSymbols;
 import net.sourceforge.phpdt.core.compiler.InvalidInputException;
@@ -22,13 +23,13 @@ import org.eclipse.ui.IFileEditorInput;
 
 
 public class IncludesScanner implements ITerminalSymbols {
-  private final PHPOpenAllIncludesEditorAction fLineCreator;
+//  private final PHPOpenAllIncludesEditorAction fOpenAllIncludesAction;
   private IProject fProject;
   private IFileEditorInput fEditorInput;
-  HashSet fSet;
-  public IncludesScanner(PHPOpenAllIncludesEditorAction action, IProject project, IFileEditorInput editorInput) {
+  private HashSet fSet;
+  public IncludesScanner(IProject project, IFileEditorInput editorInput) {
     fProject = project;
-    this.fLineCreator = action;
+//    fOpenAllIncludesAction = action;
     fEditorInput = editorInput;
     fSet = new HashSet();
   }
@@ -40,7 +41,7 @@ public class IncludesScanner implements ITerminalSymbols {
 
     try {
       if (fileToParse.exists()) {
-        addInputStream(new BufferedInputStream(fileToParse.getContents()), fileToParse.getFullPath().toString());
+        addInputStream(new BufferedInputStream(fileToParse.getContents()), fileToParse.getProjectRelativePath().toString());
       }
     } catch (CoreException e1) {
       e1.printStackTrace();
@@ -89,7 +90,7 @@ public class IncludesScanner implements ITerminalSymbols {
     String identifier;
     int counter = 0;
 
-    Scanner scanner = new Scanner(false, false, false, false, true, null, null);
+    Scanner scanner = new Scanner(false, false, false, false, true, null, null, true /*taskCaseSensitive*/);
     scanner.setSource(charArray);
     scanner.setPHPMode(false);
     int token = getNextToken(scanner);
@@ -118,8 +119,15 @@ public class IncludesScanner implements ITerminalSymbols {
      // e.printStackTrace();
     }
   }
+  
+  private IContainer getWorkingLocation(IFileEditorInput editorInput) {
+    if (editorInput == null || editorInput.getFile() == null) {
+      return null;
+    }
+    return editorInput.getFile().getParent();
+  }
   public IFile getIncludeFile(String relativeFilename) {
-    IContainer container = this.fLineCreator.getWorkingLocation(fEditorInput);
+    IContainer container = getWorkingLocation(fEditorInput);
     String fullPath = fProject.getLocation().toString();
     IFile file = null;
     if (relativeFilename.startsWith("../")) {
@@ -151,4 +159,10 @@ public class IncludesScanner implements ITerminalSymbols {
     return list;
   }
 
+  /**
+   * @return Returns the set.
+   */
+  public Set getSet() {
+    return fSet;
+  }
 }
\ No newline at end of file