flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erikdebr...@apache.org
Subject svn commit: r1446075 - in /flex/falcon/trunk: compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/ compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/
Date Thu, 14 Feb 2013 09:06:43 GMT
Author: erikdebruin
Date: Thu Feb 14 09:06:42 2013
New Revision: 1446075

URL: http://svn.apache.org/r1446075
Log:
Fixed issue where two 'goog.base()' calls were emitted if the constructor contains a 'super()'
call with an argument.
Fixed issue where constructor annotation missed 'param' references.

Modified:
    flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogFile.java
    flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogDocEmitter.java
    flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java

Modified: flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogFile.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogFile.java?rev=1446075&r1=1446074&r2=1446075&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogFile.java
(original)
+++ flex/falcon/trunk/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogFile.java
Thu Feb 14 09:06:42 2013
@@ -25,7 +25,6 @@ import org.apache.flex.compiler.clients.
 import org.apache.flex.compiler.internal.as.codegen.TestWalkerBase;
 import org.apache.flex.compiler.internal.js.driver.goog.GoogBackend;
 import org.apache.flex.compiler.tree.as.IFileNode;
-import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -56,11 +55,9 @@ public class TestGoogFile extends TestWa
                 + File.separator + "files"));
     }
 
-    @Ignore
     @Test
     public void testFile_callsuper()
     {
-        // TODO (erikdebruin) handle various constructor super call edge cases first
         IFileNode node = getFileNode("call-super", true, "goog"
                 + File.separator + "files");
         visitor.visitFile(node);

Modified: flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogDocEmitter.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogDocEmitter.java?rev=1446075&r1=1446074&r2=1446075&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogDocEmitter.java
(original)
+++ flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogDocEmitter.java
Thu Feb 14 09:06:42 2013
@@ -114,8 +114,6 @@ public class JSGoogDocEmitter extends JS
 
             if (node.isConstructor())
             {
-                // TODO (erikdebruin) handle JSDOC for constructors with arguments
-
                 begin();
                 hasDoc = true;
 
@@ -140,15 +138,6 @@ public class JSGoogDocEmitter extends JS
                                     DependencyType.INHERITANCE, true);
                     emitImplements(type, type.getPackageName());
                 }
-
-                //                IExpressionNode[] inodes = cnode.getImplementedInterfaceNodes();
-                //                if (inodes.length > 0)
-                //                {
-                //                    for (IExpressionNode inode : inodes)
-                //                    {
-                //                        emitImplements(inode.resolveType(project));
-                //                    }
-                //                }
             }
             else
             {
@@ -160,22 +149,25 @@ public class JSGoogDocEmitter extends JS
 
                     emitThis(classDefinition, classDefinition.getPackageName());
                 }
+            }
 
-                // @param
-                IParameterNode[] parameters = node.getParameterNodes();
-                for (IParameterNode pnode : parameters)
+            // @param
+            IParameterNode[] parameters = node.getParameterNodes();
+            for (IParameterNode pnode : parameters)
+            {
+                if (!hasDoc)
                 {
-                    if (!hasDoc)
-                    {
-                        begin();
-                        hasDoc = true;
-                    }
-
-                    IExpressionNode enode = pnode.getNameExpressionNode();
-                    emitParam(pnode, enode.resolveType(project)
-                            .getPackageName());
+                    begin();
+                    hasDoc = true;
                 }
 
+                IExpressionNode enode = pnode.getNameExpressionNode();
+                emitParam(pnode, enode.resolveType(project)
+                        .getPackageName());
+            }
+
+            if (!node.isConstructor())
+            {
                 // @return
                 String returnType = node.getReturnType();
                 if (returnType != ""

Modified: flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java?rev=1446075&r1=1446074&r2=1446075&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java
(original)
+++ flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java
Thu Feb 14 09:06:42 2013
@@ -459,7 +459,6 @@ public class JSGoogEmitter extends JSEmi
 
         if (isConstructor && hasSuperClass)
         {
-            /* \ngoog.inherits(x, y) */
             writeNewline();
             write(GOOG_INHERITS);
             write(PARENTHESES_OPEN);
@@ -580,7 +579,7 @@ public class JSGoogEmitter extends JSEmi
         if (hasBody(node))
             emitSelfReference(node);
 
-        if (node.isConstructor() && hasSuperClass(node))
+        if (node.isConstructor() && hasSuperClass(node) && !hasSuperCall(node.getScopedNode()))
             emitSuperCall(node, CONSTRUCTOR_FULL);
 
         emitRestParameterCodeBlock(node);
@@ -896,6 +895,19 @@ public class JSGoogEmitter extends JSEmi
                 && !qname.equals(IASLanguageConstants.Object);
     }
 
+    private boolean hasSuperCall(IScopedNode node)
+    {
+        for (int i = node.getChildCount() - 1; i > -1; i--)
+        {
+            IASNode cnode = node.getChild(i);
+            if (cnode.getNodeID() == ASTNodeID.FunctionCallID
+                    && cnode.getChild(0).getNodeID() == ASTNodeID.SuperID)
+                return true;
+        }
+        
+        return false;
+    }
+    
     private static boolean hasBody(IFunctionNode node)
     {
         IScopedNode scope = node.getScopedNode();



Mime
View raw message