some unused Plug-in Depnedencies removed
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / builder / IdentifierIndexManager.java
index 4f92951..6772af2 100644 (file)
@@ -22,10 +22,12 @@ import net.sourceforge.phpdt.core.compiler.InvalidInputException;
 import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
 import net.sourceforge.phpdt.internal.compiler.parser.SyntaxError;
 import net.sourceforge.phpdt.internal.compiler.util.Util;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 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
  *  
@@ -42,7 +44,7 @@ public class IdentifierIndexManager {
      * 
      * @param typeOfIdentifier
      *            the type of the identifier ('c'lass, 'd'efine, 'f'unction,
-     *            'm'ethod, 'v'ariable)
+     *            'm'ethod(class), 'v'ariable(class) 'g'lobal variable)
      * @param identifier
      *            current identifier
      * @param line
@@ -168,7 +170,7 @@ public class IdentifierIndexManager {
                 ident[5]=='e') {
               if (fToken == TokenNameLPAREN) {
                 getNextToken();
-                if (fToken == TokenNameStringLiteral) {
+                if (fToken == TokenNameStringDoubleQuote) {
                   ident = fScanner.getCurrentStringLiteralSource();
                   addIdentifierInformation('d', ident, buf, phpdocOffset,
                       phpdocLength);
@@ -176,6 +178,19 @@ public class IdentifierIndexManager {
                 }
               }
             }
+          } else if (fToken == TokenNameglobal) {
+            // global variable
+            while (fToken != TokenNameEOF && fToken != TokenNameERROR && 
+                   fToken != TokenNameSEMICOLON &&
+                   fToken != TokenNameLBRACE &&
+                   fToken != TokenNameRBRACE ) {
+              getNextToken(); 
+              if (fToken == TokenNameVariable) {
+                ident = fScanner.getCurrentIdentifierSource();
+                addIdentifierInformation('g', ident, buf, phpdocOffset,
+                    phpdocLength);
+              }
+            }
           } else if (fToken == TokenNameLBRACE) {
             getNextToken();
             counter++;
@@ -243,6 +258,12 @@ public class IdentifierIndexManager {
               }
               parseDeclarations(ident, buf, true);
             }
+          } else if (fToken == TokenNameVariable) {
+            // global variable
+            ident = fScanner.getCurrentIdentifierSource();
+            addIdentifierInformation('g', ident, buf, phpdocOffset,
+                phpdocLength);
+            getNextToken(); 
           } else if (fToken == TokenNameIdentifier) {
             ident = fScanner.getCurrentIdentifierSource();
             getNextToken();
@@ -255,7 +276,7 @@ public class IdentifierIndexManager {
                 ident[5]=='e') {
               if (fToken == TokenNameLPAREN) {
                 getNextToken();
-                if (fToken == TokenNameStringLiteral) {
+                if (fToken == TokenNameStringDoubleQuote) {
                   ident = fScanner.getCurrentStringLiteralSource();
                   addIdentifierInformation('d', ident, buf, phpdocOffset,
                       phpdocLength);
@@ -322,7 +343,7 @@ public class IdentifierIndexManager {
     //    InputStream iStream;
     LineCreator lineCreator = createLineCreator();
     try {
-      addInputStream(new BufferedInputStream(fileToParse.getContents()), fileToParse.getFullPath().toString(), lineCreator);
+      addInputStream(new BufferedInputStream(fileToParse.getContents()), fileToParse.getProjectRelativePath().toString(), lineCreator);
     } catch (CoreException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
@@ -402,6 +423,12 @@ public class IdentifierIndexManager {
           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);
@@ -445,6 +472,7 @@ public class IdentifierIndexManager {
           }
           break;
         default :
+          PHPeclipsePlugin.log(IStatus.ERROR, "Unknown token character in IdentifierIndexManager: "+token.charAt(0));
           identifier = null;
           phpIdentifier = null;
           classname = null;
@@ -554,7 +582,8 @@ public class IdentifierIndexManager {
       //System.out.println(token);
     } else {
       return;
-    }
+    } 
+    int offset = -1;
     // all the other tokens are identifiers:
     while (tokenizer.hasMoreTokens()) {
       token = tokenizer.nextToken();
@@ -579,6 +608,12 @@ public class IdentifierIndexManager {
           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);
@@ -591,6 +626,18 @@ public class IdentifierIndexManager {
           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);
@@ -598,6 +645,7 @@ public class IdentifierIndexManager {
               PHPIdentifier.VARIABLE, phpFileName, classname);
           break;
         default :
+          PHPeclipsePlugin.log(IStatus.ERROR, "Unknown token character in IdentifierIndexManager: "+token.charAt(0));
           identifier = null;
           phpIdentifier = null;
           classname = null;