added textArea as a temporary report area. will be replaced by a tree at some point...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / builder / IdentifierIndexManager.java
index 056edbe..532a301 100644 (file)
@@ -32,7 +32,7 @@ public class IdentifierIndexManager {
     private Scanner fScanner;
     private int fToken;
     public LineCreator() {
-      fScanner = new Scanner(true, false);
+      fScanner = new Scanner(true, false, false, false, true, null, null);
     }
     /**
      * Add the information of the current identifier to the line
@@ -79,6 +79,7 @@ public class IdentifierIndexManager {
         return;
       } catch (InvalidInputException e) {
         // ignore errors
+        e.printStackTrace();
       }
       fToken = TokenNameERROR;
     }
@@ -172,8 +173,7 @@ public class IdentifierIndexManager {
                 }
               }
             }
-          } else if ((fToken == TokenNameLBRACE)
-              || (fToken == TokenNameDOLLAR_LBRACE)) {
+          } else if (fToken == TokenNameLBRACE) {
             getNextToken();
             counter++;
           } else if (fToken == TokenNameRBRACE) {
@@ -202,7 +202,7 @@ public class IdentifierIndexManager {
       fToken = TokenNameEOF;
       getNextToken();
       try {
-        while (fToken != TokenNameEOF && fToken != TokenNameERROR) {
+        while (fToken != TokenNameEOF) { // && fToken != TokenNameERROR) {
           phpdocOffset = -1;
           if (fToken == TokenNameCOMMENT_PHPDOC) {
             phpdocOffset = fScanner.getCurrentTokenStartPosition();
@@ -308,13 +308,16 @@ public class IdentifierIndexManager {
     }
     return true;
   }
+  public LineCreator createLineCreator() {
+    return new LineCreator();
+  }
   /**
    * Add the information for a given IFile resource
    *  
    */
   public void addFile(IFile fileToParse) {
     //    InputStream iStream;
-    LineCreator lineCreator = new LineCreator();
+    LineCreator lineCreator = createLineCreator();
     try {
       //      iStream = fileToParse.getContents();
       //
@@ -327,32 +330,41 @@ public class IdentifierIndexManager {
       //      } catch (IOException e) {
       //        return;
       //      }
-      InputStream stream = null;
+      addInputStream(new BufferedInputStream(fileToParse.getContents()), fileToParse.getFullPath().toString(), lineCreator);
+    } catch (CoreException e1) {
+      // TODO Auto-generated catch block
+      e1.printStackTrace();
+    }
+  }
+  /**
+   * @param fileToParse
+   * @param lineCreator
+   * @throws CoreException
+   */
+  public void addInputStream(InputStream stream, String filePath, LineCreator lineCreator) throws CoreException {
+//    InputStream stream;
+    try {
+     // stream = new BufferedInputStream(fileToParse.getContents());
+      StringBuffer lineBuffer = new StringBuffer();
+      lineBuffer.append(filePath);
+      int lineLength = lineBuffer.length();
+      // lineCreator.parseIdentifiers(buf.toString().toCharArray(),
+      // lineBuffer);
+      lineCreator.parseIdentifiers(Util.getInputStreamAsCharArray(stream, -1,
+          null), lineBuffer);
+      if (lineLength != lineBuffer.length()) {
+        addLine(lineBuffer.toString());
+      }
+    } catch (IOException e) {
+      e.printStackTrace();
+    } finally {
       try {
-        stream = new BufferedInputStream(fileToParse.getContents());
-        StringBuffer lineBuffer = new StringBuffer();
-        lineBuffer.append(fileToParse.getFullPath().toString());
-        int lineLength = lineBuffer.length();
-        // lineCreator.parseIdentifiers(buf.toString().toCharArray(),
-        // lineBuffer);
-        lineCreator.parseIdentifiers(Util.getInputStreamAsCharArray(stream, -1,
-            null), lineBuffer);
-        if (lineLength != lineBuffer.length()) {
-          addLine(lineBuffer.toString());
+        if (stream != null) {
+          stream.close();
         }
       } catch (IOException e) {
-        return;
-      } finally {
-        try {
-          if (stream != null) {
-            stream.close();
-          }
-        } catch (IOException e) {
-        }
       }
-    } catch (CoreException e1) {
-      // TODO Auto-generated catch block
-      e1.printStackTrace();
     }
   }
   /**