You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ms...@apache.org on 2013/01/21 20:53:42 UTC
svn commit: r1436579 -
/flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java
Author: mschmalle
Date: Mon Jan 21 19:53:42 2013
New Revision: 1436579
URL: http://svn.apache.org/viewvc?rev=1436579&view=rev
Log:
Flex:FalconJx
- Fixed GoogEmitter to work with as or mxml and it's package imports, very proto right now
Modified:
flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/js/codegen/goog/JSGoogEmitter.java
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=1436579&r1=1436578&r2=1436579&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 Mon Jan 21 19:53:42 2013
@@ -22,6 +22,7 @@ package org.apache.flex.compiler.interna
import java.io.FilterWriter;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -34,7 +35,9 @@ import org.apache.flex.compiler.definiti
import org.apache.flex.compiler.definitions.IFunctionDefinition;
import org.apache.flex.compiler.definitions.IPackageDefinition;
import org.apache.flex.compiler.definitions.ITypeDefinition;
+import org.apache.flex.compiler.internal.definitions.ClassDefinition;
import org.apache.flex.compiler.internal.js.codegen.JSEmitter;
+import org.apache.flex.compiler.internal.scopes.PackageScope;
import org.apache.flex.compiler.internal.tree.as.ChainedVariableNode;
import org.apache.flex.compiler.internal.tree.as.FunctionCallNode;
import org.apache.flex.compiler.internal.tree.as.FunctionNode;
@@ -65,6 +68,8 @@ import org.apache.flex.compiler.tree.as.
import org.apache.flex.compiler.tree.as.ITypedExpressionNode;
import org.apache.flex.compiler.tree.as.IVariableNode;
+import com.google.common.collect.Collections2;
+
/**
* Concrete implementation of the 'goog' JavaScript production.
*
@@ -131,13 +136,14 @@ public class JSGoogEmitter extends JSEmi
@Override
public void emitPackageHeaderContents(IPackageDefinition definition)
{
- IASScope containedScope = definition.getContainedScope();
+ PackageScope containedScope = (PackageScope) definition
+ .getContainedScope();
+
ITypeDefinition type = findType(containedScope.getAllLocalDefinitions());
if (type == null)
return;
- ArrayList<String> list = new ArrayList<String>();
- definition.getContainedScope().getScopeNode().getAllImports(list);
+ List<String> list = resolveImports(type);
for (String imp : list)
{
if (imp.indexOf(AS3) != -1)
@@ -895,4 +901,29 @@ public class JSGoogEmitter extends JSEmi
getWalker().walk(node.getRightOperandNode());
}
}
+
+ //--------------------------------------------------------------------------
+ //
+ //--------------------------------------------------------------------------
+
+ private List<String> resolveImports(ITypeDefinition type)
+ {
+ ClassDefinition cdefinition = (ClassDefinition) type;
+ ArrayList<String> list = new ArrayList<String>();
+ IScopedNode scopeNode = type.getContainedScope().getScopeNode();
+ if (scopeNode != null)
+ {
+ scopeNode.getAllImports(list);
+ }
+ else
+ {
+ // MXML
+ String[] implicitImports = cdefinition.getImplicitImports();
+ for (String imp : implicitImports)
+ {
+ list.add(imp);
+ }
+ }
+ return list;
+ }
}