Author: ptw
Date: 2008-03-24 06:16:23 -0700 (Mon, 24 Mar 2008)
New Revision: 8359

Modified:
   
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassCompiler.java
   
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
   openlaszlo/trunk/lps/components/debugger/debugger.lzx
Log:
Change 20080322-ptw-K by [EMAIL PROTECTED] on 2008-03-22 15:33:49 EDT
    in /Users/ptw/OpenLaszlo/ringding-clean
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Fix regression due to class attribute vs. child

Bugs Fixed:
LPP-5663 'Conflict between class name attribute and child attribute named 
"name"'

Technical Reviewer: hqm (pending)
QA Reviewer: mamye (pending)

Details:
    ClassCompiler: Note className as global (for overwrite
    detection). No need to remove meta-attributes from model as they
    will not be included any more.

    NodeModel: Default superclass model correctly.  When compiling a
    class, do not include meta-attributes ("name", "extends", "with")
    in the attributes of the class.  No need to look up names as
    possibly conflicting with class now that class names are entered
    in the global table.

    debugger: Update so as not to trigger deprecated warnings.

Tests:
    smokecheck, test in bug no longer warns



Modified: 
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassCompiler.java
===================================================================
--- 
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassCompiler.java
  2008-03-24 13:05:07 UTC (rev 8358)
+++ 
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassCompiler.java
  2008-03-24 13:16:23 UTC (rev 8359)
@@ -72,9 +72,12 @@
      */
     void updateSchema(Element element, ViewSchema schema, Set visited) {
         Element elt = element;
-        
+        // Get meta attributes
         String classname = elt.getAttributeValue("name");
         String superclass = elt.getAttributeValue("extends");
+        // TODO: [2008-03-22 ptw] Need to add all elements of all
+        // mixins to the schema for this class
+        String mixins = elt.getAttributeValue("with");
         
         if (classname == null ||
             (schema.enforceValidIdentifier && 
!ScriptCompiler.isIdentifier(classname))) {
@@ -255,6 +258,8 @@
             }
         }
         String className = tagToClass(tagName);
+        // className will be a global
+        mEnv.addId(className, elt);
 
         ClassModel classModel = schema.getClassModel(tagName);
         
@@ -266,13 +271,11 @@
         // the runtime wants.
         NodeModel model = NodeModel.elementAsModel(elt, schema, mEnv);
         model = model.expandClassDefinitions();
-        model.removeAttribute("name");
         classModel.setNodeModel(model);
         // Should the package prefix be in the model?  Should the
         // model store class and tagname separately?
         String supertagname = classModel.getSuperclassName();
         String superclassname = tagToClass(supertagname);
-        model.removeAttribute("extends");
 
         // Build the constructor
         String body = "";

Modified: 
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
===================================================================
--- 
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java  
    2008-03-24 13:05:07 UTC (rev 8358)
+++ 
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java  
    2008-03-24 13:16:23 UTC (rev 8359)
@@ -489,7 +489,7 @@
         String parentName = this.className;
         return
             parentName.equals("class")?
-            schema.getClassModel(element.getAttributeValue("extends")):
+            schema.getClassModel(element.getAttributeValue("extends", 
ClassCompiler.DEFAULT_SUPERCLASS_NAME)):
             schema.getClassModel(parentName);
     }
 
@@ -633,7 +633,20 @@
                 }
             }
 
-            
+            // Special case for compiling a class, the class
+            // attributes are really 'meta' attributes, not
+            // attributes of the class -- they will be processed by
+            // the ClassModel or ClassCompiler
+            if ("class".equals(className)) {
+                // TODO: [2008-03-22 ptw] This should somehow be
+                // derived from the schema, but this does not work, so
+                // we hard-code the meta-attributes here
+//                 if (superclassModel.getAttribute(name) != null) {
+                if ("name".equals(name) || "extends".equals(name) || 
"with".equals(name)) {
+                    System.err.println("Skipping meta-attribute: " + name);
+                    continue;
+                }
+            }
 
             // Warn for redefine of a flash builtin
             // TODO: [2006-01-23 ptw] What about colliding with DHTML globals?
@@ -662,46 +675,32 @@
             if ((name.equals("id")) ||
                 (name.equals("name") &&
                  topLevelDeclaration() && !className.equals("class"))) {
-
-                ClassModel superclassModel = schema.getClassModel(value);
-                if (superclassModel != null && !superclassModel.isBuiltin()) {
+                ElementWithLocationInfo dup =
+                    (ElementWithLocationInfo) env.getId(value);
+                // we don't want to give a warning in the case
+                // where the id and name are on the same element,
+                // i.e., <view id="foo" name="foo"/>
+                if (dup != null && dup != element) {
+                    String locstring =
+                        CompilerUtils.sourceLocationPrettyString(dup);
                     env.warn(
-/* (non-Javadoc)
- * @i18n.test
- * @org-mes="You have given the " + p[0] + " an attribute " + p[1] + "=\"" + 
p[2] + "\", " + "which may overwrite the class \"" + p[3] + "\"."
- */
-            org.openlaszlo.i18n.LaszloMessages.getMessage(
-                NodeModel.class.getName(),"051018-559", new Object[] 
{getMessageName(), name, value, value})
-                        ,element);
+                        /* (non-Javadoc)
+                         * @i18n.test
+                         * @org-mes="Duplicate id attribute \"" + p[0] + "\" 
at " + p[1]
+                         */
+                        org.openlaszlo.i18n.LaszloMessages.getMessage(
+                            NodeModel.class.getName(),"051018-576", new 
Object[] {value, locstring})
+                        ,
+                        element);
                 } else {
-                    ElementWithLocationInfo dup =
-                        (ElementWithLocationInfo) env.getId(value);
-                    // we don't want to give a warning in the case
-                    // where the id and name are on the same element,
-                    // i.e., <view id="foo" name="foo"/>
-                    if (dup != null && dup != element) {
-                        String locstring =
-                            CompilerUtils.sourceLocationPrettyString(dup);
-                        env.warn(
-/* (non-Javadoc)
- * @i18n.test
- * @org-mes="Duplicate id attribute \"" + p[0] + "\" at " + p[1]
- */
-            org.openlaszlo.i18n.LaszloMessages.getMessage(
-                NodeModel.class.getName(),"051018-576", new Object[] {value, 
locstring})
-,
-                            element);
-                    } else {
-                        // TODO: [07-18-03 hqm] We will canonicalize
-                        // all id's to lowercase, because actionscript
-                        // is not case sensitive.  but in the future,
-                        // we should preserve case.
-                        env.addId(value, element);
-                    }
+                    // TODO: [07-18-03 hqm] We will canonicalize
+                    // all id's to lowercase, because actionscript
+                    // is not case sensitive.  but in the future,
+                    // we should preserve case.
+                    env.addId(value, element);
                 }
             }
 
-
             Schema.Type type;
             try {
                 if (className.equals("class")) {
@@ -775,8 +774,7 @@
                     if (name.equals("name")) {
                         Element parent = element.getParentElement();
                         if (parent != null) {
-                            for (Iterator iter2 = 
parent.getChildren().iterator(); iter2.hasNext();
-                                 ) {
+                            for (Iterator iter2 = 
parent.getChildren().iterator(); iter2.hasNext(); ) {
                                 Element e = (Element) iter2.next();
                                 if (!e.getName().equals("resource") && 
!e.getName().equals("font")
                                     && e != element && 
value.equals(e.getAttributeValue("name"))) {

Modified: openlaszlo/trunk/lps/components/debugger/debugger.lzx
===================================================================
--- openlaszlo/trunk/lps/components/debugger/debugger.lzx       2008-03-24 
13:05:07 UTC (rev 8358)
+++ openlaszlo/trunk/lps/components/debugger/debugger.lzx       2008-03-24 
13:16:23 UTC (rev 8359)
@@ -383,7 +383,7 @@
           }
       } else {
           if (!this.consoleRemote && !this['visible']) {
-              this.setVisible(true);
+              this.setAttribute('visible', true);
               this.bringToFront();
           }
           // Call the primitive method
@@ -638,8 +638,8 @@
             this.bottom.left.doSingleLine();
         }
         this.adjustMultiline();
-        this.top.controls.min.setVisible(!this.minimized);
-        this.top.controls.exp.setVisible(this.minimized);
+        this.top.controls.min.setAttribute('visible', !this.minimized);
+        this.top.controls.exp.setAttribute('visible', this.minimized);
     </method>
 
     <dragstate name="drag" />
@@ -671,7 +671,7 @@
          <basebutton name="close"  pixellock="true"
                   x="${parent.width - this.width - 7}"
                   resource="closeBtn_rsc"
-                  onclick="classroot.setVisible(false)" />
+                  onclick="classroot.setAttribute('visible', false)" />
           <basebutton name="min" pixellock="true"
                   x="${parent.close.x - this.width}"
                   resource="minBtn_rsc"
@@ -766,16 +766,16 @@
          <view name="left" height="${parent.height}" >
 
            <method name="doSingleLine">
-             this.upButton.setVisible(true); 
-             this.downButton.setVisible(false)
+             this.upButton.setAttribute('visible', true); 
+             this.downButton.setAttribute('visible', false)
              this.parent.center.input.setMultiline(false);
              classroot.savedInputAreaHeight = Math.max(53, this.parent.height);
              
this.parent.animate("height",classroot.smallInputAreaHeight,333,false);
            </method>
 
            <method name="doMultiLine">
-             this.downButton.setVisible(true); 
-             this.upButton.setVisible(false)
+             this.downButton.setAttribute('visible', true); 
+             this.upButton.setAttribute('visible', false)
              // Check if we have room to grow the input area
              var delta = classroot.savedInputAreaHeight - parent.height;
              delta = Math.min(classroot.middle.height - (classroot.lineheight 
* 2) , delta);
@@ -932,14 +932,14 @@
 
         if (typeof(global.lzconsoledebug) != 'undefined') {
            this.consoleRemote = true;
-           this.setVisible(false);
+           this.setAttribute('visible',false);
             // Open the remote debugger socket 
             __LzDebug.startupConsoleRemote();
         } else if (typeof(global.remotedebug) != 'undefined') {
            // This case mismatch here is intentional: "remotedebug" is the 
query arg, 
            // "Debug.remoteDebug" is the attribute on the Debugger window.
             this.remoteDebug = true;
-            this.setVisible( false );
+            this.setAttribute('visible', false );
             // Open the remote debugger socket 
             this.startupRemote();
 
@@ -969,7 +969,7 @@
             for (var i = 0; i < this.saved_msgs.length; i++) {
                 this.__write(this.saved_msgs[i]);
             }
-            this.setVisible( true );
+            this.setAttribute('visible', true );
             this.bringToFront();
         }
 


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

Reply via email to