Add support for additional 'root' nodes in a file, e.g. helper classes

Signed-off-by: Erik de Bruin <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/9e5c1172
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/9e5c1172
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/9e5c1172

Branch: refs/heads/develop
Commit: 9e5c117242b60dd797d5eb43546221e8e9829393
Parents: 86f0644
Author: Erik de Bruin <[email protected]>
Authored: Fri Oct 31 17:20:27 2014 +0100
Committer: Erik de Bruin <[email protected]>
Committed: Fri Oct 31 17:44:03 2014 +0100

----------------------------------------------------------------------
 .../internal/codegen/as/ASBlockWalker.java      | 28 +++++++++++++++-----
 1 file changed, 21 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9e5c1172/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBlockWalker.java
----------------------------------------------------------------------
diff --git 
a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBlockWalker.java
 
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBlockWalker.java
index 293d8e8..dc1763a 100644
--- 
a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBlockWalker.java
+++ 
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBlockWalker.java
@@ -178,14 +178,28 @@ public class ASBlockWalker implements IASBlockVisitor, 
IASBlockWalker
     public void visitFile(IFileNode node)
     {
         debug("visitFile()");
-        IASNode pnode = node.getChild(0);
-        if (pnode != null)
+        
+        int nodeCount = node.getChildCount();
+        for (int i = 0; i < nodeCount; i++)
         {
-            walk(pnode); // IPackageNode
-        }
-        else
-        {
-
+               IASNode pnode = node.getChild(i);
+               
+               // ToDo (erikdebruin): handle other types of root node, such as 
when
+               //                     there is no wrapping Package or Class, 
like
+               //                     in mx.core.Version
+               if (pnode != null && 
+                       (pnode instanceof IPackageNode || 
+                        pnode instanceof IClassNode))
+               {
+                   walk(pnode);
+                   
+                       if (i < nodeCount - 1)
+                       {
+                               emitter.writeNewline();
+                               emitter.writeNewline();
+                               emitter.writeNewline();
+                       }
+               }
         }
     }
 

Reply via email to