flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joshtynj...@apache.org
Subject git commit: [flex-falcon] [refs/heads/develop] - compiler: only adds dependencies for JSX if [JSX] metadata is specified (in other words, not for E4X)
Date Fri, 11 Nov 2016 00:31:03 GMT
Repository: flex-falcon
Updated Branches:
  refs/heads/develop ca49b5d0a -> b68a09fe3


compiler: only adds dependencies for JSX if [JSX] metadata is specified (in other words, not
for E4X)


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

Branch: refs/heads/develop
Commit: b68a09fe3e4eb4b5a4c6967c2918b1579c46c70d
Parents: ca49b5d
Author: Josh Tynjala <joshtynjala@gmail.com>
Authored: Thu Nov 10 16:30:57 2016 -0800
Committer: Josh Tynjala <joshtynjala@gmail.com>
Committed: Thu Nov 10 16:30:57 2016 -0800

----------------------------------------------------------------------
 .../internal/units/ASCompilationUnit.java       | 32 +++++++++++---------
 .../java/org/apache/flex/utils/JSXUtil.java     | 14 +++++++++
 2 files changed, 31 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b68a09fe/compiler/src/main/java/org/apache/flex/compiler/internal/units/ASCompilationUnit.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/units/ASCompilationUnit.java
b/compiler/src/main/java/org/apache/flex/compiler/internal/units/ASCompilationUnit.java
index 6dc8951..007b793 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/internal/units/ASCompilationUnit.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/internal/units/ASCompilationUnit.java
@@ -30,7 +30,6 @@ import java.util.Set;
 
 import org.apache.flex.compiler.clients.ASC;
 import org.apache.flex.compiler.common.DependencyType;
-import org.apache.flex.compiler.common.IMetaInfo;
 import org.apache.flex.compiler.definitions.IDefinition;
 import org.apache.flex.compiler.filespecs.FileSpecification;
 import org.apache.flex.compiler.filespecs.IFileSpecification;
@@ -52,6 +51,7 @@ import org.apache.flex.compiler.projects.IASProject;
 import org.apache.flex.compiler.scopes.IASScope;
 import org.apache.flex.compiler.tree.as.IASNode;
 import org.apache.flex.compiler.tree.as.IFileNodeAccumulator;
+import org.apache.flex.compiler.tree.as.IFunctionNode;
 import org.apache.flex.compiler.units.ICompilationUnit;
 import org.apache.flex.compiler.units.requests.IABCBytesRequestResult;
 import org.apache.flex.compiler.units.requests.IFileScopeRequestResult;
@@ -497,27 +497,29 @@ public class ASCompilationUnit extends CompilationUnitBase
         if (node instanceof FunctionNode)
         {
             FunctionNode functionNode = (FunctionNode) node;
-            for (IMetaInfo metaInfo : functionNode.getMetaInfos())
+            if (JSXUtil.hasJSXMetadata(functionNode))
             {
-                if (metaInfo.getTagName().equals("JSX"))
-                {
-                    //we need to parse XML in this function's body
-                    functionNode.parseFunctionBody(new ArrayList<ICompilerProblem>());
-                }
+                //we need to parse XML in this function's body
+                functionNode.parseFunctionBody(new ArrayList<ICompilerProblem>());
             }
         }
         if (node instanceof XMLLiteralNode)
         {
-            XMLLiteralNode xmlNode = (XMLLiteralNode) node;
-            CompilerProject project = getProject();
-            ArrayList<String> qualifiedNames = new ArrayList<String>();
-            JSXUtil.findQualifiedNamesInXMLLiteral(xmlNode, qualifiedNames);
-            for (String qualifiedName : qualifiedNames)
+            IFunctionNode functionNode = (IFunctionNode) node.getAncestorOfType(IFunctionNode.class);
+            if (functionNode != null && JSXUtil.hasJSXMetadata(functionNode))
             {
-                ICompilationUnit cu = project.resolveQNameToCompilationUnit(qualifiedName);
-                if (cu != null)
+                System.out.println(functionNode.getQualifiedName());
+                XMLLiteralNode xmlNode = (XMLLiteralNode) node;
+                CompilerProject project = getProject();
+                ArrayList<String> qualifiedNames = new ArrayList<String>();
+                JSXUtil.findQualifiedNamesInXMLLiteral(xmlNode, qualifiedNames);
+                for (String qualifiedName : qualifiedNames)
                 {
-                    project.addDependency(this, cu, DependencyType.EXPRESSION, cu.getQualifiedNames().get(0));
+                    ICompilationUnit cu = project.resolveQNameToCompilationUnit(qualifiedName);
+                    if (cu != null)
+                    {
+                        project.addDependency(this, cu, DependencyType.EXPRESSION, cu.getQualifiedNames().get(0));
+                    }
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b68a09fe/compiler/src/main/java/org/apache/flex/utils/JSXUtil.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/utils/JSXUtil.java b/compiler/src/main/java/org/apache/flex/utils/JSXUtil.java
index 0e8940f..4dfbbba 100644
--- a/compiler/src/main/java/org/apache/flex/utils/JSXUtil.java
+++ b/compiler/src/main/java/org/apache/flex/utils/JSXUtil.java
@@ -22,9 +22,11 @@ package org.apache.flex.utils;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.flex.compiler.common.IMetaInfo;
 import org.apache.flex.compiler.common.Multiname;
 import org.apache.flex.compiler.internal.tree.as.XMLLiteralNode;
 import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.as.IFunctionNode;
 import org.apache.flex.compiler.tree.as.IImportNode;
 import org.apache.flex.compiler.tree.as.ILiteralNode;
 import org.apache.flex.compiler.tree.as.IScopedNode;
@@ -34,6 +36,18 @@ import org.apache.flex.compiler.tree.as.IScopedNode;
  */
 public class JSXUtil
 {
+    public static boolean hasJSXMetadata(IFunctionNode node)
+    {
+        for (IMetaInfo metaInfo : node.getMetaInfos())
+        {
+            if (metaInfo.getTagName().equals("JSX"))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
     public static void findQualifiedNamesInXMLLiteral(XMLLiteralNode node, List<String>
qualifiedNames)
     {
         int childCount = node.getContentsNode().getChildCount();


Mime
View raw message