Josh, does this commit resolve https://issues.apache.org/jira/browse/FLEX-35004 ?
On Tue, Jan 12, 2016 at 11:24 AM, Alex Harui <aha...@adobe.com> wrote: > I haven't done thorough research, but I think this change is causing the > last remaining failure in the Falcon build. The failing case is > org.apache.flex.compiler.internal.codegen.js.vf2js.TestVF2JSFile.testVersio > n in compiler.jx.tests. The test case is dealing with an variable defined > in an included file which has means the parent of the variable node will > be a file node and look a lot like a file-level definition when it isn't. > > -Alex > > On 1/11/16, 11:54 AM, "joshtynj...@apache.org" <joshtynj...@apache.org> > wrote: > > >compiler.jx: added support for functions and variables in packages, and > >functions and variables after package (similar to internal classes) > > > > > >Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo > >Commit: > http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/56060782 > >Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/56060782 > >Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/56060782 > > > >Branch: refs/heads/develop > >Commit: 5606078243b62fd965bf83f6e39993140d01de76 > >Parents: 8a7bdc6 > >Author: Josh Tynjala <joshtynj...@apache.org> > >Authored: Mon Jan 11 11:54:37 2016 -0800 > >Committer: Josh Tynjala <joshtynj...@apache.org> > >Committed: Mon Jan 11 11:54:37 2016 -0800 > > > >---------------------------------------------------------------------- > > .../internal/codegen/as/ASBlockWalker.java | 20 ++++++------ > > .../codegen/js/flexjs/JSFlexJSEmitter.java | 10 ++++++ > > .../codegen/js/jx/PackageHeaderEmitter.java | 33 ++++++++++++++++++-- > > 3 files changed, 49 insertions(+), 14 deletions(-) > >---------------------------------------------------------------------- > > > > > >http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/56060782/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/ASBlockWalk > >er.java > >b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBlockWalk > >er.java > >index fec44cc..b405bb0 100644 > >--- > >a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBlockWalk > >er.java > >+++ > >b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBlockWalk > >er.java > >@@ -190,7 +190,9 @@ public class ASBlockWalker implements > >IASBlockVisitor, IASBlockWalker > > if (pnode != null && > > (pnode instanceof IPackageNode || > > pnode instanceof IInterfaceNode || > >- pnode instanceof IClassNode)) > >+ pnode instanceof IClassNode || > >+ pnode instanceof IFunctionNode || > >+ pnode instanceof IVariableNode)) > > { > > walk(pnode); > > > >@@ -238,11 +240,9 @@ public class ASBlockWalker implements > >IASBlockVisitor, IASBlockWalker > > public void visitVariable(IVariableNode node) > > { > > debug("visitVariable()"); > >- if (SemanticUtils.isPackageDefinition(node.getDefinition())) > >- { > >- //TODO: emit package-level variable > >- } > >- else if (SemanticUtils.isMemberDefinition(node.getDefinition())) > >+ if (SemanticUtils.isPackageDefinition(node.getDefinition()) || > >+ SemanticUtils.isMemberDefinition(node.getDefinition()) || > >+ node.getParent() instanceof IFileNode) > > { > > emitter.emitField(node); > > } > >@@ -256,11 +256,9 @@ public class ASBlockWalker implements > >IASBlockVisitor, IASBlockWalker > > public void visitFunction(IFunctionNode node) > > { > > debug("visitFunction()"); > >- if (SemanticUtils.isPackageDefinition(node.getDefinition())) > >- { > >- //TODO: emit package-level function > >- } > >- else if > >(DefinitionUtils.isMemberDefinition(node.getDefinition())) > >+ if (SemanticUtils.isPackageDefinition(node.getDefinition()) || > >+ DefinitionUtils.isMemberDefinition(node.getDefinition()) || > >+ node.getParent() instanceof IFileNode) > > { > > emitter.emitMethod(node); > > } > > > >http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/56060782/compiler > . > >jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter > >.java > >---------------------------------------------------------------------- > >diff --git > >a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFl > >exJSEmitter.java > >b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFl > >exJSEmitter.java > >index a101a4c..1de63fe 100644 > >--- > >a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFl > >exJSEmitter.java > >+++ > >b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFl > >exJSEmitter.java > >@@ -342,6 +342,16 @@ public class JSFlexJSEmitter extends JSGoogEmitter > >implements IJSFlexJSEmitter > > String className = > ((IInterfaceNode)pnode).getQualifiedName(); > > getModel().getInternalClasses().put(className, > mainClassName + > >"." + className); > > } > >+ else if (pnode instanceof IFunctionNode) > >+ { > >+ String className = > >((IFunctionNode)pnode).getQualifiedName(); > >+ getModel().getInternalClasses().put(className, > >mainClassName + "." + className); > >+ } > >+ else if (pnode instanceof IVariableNode) > >+ { > >+ String className = > >((IVariableNode)pnode).getQualifiedName(); > >+ getModel().getInternalClasses().put(className, > >mainClassName + "." + className); > >+ } > > } > > > > packageHeaderEmitter.emit(definition); > > > >http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/56060782/compiler > . > >jx/src/org/apache/flex/compiler/internal/codegen/js/jx/PackageHeaderEmitte > >r.java > >---------------------------------------------------------------------- > >diff --git > >a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/PackageH > >eaderEmitter.java > >b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/PackageH > >eaderEmitter.java > >index d0e161b..21d3c01 100644 > >--- > >a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/PackageH > >eaderEmitter.java > >+++ > >b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/PackageH > >eaderEmitter.java > >@@ -27,8 +27,10 @@ import java.util.List; > > import org.apache.flex.compiler.asdoc.flexjs.ASDocComment; > > import org.apache.flex.compiler.codegen.ISubEmitter; > > import org.apache.flex.compiler.codegen.js.IJSEmitter; > >+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.definitions.IVariableDefinition; > > import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens; > > import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter; > > import > >org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter; > >@@ -61,8 +63,33 @@ public class PackageHeaderEmitter extends JSSubEmitter > >implements > > IASScope containedScope = definition.getContainedScope(); > > ITypeDefinition type = EmitterUtils.findType(containedScope > > .getAllLocalDefinitions()); > >- if (type == null) > >+ String qname = null; > >+ if (type != null) > >+ { > >+ qname = type.getQualifiedName(); > >+ } > >+ if (qname == null) > >+ { > >+ IFunctionDefinition fn = > >EmitterUtils.findFunction(containedScope > >+ .getAllLocalDefinitions()); > >+ if(fn != null) > >+ { > >+ qname = fn.getQualifiedName(); > >+ } > >+ } > >+ if (qname == null) > >+ { > >+ IVariableDefinition variable = > >EmitterUtils.findVariable(containedScope > >+ .getAllLocalDefinitions()); > >+ if(variable != null) > >+ { > >+ qname = variable.getQualifiedName(); > >+ } > >+ } > >+ if (qname == null) > >+ { > > return; > >+ } > > > > FlexJSProject project = (FlexJSProject) getProject(); > > List<File> sourcePaths = project.getSourcePath(); > >@@ -77,7 +104,7 @@ public class PackageHeaderEmitter extends JSSubEmitter > >implements > > > > writeNewline("/**"); > > writeNewline(" * Generated by Apache Flex Cross-Compiler from " > >+ sourceName); > >- writeNewline(" * " + type.getQualifiedName()); > >+ writeNewline(" * " + qname); > > writeNewline(" *"); > > writeNewline(" * @fileoverview"); > > writeNewline(" *"); > >@@ -91,7 +118,7 @@ public class PackageHeaderEmitter extends JSSubEmitter > >implements > > write(JSGoogEmitterTokens.GOOG_PROVIDE); > > write(ASEmitterTokens.PAREN_OPEN); > > write(ASEmitterTokens.SINGLE_QUOTE); > >- write(getEmitter().formatQualifiedName(type.getQualifiedName())); > >+ write(getEmitter().formatQualifiedName(qname)); > > write(ASEmitterTokens.SINGLE_QUOTE); > > write(ASEmitterTokens.PAREN_CLOSE); > > writeNewline(ASEmitterTokens.SEMICOLON); > > > >