Eliminated unused classes
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / builder / IdentifierIndexManager.java
index fbabccb..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;
     }
@@ -201,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();
@@ -307,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();
       //
@@ -326,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();
     }
   }
   /**