[Laszlo-checkins] r11720 - openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/js2doc

dda@openlaszlo.org dda at openlaszlo.org
Mon Nov 10 14:04:43 PST 2008


Author: dda
Date: 2008-11-10 14:04:41 -0800 (Mon, 10 Nov 2008)
New Revision: 11720

Modified:
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/js2doc/SchemaBuilder.java
Log:
Change 20081110-dda-H by dda at lester.local on 2008-11-10 10:30:32 EST
    in /Users/dda/laszlo/src/svn/openlaszlo/trunk-d
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: In schemabuilder, throw an error for invalid types

New Features:

Bugs Fixed: LPP-7231

Technical Reviewer: max (pending)
QA Reviewer: (pending)
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:
    Changed schema builder to only permit certain types, and throw an error otherwise,
    rather than have the reader of the schema choke at runtime.
    The list of accepted types is:
     ID, boolean, color, css, expression, inheritableBoolean, number, numberExpression, reference, size, string, token.

    Aside:
    Kept some previously working code that silently converts other several other types (like LzNode)
    to "string" in the schema.  This was needed originally to get compatibility in generating
    a schema that looks like the old one (and one that is digested by the schema reader!).
    Maybe a better solution to this is to teach the readers of the schema to
    accept arbitrary types, but that goes beyond this JIRA,
    and it's not clear it gives us any new functionality now.

Tests:
   To see the error, recreated the original trouble by changing the javadoc for LzNode.datapath to

  /** ....
   * @type lz.datanode/String
   * @lzxtype datanode/string
   */
  var datapath = null;




Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/js2doc/SchemaBuilder.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/js2doc/SchemaBuilder.java	2008-11-10 17:56:02 UTC (rev 11719)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/js2doc/SchemaBuilder.java	2008-11-10 22:04:41 UTC (rev 11720)
@@ -548,7 +548,7 @@
                     member.type = eprop.getAttribute("type");
                 }
                 if (member.type != null && !"".equals(member.type)) {
-                    member.type = convertAttributeType(member.type);
+                    member.type = convertAttributeType(eprop, member.type);
                     if (member.type.indexOf('|') >= 0) {
                         member.enumvalues = member.type;
                         member.type = "string";
@@ -656,24 +656,24 @@
      * generally use the type found in the doc, and teach the reader
      * of lfc.lzx to know those types.
      */
-    String convertAttributeType(String s) {
+    String convertAttributeType(Element el, String s) {
+        String result = null;
         if (s.indexOf('|') >= 0) {
-            s = s.replaceAll("\"", "").replaceAll("'", "").replaceAll(" ", "");
+            result = s.replaceAll("\"", "").replaceAll("'", "").replaceAll(" ", "");
             // special case: booleanLiteral|'inherit' becomes inheritableBoolean
-            if ("booleanLiteral|inherit".equals(s)) {
-                s = "inheritableBoolean";
+            if ("booleanLiteral|inherit".equals(result)) {
+                result = "inheritableBoolean";
             }
-            return s;
         } else if ("String".equals(s)) {
-            return "string";
+            result = "string";
         } else if ("Number".equals(s) || "integer".equals(s) || "uint".equals(s)) {
-            return "number";
+            result = "number";
         } else if ("Boolean".equals(s)) {
-            return "boolean";
+            result = "boolean";
         } else if ("booleanLiteral".equals(s)) {
-            return "boolean";   // TODO: not exactly true, but this is what appears in the schema...
+            result = "boolean";   // TODO: not exactly true, but this is what appears in the schema...
         } else if ("sizeExpression".equals(s)) {
-            return "size";
+            result = "size";
         } else if ("Array".equals(s) ||
                    "LzDataNodeMixin".equals(s) ||
                    "LzDelegate".equals(s) ||
@@ -686,11 +686,25 @@
                    "DisplayKeys".equals(s) ||
                    "Dictionary".equals(s)) {
             // TODO: these have no good alternative!
-            return "string";
-        } else {            
-            // TODO: others??
-            return s;
+            result = "string";
+        } else if ("ID".equals(s) ||
+                   "boolean".equals(s) ||
+                   "color".equals(s) ||
+                   "css".equals(s) ||
+                   "expression".equals(s) ||
+                   "inheritableBoolean".equals(s) ||
+                   "number".equals(s) ||
+                   "numberExpression".equals(s) ||
+                   "reference".equals(s) ||
+                   "size".equals(s) ||
+                   "string".equals(s) ||
+                   "token".equals(s)) {
+            result = s;
+        } else {
+            throw new SchemaBuilderError(position(el) + "type \"" +
+                                         s + "\" not supported by schema builder");
         }
+        return result;
     }
 
     String convertDefaultValue(String s) {



More information about the Laszlo-checkins mailing list