changed the "description" attribute in phpsyntax.xml into multi-line text between...
authorkhartlage <khartlage>
Tue, 28 Jan 2003 22:02:01 +0000 (22:02 +0000)
committerkhartlage <khartlage>
Tue, 28 Jan 2003 22:02:01 +0000 (22:02 +0000)
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSyntaxRdr.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPTextHover.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpsyntax.xml

index 00e287c..ed67b53 100644 (file)
@@ -13,6 +13,13 @@ import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
+import net.sourceforge.phpeclipse.IPreferenceConstants;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+import net.sourceforge.phpeclipse.phpeditor.php.PHPConstant;
+import net.sourceforge.phpeclipse.phpeditor.php.PHPElement;
+import net.sourceforge.phpeclipse.phpeditor.php.PHPFunction;
+import net.sourceforge.phpeclipse.phpeditor.php.PHPKeyword;
+import net.sourceforge.phpeclipse.phpeditor.php.PHPType;
 import org.apache.xml.serialize.OutputFormat;
 import org.apache.xml.serialize.Serializer;
 import org.apache.xml.serialize.SerializerFactory;
@@ -24,17 +31,10 @@ import org.w3c.dom.Document;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
-import net.sourceforge.phpeclipse.IPreferenceConstants;
-import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-import net.sourceforge.phpeclipse.phpeditor.php.PHPConstant;
-import net.sourceforge.phpeclipse.phpeditor.php.PHPElement;
-import net.sourceforge.phpeclipse.phpeditor.php.PHPFunction;
-import net.sourceforge.phpeclipse.phpeditor.php.PHPKeyword;
-import net.sourceforge.phpeclipse.phpeditor.php.PHPType;
-
 /**
  * <code>PHPSyntaxRdr</code> reads PHP specifics from an XML file (eg. keywords) 
  */
@@ -49,7 +49,6 @@ public class PHPSyntaxRdr {
   private static final String TYPE_ATTR = "type"; //$NON-NLS-1$
   private static final String CONSTANT_ATTR = "constant"; //$NON-NLS-1$
   private static final String FN_ATTR = "function"; //$NON-NLS-1$
-  private static final String DESCRIPTION = "description"; //$NON-NLS-1$
   private static final String USAGE_ATTR = "usage"; //$NON-NLS-1$
   private static final String TOKENVAL_ATTR = "tokenval"; //$NON-NLS-1$
   private static IPreferenceStore store;
@@ -136,21 +135,29 @@ public class PHPSyntaxRdr {
         String Type = getAttributeValue(attributes, TYPE_ATTR);
         String Function = getAttributeValue(attributes, FN_ATTR);
         String Constant = getAttributeValue(attributes, CONSTANT_ATTR);
-        String Description = getAttributeValue(attributes, DESCRIPTION);
-        String Usage = getAttributeValue(attributes, USAGE_ATTR);
+        String usage = getAttributeValue(attributes, USAGE_ATTR);
         String Tokenval = getAttributeValue(attributes, TOKENVAL_ATTR);
 
+        StringBuffer buffer= new StringBuffer();
+        NodeList children= node.getChildNodes();
+        for (int j= 0; j != children.getLength(); j++) {
+          String value= children.item(j).getNodeValue();
+          if (value != null)
+            buffer.append(value);
+        }
+        String description = buffer.toString().trim();
+        
         if (Keyword == null && Type == null && Function == null && Constant == null) {
           //ignore as it is not a valid phpsyntax tag
         } else {
           if (Keyword != null) {
-            syntaxdata.addElement(new PHPKeyword(Keyword, Description, Tokenval));
+            syntaxdata.addElement(new PHPKeyword(Keyword, usage, Tokenval));
           } else if (Type != null) {
-            syntaxdata.addElement(new PHPType(Type, Description));
+            syntaxdata.addElement(new PHPType(Type, usage));
           } else if (Function != null) {
-            syntaxdata.addElement(new PHPFunction(Function, Description, Usage));
+            syntaxdata.addElement(new PHPFunction(Function, usage, description));
           } else if (Constant != null) {
-            syntaxdata.addElement(new PHPConstant(Constant, Description));
+            syntaxdata.addElement(new PHPConstant(Constant, usage));
           }
         }
       }
@@ -229,8 +236,8 @@ public class PHPSyntaxRdr {
           name = document.createAttribute(CONSTANT_ATTR);
         name.setValue(((PHPElement) bufferobj).getName());
         attributes.setNamedItem(name);
-        Attr description = document.createAttribute(DESCRIPTION);
-        description.setValue(((PHPElement) bufferobj).getDescription());
+        Attr description = document.createAttribute(USAGE_ATTR);
+        description.setValue(((PHPElement) bufferobj).getUsage());
         attributes.setNamedItem(description);
         if (bufferobj instanceof PHPKeyword) {
           Attr tokenval = document.createAttribute(TOKENVAL_ATTR);
@@ -238,9 +245,11 @@ public class PHPSyntaxRdr {
           attributes.setNamedItem(tokenval);
         }
         if (bufferobj instanceof PHPFunction) {
-          Attr usage = document.createAttribute(USAGE_ATTR);
-          usage.setValue(((PHPFunction) bufferobj).getUsage());
-          attributes.setNamedItem(usage);
+    //      Attr usage = document.createAttribute(USAGE_ATTR);
+          Text usage = document.createTextNode(((PHPFunction) bufferobj).getDescription());
+          node.appendChild(usage);
+//          usage.setValue(((PHPFunction) bufferobj).getUsage());
+//          attributes.setNamedItem(usage);
         }
       }
       OutputFormat format = new OutputFormat();
index 4851296..878629c 100644 (file)
@@ -14,16 +14,14 @@ package net.sourceforge.phpeclipse.phpeditor;
 import java.util.HashMap;
 import java.util.Vector;
 
+import net.sourceforge.phpeclipse.phpeditor.php.PHPElement;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPWordExtractor;
-
 import org.eclipse.jface.text.IRegion;
 import org.eclipse.jface.text.ITextHover;
 import org.eclipse.jface.text.ITextViewer;
 import org.eclipse.jface.text.Region;
 import org.eclipse.swt.graphics.Point;
 
-import net.sourceforge.phpeclipse.phpeditor.php.PHPElement;
-
 /**
  * Example implementation for an <code>ITextHover</code> 
  * which hovers over PHP code.
@@ -32,6 +30,7 @@ public class PHPTextHover implements ITextHover {
   public static HashMap functionDescriptions = null;
 
   private static PHPWordExtractor phpWordDetector = new PHPWordExtractor();
+  
   /* (non-Javadoc)
    * Method declared on ITextHover
    */
@@ -50,13 +49,14 @@ public class PHPTextHover implements ITextHover {
             String strbuffer = null;
             PHPElement elbuffer = null;
             while ((syntaxbuffer != null)
-              && (!syntaxbuffer.isEmpty() && ((elbuffer = (PHPElement) syntaxbuffer.remove(0)) != null))) {
-              functionDescriptions.put(elbuffer.getName(), elbuffer.getDescription());
+              && (!syntaxbuffer.isEmpty() && 
+                 ((elbuffer = (PHPElement) syntaxbuffer.remove(0)) != null))) {
+              functionDescriptions.put(elbuffer.getName(), elbuffer.getHoverText());
             }
 
             //            functionDescriptions = new HashMap(997);
             //            for (int i=0; i<PHPFunctionNames.FUNCTION_NAMES.length;i++) {
-            //              functionDescriptions.put(PHPFunctionNames.FUNCTION_NAMES[i],PHPFunctionDescription.FUNCTION_DESCRIPTION[i]);
+            //              functionDescriptions.put(PHPFunctionNasmes.FUNCTION_NAMES[i],PHPFunctionDescription.FUNCTION_DESCRIPTION[i]);
             //            }
           }
           return (String) functionDescriptions.get(word);
index 51ee93c..efadf8f 100644 (file)
@@ -4,11 +4,11 @@
 ===================================================        
 *Below this are the various PHP-specific functions *
 ===================================================     
-        <phpsyntax function="COM_invoke" usage="mixed COM_invoke(int module, string handler_name [, mixed arg [, mixed ...]])\n" description="Invokes a COM module"></phpsyntax>
-        <phpsyntax function="COM_load" usage="int com_load(string module_name [, string remote_host [, int codepage [, string typelib]]])\n" description="Loads a COM module"></phpsyntax>
-        <phpsyntax function="abs" usage="int abs(int number)\n" description="Return the absolute value of the number"></phpsyntax>
+        <phpsyntax function="COM_invoke" usage="mixed COM_invoke(int module, string handler_name [, mixed arg [, mixed ...]])">Invokes a COM module</phpsyntax>
+        <phpsyntax function="COM_load" usage="int com_load(string module_name [, string remote_host [, int codepage [, string typelib]]])">Loads a COM module</phpsyntax>
+        <phpsyntax function="abs" usage="int abs(int number)">Return the absolute value of the number</phpsyntax>
         <phpsyntax function="accept_connect"></phpsyntax>
-        <phpsyntax function="acos" usage="float acos(float number)" description="Return the arc cosine of the number in radians"></phpsyntax>
+        <phpsyntax function="acos" usage="float acos(float number)">Return the arc cosine of the number in radians</phpsyntax>
         <phpsyntax function="add"></phpsyntax>
         <phpsyntax function="add_iovec"></phpsyntax>
         <phpsyntax function="addaction"></phpsyntax>
         <phpsyntax function="chroot"></phpsyntax>
         <phpsyntax function="chroot"></phpsyntax>
         <phpsyntax function="chunk_split"></phpsyntax>
-        <phpsyntax function="class_exists" usage="bool class_exists(string classname)\n" description="Checks if the class exists"></phpsyntax>
+        <phpsyntax function="class_exists" usage="Checks if the class exists">bool class_exists(string classname)</phpsyntax>
         <phpsyntax function="clearstatcache"></phpsyntax>
         <phpsyntax function="close"></phpsyntax>
-        <phpsyntax function="closedir" usage="void closedir([resource dir_handle])\n" description="Close directory connection identified by the dir_handle"></phpsyntax>
+        <phpsyntax function="closedir" usage="Close directory connection identified by the dir_handle">void closedir([resource dir_handle])</phpsyntax>
         <phpsyntax function="closelog"></phpsyntax>
         <phpsyntax function="com_get"></phpsyntax>
         <phpsyntax function="com_propget"></phpsyntax>
         <phpsyntax function="crack_opendict"></phpsyntax>
         <phpsyntax function="crash"></phpsyntax>
         <phpsyntax function="crc32"></phpsyntax>
-        <phpsyntax function="create_function" usage="string create_function(string args, string code)\n" description="Creates an anonymous function, and returns its name (funny, eh?)"></phpsyntax>
+        <phpsyntax function="create_function" usage="Creates an anonymous function, and returns its name (funny, eh?)">string create_function(string args, string code)</phpsyntax>
         <phpsyntax function="crypt"></phpsyntax>
         <phpsyntax function="crypt"></phpsyntax>
         <phpsyntax function="ctype_alnum"></phpsyntax>
         <phpsyntax function="decbin"></phpsyntax>
         <phpsyntax function="dechex"></phpsyntax>
         <phpsyntax function="decoct"></phpsyntax>
-        <phpsyntax function="define" usage="bool define(string constant_name, mixed value, case_sensitive=true)\n" description="Define a new constant"></phpsyntax>
+        <phpsyntax function="define" usage="Define a new constant">bool define(string constant_name, mixed value, case_sensitive=true)</phpsyntax>
         <phpsyntax function="define_syslog_variables"></phpsyntax>
-        <phpsyntax function="defined" usage="bool defined(string constant_name)\n" description="Check whether a constant exists"></phpsyntax>
+        <phpsyntax function="defined" usage="Check whether a constant exists">bool defined(string constant_name)</phpsyntax>
         <phpsyntax function="deg2rad"></phpsyntax>
         <phpsyntax function="delete_iovec"></phpsyntax>
         <phpsyntax function="dgettext"></phpsyntax>
-        <phpsyntax function="dir" usage="class dir(string directory)\n" description="Directory class with properties, handle and class and methods read, rewind and close"></phpsyntax>
+        <phpsyntax function="dir" usage="Directory class with properties, handle and class and methods read, rewind and close">class dir(string directory)</phpsyntax>
         <phpsyntax function="dirname"></phpsyntax>
         <phpsyntax function="diskfreespace"></phpsyntax>
         <phpsyntax function="display_disabled_function"></phpsyntax>
         <phpsyntax function="mcal_event_set_alarm"></phpsyntax>
         <phpsyntax function="mcal_event_set_category"></phpsyntax>
         <phpsyntax function="mcal_event_set_class"></phpsyntax>
-        <phpsyntax function="mcal_event_set_description"></phpsyntax>
+        <phpsyntax function="mcal_event_set_usage"></phpsyntax>
         <phpsyntax function="mcal_event_set_end"></phpsyntax>
         <phpsyntax function="mcal_event_set_recur_daily"></phpsyntax>
         <phpsyntax function="mcal_event_set_recur_monthly_mday"></phpsyntax>
         <phpsyntax function="strtoupper"></phpsyntax>
         <phpsyntax function="strtr"></phpsyntax>
         <phpsyntax function="strval"></phpsyntax>
-        <phpsyntax function="substr" usage="string substr(string str, int start [, int length])\n" description="Returns part of a string"></phpsyntax>
+        <phpsyntax function="substr" usage="Returns part of a string">string substr(string str, int start [, int length])</phpsyntax>
         <phpsyntax function="substr_count"></phpsyntax>
         <phpsyntax function="substr_replace"></phpsyntax>
         <phpsyntax function="swf_actiongeturl"></phpsyntax>