reworked the Console write() method
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / PHPSyntaxRdr.java
index 00e287c..6750da0 100644 (file)
@@ -13,6 +13,14 @@ 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 +32,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 +50,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 +136,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 +237,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 +246,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();