Fixed bug: ArrayIndexOutOfBoundsException
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / PHPTextHover.java
index 22e1470..4d0aa94 100644 (file)
@@ -11,7 +11,6 @@
  **********************************************************************/
 package net.sourceforge.phpeclipse.phpeditor;
 
-import java.io.FileReader;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -21,6 +20,7 @@ import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import net.sourceforge.phpeclipse.builder.IdentifierIndexManager;
 import net.sourceforge.phpeclipse.builder.PHPIdentifierLocation;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPElement;
+import net.sourceforge.phpeclipse.phpeditor.php.PHPFunction;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPWordExtractor;
 
 import org.eclipse.core.resources.IProject;
@@ -34,9 +34,9 @@ import org.eclipse.swt.graphics.Point;
  * Implementation for an <code>ITextHover</code> which hovers over PHP code.
  */
 public class PHPTextHover implements ITextHover {
-       public static HashMap functionDescriptions = null;
+       private static HashMap functionDescriptions = null;
 
-       private static PHPWordExtractor phpWordDetector = new PHPWordExtractor();
+       private static HashMap identDescriptions = null;
 
        /**
         * The current project; maybe <code>null</code> for preference pages
@@ -57,13 +57,17 @@ public class PHPTextHover implements ITextHover {
                                        String word = textViewer.getDocument().get(hoverRegion.getOffset(), hoverRegion.getLength());
                                        if (functionDescriptions == null) {
                                                functionDescriptions = new HashMap();
+                                               identDescriptions = new HashMap();
                                                ArrayList syntaxbuffer = PHPSyntaxRdr.getSyntaxData();
-                                               String strbuffer = null;
                                                PHPElement elbuffer = null;
                                                if (syntaxbuffer != null) {
                                                        for (int i = 0; i < syntaxbuffer.size(); i++) {
                                                                elbuffer = (PHPElement) syntaxbuffer.get(i);
-                                                               functionDescriptions.put(elbuffer.getName(), elbuffer.getHoverText());
+                                                               if (elbuffer instanceof PHPFunction) {
+                                                                       functionDescriptions.put(elbuffer.getName(), elbuffer.getHoverText());
+                                                               } else {
+                                                                       identDescriptions.put(elbuffer.getName(), elbuffer.getHoverText());
+                                                               }
                                                        }
                                                }
                                                //
@@ -74,7 +78,7 @@ public class PHPTextHover implements ITextHover {
                                                // elbuffer.getHoverText());
                                                // }
                                        }
-                                       String hoverInfo = (String) functionDescriptions.get(word);
+                                       String hoverInfo = (String) identDescriptions.get(word);
                                        if (hoverInfo == null & word.length() > 0) {
                                                hoverInfo = (String) functionDescriptions.get(word.toLowerCase());
                                        }
@@ -86,7 +90,6 @@ public class PHPTextHover implements ITextHover {
                                                        try {
                                                                PHPIdentifierLocation location;
                                                                String filename;
-                                                               FileReader phpdocFileReader;
                                                                StringBuffer hoverInfoBuffer = new StringBuffer();
                                                                String workspaceLocation;
                                                                if (fProject != null) {