Author: hqm
Date: 2008-03-14 12:47:16 -0700 (Fri, 14 Mar 2008)
New Revision: 8272

Modified:
   openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx
   
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassModel.java
   
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java
Log:
Change 20080314-hqm-U by [EMAIL PROTECTED] on 2008-03-14 15:01:36 EDT
    in /Users/hqm/openlaszlo/trunk4
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: add warning for method in a state

New Features:

Bugs Fixed:

Technical Reviewer: ptw
QA Reviewer: dda
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:

add a "forbiddenElements" directive to the schema parser/verifier, and
make "method" a forbidden child of a <state> (or subclass of <state>) tag.
    

Tests:

compiling this should generate a warning

<canvas width="100%" height="80%" debug="true">
<view name="foo">
  <dragstate>
     <view/>
     <method name="foo">
     </method>
  </dragstate>
</view>
</canvas>
 



Modified: openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx 2008-03-14 19:12:36 UTC (rev 
8271)
+++ openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx 2008-03-14 19:47:16 UTC (rev 
8272)
@@ -527,6 +527,9 @@
   <event name="onapply"/>
   <!-- Script that is executed when the state is removed from its parent. -->
   <event name="onremove"/>
+  <forbiddenElements>
+    <element>method</element>
+  </forbiddenElements>
 </interface>
 
 <interface name="datarequest" extends="node"/>

Modified: 
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassModel.java
===================================================================
--- 
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassModel.java 
    2008-03-14 19:12:36 UTC (rev 8271)
+++ 
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassModel.java 
    2008-03-14 19:47:16 UTC (rev 8272)
@@ -20,6 +20,9 @@
     /** Set of tags that can legally be nested in this element */
     protected Set mCanContainTags = new HashSet();
 
+      /** Set of forbidden child tags of this element */
+    protected Set mForbiddenTags = new HashSet();
+
     /* If superclass is a predefined system class, just store its name. */
     protected String superclassName = null;
     protected boolean hasInputText = false;
@@ -310,9 +313,20 @@
     public Set getContainsSet () {
       return mCanContainTags;
     }
+
+      /** Add an entry to the table of forbidden tags for a
+       * given tag */
+    public void addForbiddenElement (String childtag) {
+      mForbiddenTags.add(childtag);
+    }
+
+    public Set getForbiddenSet () {
+      return mForbiddenTags;
+    }
+
 }
 
 /**
- * @copyright Copyright 2001-2007 Laszlo Systems, Inc.  All Rights
+ * @copyright Copyright 2001-2008 Laszlo Systems, Inc.  All Rights
  * Reserved.  Use is subject to license terms.
  */

Modified: 
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java
===================================================================
--- 
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java 
    2008-03-14 19:12:36 UTC (rev 8271)
+++ 
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java 
    2008-03-14 19:47:16 UTC (rev 8272)
@@ -3,7 +3,7 @@
  * 
****************************************************************************/
 
 /* J_LZ_COPYRIGHT_BEGIN *******************************************************
-* Copyright 2001-2007 Laszlo Systems, Inc.  All Rights Reserved.              *
+* Copyright 2001-2008 Laszlo Systems, Inc.  All Rights Reserved.              *
 * Use is subject to license terms.                                            *
 * J_LZ_COPYRIGHT_END *********************************************************/
 
@@ -362,6 +362,19 @@
                             "containsElement block must only contain <element> 
tags", etag);
                     }
                 } 
+            } else if (child.getName().equals("forbiddenElements")) {
+                    // look for <element>tagname</element> 
+                Iterator iter1 = child.getChildren().iterator();
+                while (iter1.hasNext()) {
+                    Element etag = (Element) iter1.next();
+                    if (etag.getName().equals("element")) {
+                        String tagname = etag.getText();
+                        info.addForbiddenElement(tagname);
+                    } else {
+                        throw new CompilationError(
+                            "containsElement block must only contain <element> 
tags", etag);
+                    }
+                } 
             }
         }
 
@@ -622,6 +635,12 @@
         // TODO [hqm 2007-09]: CHECK FOR NULL HERE 
 
         Set tagset = parent.getContainsSet();
+        Set forbidden = parent.getForbiddenSet();
+
+        if (forbidden.contains(childTag)) {
+            return false;
+        }
+
         if (tagset.contains(childTag)) {
             return true;
         }


_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Reply via email to