Moved the project.index file to eclipse/workspace/.metadata/.plugins/org.eclipse...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / builder / IdentifierIndexManager.java
index cd647e3..7b7954c 100644 (file)
@@ -41,7 +41,7 @@ public class IdentifierIndexManager {
     private int fToken;
 
     public LineCreator() {
-      fScanner = new Scanner(true, false, false, false, true, null, null, true /*taskCaseSensitive*/);
+      fScanner = new Scanner(true, false, false, false, true, null, null, true /* taskCaseSensitive */);
     }
 
     /**
@@ -303,7 +303,7 @@ public class IdentifierIndexManager {
                   ident = fScanner.getCurrentStringLiteralSource();
                   addIdentifierInformation('d', ident, buf, phpdocOffset, phpdocLength);
                   getNextToken();
-                } 
+                }
               }
             }
           } else {
@@ -425,106 +425,112 @@ public class IdentifierIndexManager {
     boolean tokenExists = false;
     tokenizer = new StringTokenizer(line, "\t");
     // first token contains the filename:
-    if (tokenizer.hasMoreTokens()) {
-      phpFileName = tokenizer.nextToken();
-      //System.out.println(token);
-    } else {
-      return;
-    }
-    // all the other tokens are identifiers:
-    while (tokenizer.hasMoreTokens()) {
-      token = tokenizer.nextToken();
-      //System.out.println(token);
-      switch (token.charAt(0)) {
-      case 'c':
-        // class name
-        identifier = token.substring(1);
-        classname = identifier;
-        phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.CLASS, phpFileName);
-        break;
-      case 'd':
-        // define
-        identifier = token.substring(1);
-        phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.DEFINE, phpFileName);
-        break;
-      case 'f':
-        // function name
-        identifier = token.substring(1);
-        phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.FUNCTION, phpFileName);
-        break;
-      case 'g':
-        // global variable
-        identifier = token.substring(1);
-        phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.GLOBAL_VARIABLE, phpFileName);
-        break;
-      case 'k':
-        // constructor function name
-        identifier = token.substring(1);
-        phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.CONSTRUCTOR, phpFileName);
-        break;
-      case 'm':
-        //method inside a class
-        identifier = token.substring(1);
-        phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.METHOD, phpFileName, classname);
-        break;
-      case 'v':
-        // variable inside a class
-        identifier = token.substring(1);
-        phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.VARIABLE, phpFileName, classname);
-        break;
-      case 'o':
-        // offset information
-        identifier = null;
-        if (phpIdentifier != null) {
-          offset = token.substring(1);
-          phpIdentifier.setOffset(Integer.parseInt(offset));
-        }
-        break;
-      case 'p':
-        // PHPdoc offset information
-        identifier = null;
-        if (phpIdentifier != null) {
-          offset = token.substring(1);
-          phpIdentifier.setPHPDocOffset(Integer.parseInt(offset));
-        }
-        break;
-      case 'l':
-        // PHPdoc length information
-        identifier = null;
-        if (phpIdentifier != null) {
-          offset = token.substring(1);
-          phpIdentifier.setPHPDocLength(Integer.parseInt(offset));
-        }
-        break;
-      default:
-        PHPeclipsePlugin.log(IStatus.ERROR, "Unknown token character in IdentifierIndexManager: " + token.charAt(0));
-        identifier = null;
-        phpIdentifier = null;
-        classname = null;
+    try {
+      if (tokenizer.hasMoreTokens()) {
+        phpFileName = tokenizer.nextToken();
+        //System.out.println(token);
+      } else {
+        return;
       }
-      if (identifier != null && phpIdentifier != null) {
-        tokenExists = true;
-        ArrayList list = (ArrayList) fIndentifierMap.get(identifier);
-        if (list == null) {
-          list = new ArrayList();
-          list.add(phpIdentifier);
-          fIndentifierMap.put(identifier, list);
-        } else {
-          boolean flag = false;
-          for (int i = 0; i < list.size(); i++) {
-            if (list.get(i).equals(phpIdentifier)) {
-              flag = true;
-              break;
-            }
+      // all the other tokens are identifiers:
+      while (tokenizer.hasMoreTokens()) {
+        token = tokenizer.nextToken();
+        //System.out.println(token);
+        switch (token.charAt(0)) {
+        case 'c':
+          // class name
+          identifier = token.substring(1);
+          classname = identifier;
+          phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.CLASS, phpFileName);
+          break;
+        case 'd':
+          // define
+          identifier = token.substring(1);
+          phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.DEFINE, phpFileName);
+          break;
+        case 'f':
+          // function name
+          identifier = token.substring(1);
+          phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.FUNCTION, phpFileName);
+          break;
+        case 'g':
+          // global variable
+          identifier = token.substring(1);
+          phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.GLOBAL_VARIABLE, phpFileName);
+          break;
+        case 'k':
+          // constructor function name
+          identifier = token.substring(1);
+          phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.CONSTRUCTOR, phpFileName);
+          break;
+        case 'm':
+          //method inside a class
+          identifier = token.substring(1);
+          phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.METHOD, phpFileName, classname);
+          break;
+        case 'v':
+          // variable inside a class
+          identifier = token.substring(1);
+          phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.VARIABLE, phpFileName, classname);
+          break;
+        case 'o':
+          // offset information
+          identifier = null;
+          if (phpIdentifier != null) {
+            offset = token.substring(1);
+            phpIdentifier.setOffset(Integer.parseInt(offset));
+          }
+          break;
+        case 'p':
+          // PHPdoc offset information
+          identifier = null;
+          if (phpIdentifier != null) {
+            offset = token.substring(1);
+            phpIdentifier.setPHPDocOffset(Integer.parseInt(offset));
+          }
+          break;
+        case 'l':
+          // PHPdoc length information
+          identifier = null;
+          if (phpIdentifier != null) {
+            offset = token.substring(1);
+            phpIdentifier.setPHPDocLength(Integer.parseInt(offset));
           }
-          if (flag == false) {
+          break;
+        default:
+          PHPeclipsePlugin.log(IStatus.ERROR, "Unknown token character in IdentifierIndexManager: " + token.charAt(0));
+          identifier = null;
+          phpIdentifier = null;
+          classname = null;
+        }
+        if (identifier != null && phpIdentifier != null) {
+          tokenExists = true;
+          ArrayList list = (ArrayList) fIndentifierMap.get(identifier);
+          if (list == null) {
+            list = new ArrayList();
             list.add(phpIdentifier);
+            fIndentifierMap.put(identifier, list);
+          } else {
+            boolean flag = false;
+            for (int i = 0; i < list.size(); i++) {
+              if (list.get(i).equals(phpIdentifier)) {
+                flag = true;
+                break;
+              }
+            }
+            if (flag == false) {
+              list.add(phpIdentifier);
+            }
           }
         }
       }
+      fFileMap.put(phpFileName, line);
+    } catch (Throwable e) {
+      // write to workspace/.metadata/.log file
+      PHPeclipsePlugin.log(e);
     }
     //    if (tokenExists) {
-    fFileMap.put(phpFileName, line);
+    
     //    }
   }