misc changes
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / builder / IdentifierIndexManager.java
index 6772af2..262d596 100644 (file)
@@ -1,4 +1,5 @@
 package net.sourceforge.phpeclipse.builder;
+
 import java.io.BufferedInputStream;
 import java.io.BufferedReader;
 import java.io.FileNotFoundException;
@@ -28,6 +29,7 @@ import net.sourceforge.phpeclipse.obfuscator.PHPIdentifier;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IStatus;
+
 /**
  * Manages the identifer index information for a specific project
  *  
@@ -35,27 +37,29 @@ import org.eclipse.core.runtime.IStatus;
 public class IdentifierIndexManager {
   public class LineCreator implements ITerminalSymbols {
     private Scanner fScanner;
+
     private int fToken;
+
     public LineCreator() {
       fScanner = new Scanner(true, false, false, false, true, null, null);
     }
+
     /**
      * Add the information of the current identifier to the line
      * 
      * @param typeOfIdentifier
-     *            the type of the identifier ('c'lass, 'd'efine, 'f'unction,
-     *            'm'ethod(class), 'v'ariable(class) 'g'lobal variable)
+     *          the type of the identifier ('c'lass, 'd'efine, 'f'unction, 'm'ethod(class), 'v'ariable(class) 'g'lobal variable)
      * @param identifier
-     *            current identifier
+     *          current identifier
      * @param line
-     *            Buffer for the current index line
+     *          Buffer for the current index line
      * @param phpdocOffset
-     *            the offset of the PHPdoc comment if available
+     *          the offset of the PHPdoc comment if available
      * @param phpdocLength
-     *            the length of the PHPdoc comment if available
+     *          the length of the PHPdoc comment if available
      */
-    private void addIdentifierInformation(char typeOfIdentifier,
-        char[] identifier, StringBuffer line, int phpdocOffset, int phpdocLength) {
+    private void addIdentifierInformation(char typeOfIdentifier, char[] identifier, StringBuffer line, int phpdocOffset,
+        int phpdocLength) {
       line.append('\t');
       line.append(typeOfIdentifier);
       line.append(identifier);
@@ -68,6 +72,23 @@ public class IdentifierIndexManager {
         line.append(phpdocLength);
       }
     }
+    
+    private void addClassVariableInformation(char typeOfIdentifier, char[] identifier, StringBuffer line, int phpdocOffset,
+        int phpdocLength) {
+      line.append('\t');
+      line.append(typeOfIdentifier);
+      line.append(identifier);
+      line.append("\to"); // Offset
+      // we don't store the '$' in the index for class variables:
+      line.append(fScanner.getCurrentTokenStartPosition()+1);
+      if (phpdocOffset >= 0) {
+        line.append("\tp"); // phpdoc offset
+        line.append(phpdocOffset);
+        line.append("\tl"); // phpdoc length
+        line.append(phpdocLength);
+      }
+    }
+
     /**
      * Get the next token from input
      */
@@ -77,19 +98,18 @@ public class IdentifierIndexManager {
         if (Scanner.DEBUG) {
           int currentEndPosition = fScanner.getCurrentTokenEndPosition();
           int currentStartPosition = fScanner.getCurrentTokenStartPosition();
-          System.out.print(currentStartPosition + "," + currentEndPosition
-              + ": ");
+          System.out.print(currentStartPosition + "," + currentEndPosition + ": ");
           System.out.println(fScanner.toStringAction(fToken));
         }
         return;
       } catch (InvalidInputException e) {
         // ignore errors
-//        e.printStackTrace();
+        //        e.printStackTrace();
       }
       fToken = TokenNameERROR;
     }
-    private void parseDeclarations(char[] parent, StringBuffer buf,
-        boolean goBack) {
+
+    private void parseDeclarations(char[] parent, StringBuffer buf, boolean goBack) {
       char[] ident;
       char[] classVariable;
       int counter = 0;
@@ -100,22 +120,23 @@ public class IdentifierIndexManager {
           phpdocOffset = -1;
           if (fToken == TokenNameCOMMENT_PHPDOC) {
             phpdocOffset = fScanner.getCurrentTokenStartPosition();
-            phpdocLength = fScanner.getCurrentTokenEndPosition()
-                - fScanner.getCurrentTokenStartPosition() + 1;
+            phpdocLength = fScanner.getCurrentTokenEndPosition() - fScanner.getCurrentTokenStartPosition() + 1;
             getNextToken();
             if (fToken == TokenNameEOF || fToken == TokenNameERROR) {
               break;
             }
           }
-          if (fToken == TokenNamevar || fToken == TokenNamepublic
+          if (fToken == TokenNamevar || fToken == TokenNamestatic || fToken == TokenNamefinal || fToken == TokenNamepublic
               || fToken == TokenNameprotected || fToken == TokenNameprivate) {
-            getNextToken();
+            while (fToken == TokenNamevar || fToken == TokenNamestatic || fToken == TokenNamefinal || fToken == TokenNamepublic
+                || fToken == TokenNameprotected || fToken == TokenNameprivate) {
+              getNextToken();
+            }  
             if (fToken == TokenNameVariable) {
               ident = fScanner.getCurrentIdentifierSource();
               classVariable = new char[ident.length - 1];
               System.arraycopy(ident, 1, classVariable, 0, ident.length - 1);
-              addIdentifierInformation('v', classVariable, buf, phpdocOffset,
-                  phpdocLength);
+              addClassVariableInformation('v', classVariable, buf, phpdocOffset, phpdocLength);
               getNextToken();
             }
           } else if (fToken == TokenNamefunction) {
@@ -127,33 +148,28 @@ public class IdentifierIndexManager {
               ident = fScanner.getCurrentIdentifierSource();
               if (parent != null && equalCharArrays(parent, ident)) {
                 // constructor function
-                addIdentifierInformation('k', ident, buf, phpdocOffset,
-                    phpdocLength);
+                addIdentifierInformation('k', ident, buf, phpdocOffset, phpdocLength);
               } else {
                 if (parent != null) {
                   // class method function
-                  addIdentifierInformation('m', ident, buf, phpdocOffset,
-                      phpdocLength);
+                  addIdentifierInformation('m', ident, buf, phpdocOffset, phpdocLength);
                 } else {
                   // nested function ?!
-                  addIdentifierInformation('f', ident, buf, phpdocOffset,
-                      phpdocLength);
+                  addIdentifierInformation('f', ident, buf, phpdocOffset, phpdocLength);
                 }
               }
               getNextToken();
               parseDeclarations(null, buf, true);
             }
-          } else if (fToken == TokenNameclass) {
+          } else if (fToken == TokenNameclass || fToken == TokenNameinterface) {
             getNextToken();
             if (fToken == TokenNameIdentifier) {
               ident = fScanner.getCurrentIdentifierSource();
-              addIdentifierInformation('c', ident, buf, phpdocOffset,
-                  phpdocLength);
+              addIdentifierInformation('c', ident, buf, phpdocOffset, phpdocLength);
               getNextToken();
               //skip tokens for classname, extends and others until we have
               // the opening '{'
-              while (fToken != TokenNameLBRACE && fToken != TokenNameEOF
-                  && fToken != TokenNameERROR) {
+              while (fToken != TokenNameLBRACE && fToken != TokenNameEOF && fToken != TokenNameERROR) {
                 getNextToken();
               }
               parseDeclarations(ident, buf, true);
@@ -161,34 +177,25 @@ public class IdentifierIndexManager {
           } else if (fToken == TokenNameIdentifier) {
             ident = fScanner.getCurrentIdentifierSource();
             getNextToken();
-            if (ident.length==6 && 
-                ident[0]=='d' && 
-                ident[1]=='e' && 
-                ident[2]=='f' && 
-                ident[3]=='i' && 
-                ident[4]=='n' && 
-                ident[5]=='e') {
+            if (ident.length == 6 && ident[0] == 'd' && ident[1] == 'e' && ident[2] == 'f' && ident[3] == 'i' && ident[4] == 'n'
+                && ident[5] == 'e') {
               if (fToken == TokenNameLPAREN) {
                 getNextToken();
                 if (fToken == TokenNameStringDoubleQuote) {
                   ident = fScanner.getCurrentStringLiteralSource();
-                  addIdentifierInformation('d', ident, buf, phpdocOffset,
-                      phpdocLength);
+                  addIdentifierInformation('d', ident, buf, phpdocOffset, phpdocLength);
                   getNextToken();
                 }
               }
             }
           } else if (fToken == TokenNameglobal) {
             // global variable
-            while (fToken != TokenNameEOF && fToken != TokenNameERROR && 
-                   fToken != TokenNameSEMICOLON &&
-                   fToken != TokenNameLBRACE &&
-                   fToken != TokenNameRBRACE ) {
-              getNextToken(); 
+            while (fToken != TokenNameEOF && fToken != TokenNameERROR && fToken != TokenNameSEMICOLON && fToken != TokenNameLBRACE
+                && fToken != TokenNameRBRACE) {
+              getNextToken();
               if (fToken == TokenNameVariable) {
                 ident = fScanner.getCurrentIdentifierSource();
-                addIdentifierInformation('g', ident, buf, phpdocOffset,
-                    phpdocLength);
+                addIdentifierInformation('g', ident, buf, phpdocOffset, phpdocLength);
               }
             }
           } else if (fToken == TokenNameLBRACE) {
@@ -209,6 +216,7 @@ public class IdentifierIndexManager {
         e.printStackTrace();
       }
     }
+
     synchronized public void parseIdentifiers(char[] charArray, StringBuffer buf) {
       char[] ident;
       String identifier;
@@ -224,8 +232,7 @@ public class IdentifierIndexManager {
           phpdocOffset = -1;
           if (fToken == TokenNameCOMMENT_PHPDOC) {
             phpdocOffset = fScanner.getCurrentTokenStartPosition();
-            phpdocLength = fScanner.getCurrentTokenEndPosition()
-                - fScanner.getCurrentTokenStartPosition() + 1;
+            phpdocLength = fScanner.getCurrentTokenEndPosition() - fScanner.getCurrentTokenStartPosition() + 1;
             getNextToken();
             if (fToken == TokenNameEOF || fToken == TokenNameERROR) {
               break;
@@ -238,22 +245,19 @@ public class IdentifierIndexManager {
             }
             if (fToken == TokenNameIdentifier) {
               ident = fScanner.getCurrentIdentifierSource();
-              addIdentifierInformation('f', ident, buf, phpdocOffset,
-                  phpdocLength);
+              addIdentifierInformation('f', ident, buf, phpdocOffset, phpdocLength);
               getNextToken();
               parseDeclarations(null, buf, true);
             }
-          } else if (fToken == TokenNameclass) {
+          } else if (fToken == TokenNameclass || fToken == TokenNameinterface) {
             getNextToken();
             if (fToken == TokenNameIdentifier) {
               ident = fScanner.getCurrentIdentifierSource();
-              addIdentifierInformation('c', ident, buf, phpdocOffset,
-                  phpdocLength);
+              addIdentifierInformation('c', ident, buf, phpdocOffset, phpdocLength);
               getNextToken();
               //skip fTokens for classname, extends and others until we have
               // the opening '{'
-              while (fToken != TokenNameLBRACE && fToken != TokenNameEOF
-                  && fToken != TokenNameERROR) {
+              while (fToken != TokenNameLBRACE && fToken != TokenNameEOF && fToken != TokenNameERROR) {
                 getNextToken();
               }
               parseDeclarations(ident, buf, true);
@@ -261,25 +265,18 @@ public class IdentifierIndexManager {
           } else if (fToken == TokenNameVariable) {
             // global variable
             ident = fScanner.getCurrentIdentifierSource();
-            addIdentifierInformation('g', ident, buf, phpdocOffset,
-                phpdocLength);
-            getNextToken(); 
+            addIdentifierInformation('g', ident, buf, phpdocOffset, phpdocLength);
+            getNextToken();
           } else if (fToken == TokenNameIdentifier) {
             ident = fScanner.getCurrentIdentifierSource();
             getNextToken();
-            if (ident.length==6 && 
-                ident[0]=='d' && 
-                ident[1]=='e' && 
-                ident[2]=='f' && 
-                ident[3]=='i' && 
-                ident[4]=='n' && 
-                ident[5]=='e') {
+            if (ident.length == 6 && ident[0] == 'd' && ident[1] == 'e' && ident[2] == 'f' && ident[3] == 'i' && ident[4] == 'n'
+                && ident[5] == 'e') {
               if (fToken == TokenNameLPAREN) {
                 getNextToken();
                 if (fToken == TokenNameStringDoubleQuote) {
                   ident = fScanner.getCurrentStringLiteralSource();
-                  addIdentifierInformation('d', ident, buf, phpdocOffset,
-                      phpdocLength);
+                  addIdentifierInformation('d', ident, buf, phpdocOffset, phpdocLength);
                   getNextToken();
                 }
               }
@@ -294,6 +291,7 @@ public class IdentifierIndexManager {
       }
     }
   }
+
   class StringComparator implements Comparator {
     public int compare(Object o1, Object o2) {
       String s1 = (String) o1;
@@ -301,19 +299,25 @@ public class IdentifierIndexManager {
       return s1.compareTo(s2);
       //       return s1.toUpperCase().compareTo(s2.toUpperCase());
     }
+
     public boolean equals(Object o) {
       String s = (String) o;
       return compare(this, o) == 0;
     }
   }
+
   private HashMap fFileMap;
+
   private String fFilename;
+
   private TreeMap fIndentifierMap;
+
   public IdentifierIndexManager(String filename) {
     fFilename = filename;
     initialize();
     readFile();
   }
+
   /**
    * Check if 2 char arrays are equal
    * 
@@ -332,9 +336,11 @@ public class IdentifierIndexManager {
     }
     return true;
   }
+
   public LineCreator createLineCreator() {
     return new LineCreator();
   }
+
   /**
    * Add the information for a given IFile resource
    *  
@@ -343,12 +349,14 @@ public class IdentifierIndexManager {
     //    InputStream iStream;
     LineCreator lineCreator = createLineCreator();
     try {
-      addInputStream(new BufferedInputStream(fileToParse.getContents()), fileToParse.getProjectRelativePath().toString(), lineCreator);
+      addInputStream(new BufferedInputStream(fileToParse.getContents()), fileToParse.getProjectRelativePath().toString(),
+          lineCreator);
     } catch (CoreException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
     }
   }
+
   /**
    * @param fileToParse
    * @param lineCreator
@@ -359,14 +367,13 @@ public class IdentifierIndexManager {
       StringBuffer lineBuffer = new StringBuffer();
       lineBuffer.append(filePath);
       int lineLength = lineBuffer.length();
-      lineCreator.parseIdentifiers(Util.getInputStreamAsCharArray(stream, -1,
-          null), lineBuffer);
-//      if (lineLength != lineBuffer.length()) {
-      // always add the file for Open Include Action  
+      lineCreator.parseIdentifiers(Util.getInputStreamAsCharArray(stream, -1, null), lineBuffer);
+      //      if (lineLength != lineBuffer.length()) {
+      // always add the file for Open Include Action
       addLine(lineBuffer.toString());
-//      }
-    }  catch (IOException e) {
-        e.printStackTrace();
+      //      }
+    } catch (IOException e) {
+      e.printStackTrace();
     } finally {
       try {
         if (stream != null) {
@@ -376,9 +383,9 @@ public class IdentifierIndexManager {
       }
     }
   }
+
   /**
-   * Adds a line of the index file for function, class, class-method and
-   * class-variable names
+   * Adds a line of the index file for function, class, class-method and class-variable names
    * 
    * @param line
    */
@@ -404,78 +411,71 @@ public class IdentifierIndexManager {
       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;
+      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;
       }
       if (identifier != null && phpIdentifier != null) {
         tokenExists = true;
@@ -498,10 +498,11 @@ public class IdentifierIndexManager {
         }
       }
     }
-//    if (tokenExists) {
-      fFileMap.put(phpFileName, line);
-//    } 
+    //    if (tokenExists) {
+    fFileMap.put(phpFileName, line);
+    //    }
   }
+
   /**
    * Change the information for a given IFile resource
    *  
@@ -510,9 +511,9 @@ public class IdentifierIndexManager {
     removeFile(fileToParse);
     addFile(fileToParse);
   }
+
   /**
-   * Get a list of all PHPIdentifierLocation object's associated with an
-   * identifier
+   * Get a list of all PHPIdentifierLocation object's associated with an identifier
    * 
    * @param identifier
    * @return
@@ -520,6 +521,7 @@ public class IdentifierIndexManager {
   public List getLocations(String identifier) {
     return (List) fIndentifierMap.get(identifier);
   }
+
   /**
    * Initialize (i.e. clear) the current index information
    *  
@@ -528,6 +530,7 @@ public class IdentifierIndexManager {
     fIndentifierMap = new TreeMap(new StringComparator());
     fFileMap = new HashMap();
   }
+
   private void readFile() {
     FileReader fileReader;
     try {
@@ -549,6 +552,7 @@ public class IdentifierIndexManager {
       e.printStackTrace();
     }
   }
+
   /**
    * Remove the information for a given IFile resource
    *  
@@ -556,14 +560,14 @@ public class IdentifierIndexManager {
   public void removeFile(IFile fileToParse) {
     //    String line = (String)
     // fFileMap.get(fileToParse.getLocation().toString());
-    String line = (String) fFileMap.get(fileToParse.getFullPath().toString());
+    String line = (String) fFileMap.get(fileToParse.getProjectRelativePath().toString());
     if (line != null) {
       removeLine(line);
     }
   }
+
   /**
-   * Removes a line of the index file for function, class, class-method and
-   * class-variable names
+   * Removes a line of the index file for function, class, class-method and class-variable names
    * 
    * @param line
    */
@@ -582,73 +586,66 @@ public class IdentifierIndexManager {
       //System.out.println(token);
     } else {
       return;
-    } 
+    }
     int offset = -1;
     // 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 'o' :
-          // offset information
-          identifier = null;
-          break;
-        case 'p' :
-          // PHPdoc offset information
-          identifier = null;
-          break;
-        case 'l' :
-          // PHPdoc length information
-          identifier = null;
-          break;
-        case 'v' :
-          // variable inside a class
-          identifier = token.substring(1);
-          phpIdentifier = new PHPIdentifierLocation(identifier,
-              PHPIdentifier.VARIABLE, phpFileName, classname);
-          break;
-        default :
-          PHPeclipsePlugin.log(IStatus.ERROR, "Unknown token character in IdentifierIndexManager: "+token.charAt(0));
-          identifier = null;
-          phpIdentifier = null;
-          classname = null;
+      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 'o':
+        // offset information
+        identifier = null;
+        break;
+      case 'p':
+        // PHPdoc offset information
+        identifier = null;
+        break;
+      case 'l':
+        // PHPdoc length information
+        identifier = null;
+        break;
+      case 'v':
+        // variable inside a class
+        identifier = token.substring(1);
+        phpIdentifier = new PHPIdentifierLocation(identifier, PHPIdentifier.VARIABLE, phpFileName, classname);
+        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) {
         ArrayList list = (ArrayList) fIndentifierMap.get(identifier);
@@ -668,6 +665,7 @@ public class IdentifierIndexManager {
     }
     fFileMap.remove(phpFileName);
   }
+
   /**
    * Save the current index information in the projects index file
    *  
@@ -691,6 +689,7 @@ public class IdentifierIndexManager {
       e.printStackTrace();
     }
   }
+
   /**
    * @param fromKey
    * @param toKey
@@ -709,9 +708,9 @@ public class IdentifierIndexManager {
     ArrayList list = new ArrayList();
     String fileName;
     int index;
-    while(iter.hasNext()) {
+    while (iter.hasNext()) {
       fileName = (String) iter.next();
-      if ((index=fileName.indexOf(filePattern))!=-1 && fileName.length()==(index+filePattern.length())) {
+      if ((index = fileName.indexOf(filePattern)) != -1 && fileName.length() == (index + filePattern.length())) {
         list.add(fileName);
       }
     }