flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erikdebr...@apache.org
Subject svn commit: r1451687 - in /flex/falcon/trunk: compiler.jx.tests/src/org/apache/flex/compiler/internal/mxml/codegen/ compiler.jx.tests/src/org/apache/flex/compiler/internal/mxml/codegen/flexjs/ compiler.jx.tests/src/org/apache/flex/compiler/internal/tes...
Date Fri, 01 Mar 2013 18:50:20 GMT
Author: erikdebruin
Date: Fri Mar  1 18:50:19 2013
New Revision: 1451687

URL: http://svn.apache.org/r1451687
Log:
Added some MXML tests and made them pass.
Removed FlexJSUI.swc from 'test-files', as it is a binary and therefore doesn't belong in
SVN.

Added:
    flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/mxml/codegen/flexjs/TestFlexJSMXMLApplication.java
      - copied, changed from r1451197, flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/mxml/codegen/flexjs/TestMXMLDocument.java
Removed:
    flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/mxml/codegen/flexjs/TestMXMLDocument.java
    flex/falcon/trunk/compiler.jx.tests/test-files/flexjs/projects/FlexJSTest/libs/FlexJSUI.swc
Modified:
    flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/mxml/codegen/TestMXMLApplication.java
    flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/FlexJSTestBase.java
    flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/MXMLTestBase.java
    flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/mxml/codegen/MXMLBlockWalker.java
    flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/mxml/codegen/MXMLEmitter.java
    flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/mxml/visitor/MXMLNodeSwitch.java
    flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/mxml/codegen/IMXMLEmitter.java
    flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/visitor/IMXMLBlockVisitor.java

Modified: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/mxml/codegen/TestMXMLApplication.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/mxml/codegen/TestMXMLApplication.java?rev=1451687&r1=1451686&r2=1451687&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/mxml/codegen/TestMXMLApplication.java
(original)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/mxml/codegen/TestMXMLApplication.java
Fri Mar  1 18:50:19 2013
@@ -2,53 +2,120 @@ package org.apache.flex.compiler.interna
 
 import org.apache.flex.compiler.internal.test.MXMLTestBase;
 import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
-import org.junit.Ignore;
 import org.junit.Test;
 
 public class TestMXMLApplication extends MXMLTestBase
 {
 
     @Test
-    public void testSimple()
+    public void testBasicApp()
     {
-        String code = "" +
-                "<s:Application xmlns:s=\"library://ns.adobe.com/flex/spark\">" +
-                "</s:Application>";
-        
+        String code = ""
+                + "<s:Application xmlns:s=\"library://ns.adobe.com/flex/spark\">"
+                + "</s:Application>";
+
         IMXMLFileNode node = compileMXML(code);
 
         mxmlBlockWalker.visitFile(node);
-        
-        assertOut("<Application>\n\t\n</Application>");
+
+        assertOut("<Application>\n</Application>");
     }
 
-    
     @Test
-    public void testOneComponent()
+    public void testBasicAppWithOneComponent()
     {
-        String code = "" +
-        		"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
-        		"<s:Application xmlns:fx=\"http://ns.adobe.com/mxml/2009\" xmlns:s=\"library://ns.adobe.com/flex/spark\"
xmlns:mx=\"library://ns.adobe.com/flex/mx\">\n" +
-                "\t<s:Button id=\"myBtn\" label=\"Hello world\"></s:Button>\n"
+
-        		"</s:Application>";
-        
+        String code = ""
+                + "<s:Application xmlns:s=\"library://ns.adobe.com/flex/spark\">"
+                + "    <s:Button id=\"myBtn\" label=\"Hello world\"></s:Button>"
+                + "</s:Application>";
+
         IMXMLFileNode node = compileMXML(code);
 
         mxmlBlockWalker.visitFile(node);
-        
+
         assertOut("<Application>\n\t<Button id=\"myBtn\" label=\"Hello world\"></Button>\n</Application>");
     }
 
-    @Ignore
     @Test
-    public void MXMLApplication_component()
+    public void testBasicAppWithTwoComponents()
     {
-        String code = "<component className=\"org.apache.flex.core:Application\" " +
-        		"name=\"Application\" uri=\"library://ns.apache.org/flexjs/basic\" />";
-        
+        String code = ""
+                + "<s:Application xmlns:s=\"library://ns.adobe.com/flex/spark\">"
+                + "    <s:Label id=\"myLbl\" text=\"Bye bye\"></s:Label>"
+                + "    <s:Button id=\"myBtn\" label=\"Hello world\"></s:Button>"
+                + "</s:Application>";
+
         IMXMLFileNode node = compileMXML(code);
 
         mxmlBlockWalker.visitFile(node);
+
+        assertOut("<Application>\n\t<Label id=\"myLbl\" text=\"Bye bye\"></Label>\n\t<Button
id=\"myBtn\" label=\"Hello world\"></Button>\n</Application>");
+    }
+
+    @Test
+    public void testDefaultApp()
+    {
+        String code = ""
+                + "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+                + "<s:Application xmlns:fx=\"http://ns.adobe.com/mxml/2009\""
+                + "               xmlns:s=\"library://ns.adobe.com/flex/spark\" "
+                + "               xmlns:mx=\"library://ns.adobe.com/flex/mx\" "
+                + "               minWidth=\"955\" minHeight=\"600\">"
+                + "    <fx:Declarations>"
+                + "        <!-- Place non-visual elements (e.g., services, value objects)
here -->"
+                + "    </fx:Declarations>" + "</s:Application>";
+
+        IMXMLFileNode node = compileMXML(code);
+
+        mxmlBlockWalker.visitFile(node);
+
+        assertOut("<Application minHeight=600 minWidth=955>\n</Application>");
+    }
+
+    @Test
+    public void testDefaultAppWithOneComponent()
+    {
+        String code = ""
+                + "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+                + "<s:Application xmlns:fx=\"http://ns.adobe.com/mxml/2009\""
+                + "               xmlns:s=\"library://ns.adobe.com/flex/spark\""
+                + "               xmlns:mx=\"library://ns.adobe.com/flex/mx\""
+                + "               minWidth=\"955\" minHeight=\"600\">"
+                + "    <fx:Declarations>"
+                + "        <!-- Place non-visual elements (e.g., services, value objects)
here -->"
+                + "    </fx:Declarations>"
+                + "    <s:Button label=\"Click me\" />" + "</s:Application>";
+
+        IMXMLFileNode node = compileMXML(code);
+
+        mxmlBlockWalker.visitFile(node);
+
+        assertOut("<Application minHeight=600 minWidth=955>\n\t<Button label=\"Click
me\"></Button>\n</Application>");
+    }
+
+    @Test
+    public void testDefaultAppSimpleScript()
+    {
+        // TODO (erikdebruin) handle actual script contents... 
+        //                    maybe use AS parser?
+        String code = ""
+                + "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+                + "<s:Application xmlns:fx=\"http://ns.adobe.com/mxml/2009\""
+                + "               xmlns:s=\"library://ns.adobe.com/flex/spark\""
+                + "               xmlns:mx=\"library://ns.adobe.com/flex/mx\""
+                + "               minWidth=\"955\" minHeight=\"600\">"
+                + "    <fx:Declarations>"
+                + "        <!-- Place non-visual elements (e.g., services, value objects)
here -->"
+                + "    </fx:Declarations>" + "    <fx:Script>"
+                + "        <![CDATA["
+                + "            // just a comment here, for now ;-)"
+                + "        ]]>" + "    </fx:Script>" + "</s:Application>";
+
+        IMXMLFileNode node = compileMXML(code);
+
+        mxmlBlockWalker.visitFile(node);
+
+        assertOut("<Application minHeight=600 minWidth=955>\n</Application>");
     }
 
 }

Copied: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/mxml/codegen/flexjs/TestFlexJSMXMLApplication.java
(from r1451197, flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/mxml/codegen/flexjs/TestMXMLDocument.java)
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/mxml/codegen/flexjs/TestFlexJSMXMLApplication.java?p2=flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/mxml/codegen/flexjs/TestFlexJSMXMLApplication.java&p1=flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/mxml/codegen/flexjs/TestMXMLDocument.java&r1=1451197&r2=1451687&rev=1451687&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/mxml/codegen/flexjs/TestMXMLDocument.java
(original)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/mxml/codegen/flexjs/TestFlexJSMXMLApplication.java
Fri Mar  1 18:50:19 2013
@@ -7,18 +7,33 @@ import org.apache.flex.compiler.tree.mxm
 import org.junit.Ignore;
 import org.junit.Test;
 
-public class TestMXMLDocument extends FlexJSTestBase
+public class TestFlexJSMXMLApplication extends FlexJSTestBase
 {
 
     @Ignore
     @Test
+    public void testBasicAppMx()
+    {
+        String code = ""
+                + "<basic:Application xmlns:basic=\"library://ns.apache.org/flexjs/basic\">"
+                + "</basic:Application>";
+
+        IMXMLFileNode node = compileMXML(code);
+
+        mxmlBlockWalker.visitFile(node);
+
+        // TODO (erikdebruin) this needs to become JS Goog output ;-)
+        assertOut("<Application>\n</Application>");
+    }
+
+    @Ignore
+    @Test
     public void MXMLClassNode_flashDisplaySprite()
     {
-        String path = "flexjs" + File.separator + 
-                      "projects" + File.separator + 
-                      "FlexJSTest" + File.separator + 
-                      "src";
-        
+        String path = "flexjs"
+                + File.separator + "projects" + File.separator + "FlexJSTest"
+                + File.separator + "src";
+
         IMXMLFileNode node = compileMXML("FlexJSTest", true, path);
 
         mxmlBlockWalker.visitFile(node);

Modified: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/FlexJSTestBase.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/FlexJSTestBase.java?rev=1451687&r1=1451686&r2=1451687&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/FlexJSTestBase.java
(original)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/FlexJSTestBase.java
Fri Mar  1 18:50:19 2013
@@ -18,7 +18,8 @@ public class FlexJSTestBase extends Test
         super.setUp();
 
         mxmlEmitter = backend.createMXMLEmitter(writer);
-        mxmlBlockWalker = backend.createMXMLWalker(project, errors, mxmlEmitter);
+        mxmlBlockWalker = backend
+                .createMXMLWalker(project, errors, mxmlEmitter);
     }
 
     @Override
@@ -30,9 +31,8 @@ public class FlexJSTestBase extends Test
                 + "/frameworks/libs/framework.swc")));
         libraries.add(new File(FilenameNormalization.normalize(env.SDK
                 + "\\frameworks\\libs\\rpc.swc")));
-        libraries.add(new File(FilenameNormalization.normalize(env.SDK
-                + "/frameworks/libs/spark.swc")));
-        libraries.add(new File(tempDir, "libs/FlexJSUI.swc"));
+        libraries.add(new File(
+                "./test-files/flexjs/projects/FlexJSTest/libs/FlexJSUI.swc"));
 
         super.addLibraries();
     }
@@ -40,9 +40,12 @@ public class FlexJSTestBase extends Test
     @Override
     public void addNamespaceMappings()
     {
-        namespaceMappings.add(new MXMLNamespaceMapping(
-                "library://ns.apache.org/flexjs/basic", new File(tempDir,
-                        "libs/manifest.xml").getAbsolutePath()));
+        namespaceMappings
+                .add(new MXMLNamespaceMapping(
+                        "library://ns.apache.org/flexjs/basic",
+                        new File(
+                                "./test-files/flexjs/projects/FlexJSTest/libs/basic-manifest.xml")
+                                .getAbsolutePath()));
 
         super.addNamespaceMappings();
     }

Modified: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/MXMLTestBase.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/MXMLTestBase.java?rev=1451687&r1=1451686&r2=1451687&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/MXMLTestBase.java
(original)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/MXMLTestBase.java
Fri Mar  1 18:50:19 2013
@@ -18,7 +18,8 @@ public class MXMLTestBase extends TestBa
         super.setUp();
 
         mxmlEmitter = backend.createMXMLEmitter(writer);
-        mxmlBlockWalker = backend.createMXMLWalker(project, errors, mxmlEmitter);
+        mxmlBlockWalker = backend
+                .createMXMLWalker(project, errors, mxmlEmitter);
     }
 
     @Override
@@ -27,8 +28,12 @@ public class MXMLTestBase extends TestBa
         libraries.add(new File(FilenameNormalization.normalize(env.FPSDK
                 + "/11.1/playerglobal.swc")));
         libraries.add(new File(FilenameNormalization.normalize(env.SDK
+                + "/frameworks/libs/framework.swc")));
+        libraries.add(new File(FilenameNormalization.normalize(env.SDK
+                + "/frameworks/libs/mx.swc")));
+        libraries.add(new File(FilenameNormalization.normalize(env.SDK
                 + "/frameworks/libs/spark.swc")));
-        
+
         super.addLibraries();
     }
 

Modified: flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/mxml/codegen/MXMLBlockWalker.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/mxml/codegen/MXMLBlockWalker.java?rev=1451687&r1=1451686&r2=1451687&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/mxml/codegen/MXMLBlockWalker.java
(original)
+++ flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/mxml/codegen/MXMLBlockWalker.java
Fri Mar  1 18:50:19 2013
@@ -21,18 +21,19 @@ package org.apache.flex.compiler.interna
 
 import java.util.List;
 
-import org.apache.flex.compiler.definitions.IClassDefinition;
 import org.apache.flex.compiler.mxml.codegen.IMXMLEmitter;
 import org.apache.flex.compiler.problems.ICompilerProblem;
 import org.apache.flex.compiler.projects.IASProject;
-import org.apache.flex.compiler.projects.ICompilerProject;
 import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLArrayNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLClassDefinitionNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLDeclarationsNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLDeferredInstanceNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLDocumentNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLEventSpecifierNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLInstanceNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLIntNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLLiteralNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLPropertySpecifierNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLScriptNode;
@@ -44,6 +45,7 @@ import org.apache.flex.compiler.visitor.
 
 /**
  * @author Michael Schmalle
+ * @author Erik de Bruin
  */
 public class MXMLBlockWalker implements IMXMLBlockVisitor, IMXMLBlockWalker
 {
@@ -98,6 +100,7 @@ public class MXMLBlockWalker implements 
         emitter.setMXMLWalker(this);
     }
 
+    @Override
     public void visitFile(IMXMLFileNode node)
     {
         debug("visitFile()");
@@ -105,6 +108,7 @@ public class MXMLBlockWalker implements 
         walk(node.getDocumentNode());
     }
 
+    @Override
     public void visitDeclarations(IMXMLDeclarationsNode node)
     {
         debug("visitDeclarations()");
@@ -112,17 +116,17 @@ public class MXMLBlockWalker implements 
         //
     }
 
+    @Override
     public void visitDocument(IMXMLDocumentNode node)
     {
         debug("visitDocument()");
 
-        IClassDefinition cdef = node.getClassReference((ICompilerProject) project);
-
-        emitter.emitDocumentHeader(cdef);
+        emitter.emitDocumentHeader(node);
         visitClassDefinition(node);
-        emitter.emitDocumentFooter(cdef);
+        emitter.emitDocumentFooter(node);
     }
 
+    @Override
     public void visitClassDefinition(IMXMLClassDefinitionNode node)
     {
         debug("visitClassDefinition()");
@@ -132,6 +136,17 @@ public class MXMLBlockWalker implements 
 
     //--------------------------------------------------------------------------
 
+    @Override
+    public void visitDeferredInstance(IMXMLDeferredInstanceNode node)
+    {
+        debug("visitdeferredInstance()");
+
+        walk(node.getChild(0));
+    }
+
+    //--------------------------------------------------------------------------
+
+    @Override
     public void visitPropertySpecifier(IMXMLPropertySpecifierNode node)
     {
         debug("visitPropertySpecifier()");
@@ -139,6 +154,7 @@ public class MXMLBlockWalker implements 
         emitter.emitPropertySpecifier(node);
     }
 
+    @Override
     public void visitEventSpecifier(IMXMLEventSpecifierNode node)
     {
         debug("visitEventSpecifier()");
@@ -150,10 +166,11 @@ public class MXMLBlockWalker implements 
         debug("visitStyleSpecifier()");
     }
 
+    @Override
     public void visitInstance(IMXMLInstanceNode node)
     {
         debug("visitInstance()");
-        
+
         emitter.emitInstance(node);
     }
 
@@ -166,23 +183,41 @@ public class MXMLBlockWalker implements 
     //--------------------------------------------------------------------------
 
     @Override
-    public void visitLiteral(IMXMLLiteralNode node)
+    public void visitArray(IMXMLArrayNode node)
     {
-        debug("visitLiteral()");
-        
-        emitter.emitLiteral(node);
+        debug("visitArray()");
+
+        emitter.emitArray(node);
     }
-    
+
+    @Override
+    public void visitInt(IMXMLIntNode node)
+    {
+        debug("visitInt()");
+
+        emitter.emitInt(node);
+    }
+
     @Override
     public void visitString(IMXMLStringNode node)
     {
         debug("visitString()");
-        
+
         emitter.emitString(node);
     }
 
     //--------------------------------------------------------------------------
 
+    @Override
+    public void visitLiteral(IMXMLLiteralNode node)
+    {
+        debug("visitLiteral()");
+
+        emitter.emitLiteral(node);
+    }
+
+    //--------------------------------------------------------------------------
+
     protected void debug(String message)
     {
         //System.out.println(message);

Modified: flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/mxml/codegen/MXMLEmitter.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/mxml/codegen/MXMLEmitter.java?rev=1451687&r1=1451686&r2=1451687&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/mxml/codegen/MXMLEmitter.java
(original)
+++ flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/mxml/codegen/MXMLEmitter.java
Fri Mar  1 18:50:19 2013
@@ -27,9 +27,12 @@ import org.apache.flex.compiler.internal
 import org.apache.flex.compiler.mxml.codegen.IMXMLEmitter;
 import org.apache.flex.compiler.projects.ICompilerProject;
 import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLArrayNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLClassDefinitionNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLDeclarationsNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLDocumentNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLInstanceNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLIntNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLLiteralNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLPropertySpecifierNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLScriptNode;
@@ -45,11 +48,13 @@ public class MXMLEmitter extends Emitter
 
     private MXMLBlockWalker walker;
 
+    @Override
     public MXMLBlockWalker getMXMLWalker()
     {
         return walker;
     }
 
+    @Override
     public void setMXMLWalker(MXMLBlockWalker value)
     {
         walker = value;
@@ -62,22 +67,44 @@ public class MXMLEmitter extends Emitter
 
     //--------------------------------------------------------------------------
 
-    public void emitDocumentHeader(IClassDefinition definition)
+    @Override
+    public void emitDocumentHeader(IMXMLDocumentNode node)
     {
-        writeNewline("<" + definition.getBaseName() + ">", true);
+        IClassDefinition cdef = node
+                .getClassReference((ICompilerProject) walker.getProject());
+
+        write("<" + cdef.getBaseName());
+
+        IMXMLPropertySpecifierNode[] pnodes = node.getPropertySpecifierNodes();
+        if (pnodes != null)
+        {
+            for (IMXMLPropertySpecifierNode pnode : pnodes)
+            {
+                if (!pnode.getName().equals("mxmlContentFactory"))
+                    getMXMLWalker().walk(pnode);
+            }
+        }
+
+        write(">");
+        indentPush();
     }
 
-    public void emitDocumentFooter(IClassDefinition definition)
+    @Override
+    public void emitDocumentFooter(IMXMLDocumentNode node)
     {
+        IClassDefinition cdef = node
+                .getClassReference((ICompilerProject) walker.getProject());
+
         writeNewline("", false);
-        write("</" + definition.getBaseName() + ">");
+        write("</" + cdef.getBaseName() + ">");
     }
 
     //--------------------------------------------------------------------------
 
+    @Override
     public void emitClass(IMXMLClassDefinitionNode node)
     {
-        // script traversal
+        // fx:script tag contents
         IMXMLScriptNode[] snodes = node.getScriptNodes();
         if (snodes != null)
         {
@@ -90,17 +117,18 @@ public class MXMLEmitter extends Emitter
             }
         }
 
-        // property specifier traversal
+        // "regular" tags (components)
         IMXMLPropertySpecifierNode[] pnodes = node.getPropertySpecifierNodes();
         if (pnodes != null)
         {
             for (IMXMLPropertySpecifierNode pnode : pnodes)
             {
-                getMXMLWalker().walk(pnode);
+                if (pnode.getName().equals("mxmlContentFactory"))
+                    getMXMLWalker().walk(pnode);
             }
         }
 
-        // node traversal
+        // fx:declarations tag contents
         IMXMLDeclarationsNode[] dnodes = node.getDeclarationsNodes();
         if (dnodes != null)
         {
@@ -113,6 +141,7 @@ public class MXMLEmitter extends Emitter
 
     //--------------------------------------------------------------------------
 
+    @Override
     public void emitInstance(IMXMLInstanceNode node)
     {
         IClassDefinition cdef = node
@@ -121,14 +150,18 @@ public class MXMLEmitter extends Emitter
 
         String cname = cdef.getBaseName();
 
+        writeNewline();
         write("<");
         write(cname);
-        write(ASEmitterTokens.SPACE);
-        write("id");
-        write(ASEmitterTokens.EQUAL);
-        write("\"");
-        write(node.getID());
-        write("\"");
+        if (node.getID() != null && node.getID() != "")
+        {
+            write(ASEmitterTokens.SPACE);
+            write("id");
+            write(ASEmitterTokens.EQUAL);
+            write("\"");
+            write(node.getID());
+            write("\"");
+        }
 
         IMXMLPropertySpecifierNode[] pnodes = node.getPropertySpecifierNodes();
         final int len = pnodes.length;
@@ -141,12 +174,14 @@ public class MXMLEmitter extends Emitter
         }
 
         write(">");
+        // TODO (erikdebruin) we need to parse any children, if present...
         write("<");
         write("/");
         write(cname);
         write(">");
     }
 
+    @Override
     public void emitPropertySpecifier(IMXMLPropertySpecifierNode node)
     {
         boolean isMXMLContentFactory = node.getName().equals(
@@ -164,6 +199,23 @@ public class MXMLEmitter extends Emitter
 
     //--------------------------------------------------------------------------
 
+    @Override
+    public void emitArray(IMXMLArrayNode node)
+    {
+        final int len = node.getChildCount();
+        for (int i = 0; i < len; i++)
+        {
+            getMXMLWalker().walk(node.getChild(i));
+        }
+    }
+
+    @Override
+    public void emitInt(IMXMLIntNode node)
+    {
+        getMXMLWalker().walk(node.getChild(0));
+    }
+
+    @Override
     public void emitString(IMXMLStringNode node)
     {
         write("\"");
@@ -175,6 +227,7 @@ public class MXMLEmitter extends Emitter
 
     //--------------------------------------------------------------------------
 
+    @Override
     public void emitLiteral(IMXMLLiteralNode node)
     {
         write(node.getValue().toString());

Modified: flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/mxml/visitor/MXMLNodeSwitch.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/mxml/visitor/MXMLNodeSwitch.java?rev=1451687&r1=1451686&r2=1451687&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/mxml/visitor/MXMLNodeSwitch.java
(original)
+++ flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/mxml/visitor/MXMLNodeSwitch.java
Fri Mar  1 18:50:19 2013
@@ -20,10 +20,12 @@
 package org.apache.flex.compiler.internal.mxml.visitor;
 
 import org.apache.flex.compiler.tree.as.IASNode;
-import org.apache.flex.compiler.tree.mxml.IMXMLClassDefinitionNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLArrayNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLDeclarationsNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLDeferredInstanceNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLDocumentNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLInstanceNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLIntNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLLiteralNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLPropertySpecifierNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLStringNode;
@@ -32,6 +34,7 @@ import org.apache.flex.compiler.visitor.
 
 /**
  * @author Michael Schmalle
+ * @author Erik de Bruin
  */
 public class MXMLNodeSwitch implements IASNodeStrategy
 {
@@ -47,15 +50,21 @@ public class MXMLNodeSwitch implements I
     {
         switch (node.getNodeID())
         {
-        case MXMLClassDefinitionID:
-            visitor.visitClassDefinition((IMXMLClassDefinitionNode) node);
+        case MXMLArrayID:
+            visitor.visitArray((IMXMLArrayNode) node);
             break;
         case MXMLDeclarationsID:
             visitor.visitDeclarations((IMXMLDeclarationsNode) node);
             break;
+        case MXMLDeferredInstanceID:
+            visitor.visitDeferredInstance((IMXMLDeferredInstanceNode) node);
+            break;
         case MXMLDocumentID:
             visitor.visitDocument((IMXMLDocumentNode) node);
             break;
+        case MXMLIntID:
+            visitor.visitInt((IMXMLIntNode) node);
+            break;
         case MXMLInstanceID:
             visitor.visitInstance((IMXMLInstanceNode) node);
             break;
@@ -68,9 +77,57 @@ public class MXMLNodeSwitch implements I
         case MXMLStringID:
             visitor.visitString((IMXMLStringNode) node);
             break;
-            
+
+        case MXMLApplicationID:
+        case MXMLBindingID:
+        case MXMLBindingAttributeID:
+        case MXMLBooleanID:
+        case MXMLClassID:
+        case MXMLClassDefinitionID:
+        case MXMLClearID:
+        case MXMLComponentID:
+        case MXMLConcatenatedDataBindingID:
+        case MXMLDataBindingID:
+        case MXMLDateID:
+        case MXMLDefinitionID:
+        case MXMLDesignLayerID:
+        case MXMLEmbedID:
+        case MXMLEffectSpecifierID:
+        case MXMLEventSpecifierID:
+        case MXMLFactoryID:
+        case MXMLFileID:
+        case MXMLFunctionID:
+        case MXMLHTTPServiceID:
+        case MXMLHTTPServiceRequestID:
+        case MXMLImplementsID:
+        case MXMLLibraryID:
+        case MXMLMetadataID:
+        case MXMLModelID:
+        case MXMLModelPropertyID:
+        case MXMLModelRootID:
+        case MXMLNumberID:
+        case MXMLObjectID:
+        case MXMLPrivateID:
+        case MXMLRegExpID:
+        case MXMLRemoteObjectID:
+        case MXMLRemoteObjectMethodID:
+        case MXMLReparentID:
+        case MXMLRepeaterID:
+        case MXMLResourceID:
+        case MXMLScriptID:
+        case MXMLStateID:
+        case MXMLStyleID:
+        case MXMLStyleSpecifierID:
+        case MXMLUintID:
+        case MXMLVectorID:
+        case MXMLWebServiceID:
+        case MXMLWebServiceOperationID:
+        case MXMLXMLID:
+        case MXMLXMLListID:
         default:
-            throw new IllegalArgumentException("No handler specified for nodes of type '"
+ node.getNodeID().getParaphrase() + "'");
+            throw new IllegalArgumentException(
+                    "No handler specified for nodes of type '"
+                            + node.getNodeID().getParaphrase() + "'");
         }
     }
 

Modified: flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/mxml/codegen/IMXMLEmitter.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/mxml/codegen/IMXMLEmitter.java?rev=1451687&r1=1451686&r2=1451687&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/mxml/codegen/IMXMLEmitter.java
(original)
+++ flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/mxml/codegen/IMXMLEmitter.java
Fri Mar  1 18:50:19 2013
@@ -22,10 +22,12 @@ package org.apache.flex.compiler.mxml.co
 import java.io.Writer;
 
 import org.apache.flex.compiler.common.codegen.IEmitter;
-import org.apache.flex.compiler.definitions.IClassDefinition;
 import org.apache.flex.compiler.internal.mxml.codegen.MXMLBlockWalker;
+import org.apache.flex.compiler.tree.mxml.IMXMLArrayNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLClassDefinitionNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLDocumentNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLInstanceNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLIntNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLLiteralNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLPropertySpecifierNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLStringNode;
@@ -37,6 +39,7 @@ import org.apache.flex.compiler.visitor.
  * {@link IASNodeStrategy} and the current output buffer {@link Writer}.
  * 
  * @author Michael Schmalle
+ * @author Erik de Bruin
  */
 public interface IMXMLEmitter extends IEmitter
 {
@@ -47,8 +50,9 @@ public interface IMXMLEmitter extends IE
 
     //--------------------------------------------------------------------------
 
-    void emitDocumentHeader(IClassDefinition definition);
-    void emitDocumentFooter(IClassDefinition definition);
+    void emitDocumentHeader(IMXMLDocumentNode node);
+
+    void emitDocumentFooter(IMXMLDocumentNode node);
 
     //--------------------------------------------------------------------------
 
@@ -57,14 +61,19 @@ public interface IMXMLEmitter extends IE
     //--------------------------------------------------------------------------
 
     void emitInstance(IMXMLInstanceNode node);
+
     void emitPropertySpecifier(IMXMLPropertySpecifierNode node);
 
     //--------------------------------------------------------------------------
 
+    void emitArray(IMXMLArrayNode node);
+
+    void emitInt(IMXMLIntNode node);
+
     void emitString(IMXMLStringNode node);
 
     //--------------------------------------------------------------------------
 
     void emitLiteral(IMXMLLiteralNode node);
-    
+
 }

Modified: flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/visitor/IMXMLBlockVisitor.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/visitor/IMXMLBlockVisitor.java?rev=1451687&r1=1451686&r2=1451687&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/visitor/IMXMLBlockVisitor.java
(original)
+++ flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/visitor/IMXMLBlockVisitor.java
Fri Mar  1 18:50:19 2013
@@ -19,12 +19,15 @@
 
 package org.apache.flex.compiler.visitor;
 
+import org.apache.flex.compiler.tree.mxml.IMXMLArrayNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLClassDefinitionNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLDeclarationsNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLDeferredInstanceNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLDocumentNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLEventSpecifierNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLInstanceNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLIntNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLLiteralNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLPropertySpecifierNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLScriptNode;
@@ -33,6 +36,7 @@ import org.apache.flex.compiler.tree.mxm
 
 /**
  * @author Michael Schmalle
+ * @author Erik de Bruin
  */
 public interface IMXMLBlockVisitor
 {
@@ -43,7 +47,11 @@ public interface IMXMLBlockVisitor
     void visitClassDefinition(IMXMLClassDefinitionNode node);
 
     void visitDeclarations(IMXMLDeclarationsNode node);
-    
+
+    //--------------------------------------------------------------------------
+
+    void visitDeferredInstance(IMXMLDeferredInstanceNode node);
+
     //--------------------------------------------------------------------------
 
     void visitPropertySpecifier(IMXMLPropertySpecifierNode node);
@@ -58,10 +66,14 @@ public interface IMXMLBlockVisitor
 
     //--------------------------------------------------------------------------
 
+    void visitArray(IMXMLArrayNode node);
+
+    void visitInt(IMXMLIntNode node);
+
     void visitString(IMXMLStringNode node);
 
     //--------------------------------------------------------------------------
 
     void visitLiteral(IMXMLLiteralNode node);
-    
+
 }



Mime
View raw message