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: JSXUtil uses findProperty to resolve JSX tags to anything in scope instead of only imports (to allow other types in the same package and even local functions and things)
Date Fri, 11 Nov 2016 16:41:00 GMT
Repository: flex-falcon
Updated Branches:
  refs/heads/develop 494693b7f -> f9b55ee98


compiler: JSXUtil uses findProperty to resolve JSX tags to anything in scope instead of only
imports (to allow other types in the same package and even local functions and things)


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

Branch: refs/heads/develop
Commit: f9b55ee98c9d89fd68523938a5867e489d9cc122
Parents: 494693b
Author: Josh Tynjala <joshtynjala@gmail.com>
Authored: Fri Nov 11 08:28:36 2016 -0800
Committer: Josh Tynjala <joshtynjala@gmail.com>
Committed: Fri Nov 11 08:28:36 2016 -0800

----------------------------------------------------------------------
 .../internal/codegen/js/jx/LiteralEmitter.java  |  2 +-
 .../internal/units/ASCompilationUnit.java       |  2 +-
 .../java/org/apache/flex/utils/JSXUtil.java     | 42 ++++++++------------
 3 files changed, 19 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/f9b55ee9/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/LiteralEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/LiteralEmitter.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/LiteralEmitter.java
index 58b3f07..2354d95 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/LiteralEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/LiteralEmitter.java
@@ -433,7 +433,7 @@ public class LiteralEmitter extends JSSubEmitter implements
 
     private String getElementNameToEmit(String elementName, IASNode node)
     {
-        String qualifiedTypeName = JSXUtil.getQualifiedTypeForElementName(elementName, node);
+        String qualifiedTypeName = JSXUtil.getQualifiedTypeForElementName(elementName, node,
getProject());
         if (qualifiedTypeName != null)
         {
             return getEmitter().formatQualifiedName(qualifiedTypeName);

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/f9b55ee9/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 906b241..0d27e68 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
@@ -511,7 +511,7 @@ public class ASCompilationUnit extends CompilationUnitBase
                 XMLLiteralNode xmlNode = (XMLLiteralNode) node;
                 CompilerProject project = getProject();
                 ArrayList<String> qualifiedNames = new ArrayList<String>();
-                JSXUtil.findQualifiedNamesInXMLLiteral(xmlNode, qualifiedNames);
+                JSXUtil.findQualifiedNamesInXMLLiteral(xmlNode, project, qualifiedNames);
                 for (String qualifiedName : qualifiedNames)
                 {
                     ICompilationUnit cu = project.resolveQNameToCompilationUnit(qualifiedName);

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/f9b55ee9/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 66c7393..e2a13aa 100644
--- a/compiler/src/main/java/org/apache/flex/utils/JSXUtil.java
+++ b/compiler/src/main/java/org/apache/flex/utils/JSXUtil.java
@@ -19,15 +19,17 @@
 
 package org.apache.flex.utils;
 
-import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.flex.compiler.common.DependencyType;
 import org.apache.flex.compiler.common.IMetaInfo;
-import org.apache.flex.compiler.common.Multiname;
+import org.apache.flex.compiler.definitions.IDefinition;
+import org.apache.flex.compiler.internal.scopes.ASScope;
 import org.apache.flex.compiler.internal.tree.as.XMLLiteralNode;
+import org.apache.flex.compiler.projects.ICompilerProject;
+import org.apache.flex.compiler.scopes.IASScope;
 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;
 
@@ -48,7 +50,7 @@ public class JSXUtil
         return false;
     }
 
-    public static void findQualifiedNamesInXMLLiteral(XMLLiteralNode node, List<String>
qualifiedNames)
+    public static void findQualifiedNamesInXMLLiteral(XMLLiteralNode node, ICompilerProject
project, List<String> qualifiedNames)
     {
         int childCount = node.getContentsNode().getChildCount();
         for (int i = 0; i < childCount; i++)
@@ -59,13 +61,13 @@ public class JSXUtil
                 ILiteralNode literalChild = (ILiteralNode) child;
                 if (literalChild.getLiteralType() == ILiteralNode.LiteralType.XML)
                 {
-                    findQualifiedNamesInXMLLiteralChild(literalChild, qualifiedNames);
+                    findQualifiedNamesInXMLLiteralChild(literalChild, project, qualifiedNames);
                 }
             }
         }
     }
-    
-    private static void findQualifiedNamesInXMLLiteralChild(ILiteralNode node, List<String>
qualifiedNames)
+
+    private static void findQualifiedNamesInXMLLiteralChild(ILiteralNode node, ICompilerProject
project, List<String> qualifiedNames)
     {
         String value = node.getValue();
         while (true)
@@ -105,7 +107,7 @@ public class JSXUtil
             //ignore end tags
             if (!elementName.startsWith("/"))
             {
-                String qualifiedElementName = getQualifiedTypeForElementName(elementName,
node);
+                String qualifiedElementName = getQualifiedTypeForElementName(elementName,
node, project);
                 if (qualifiedElementName != null)
                 {
                     qualifiedNames.add(qualifiedElementName);
@@ -119,7 +121,7 @@ public class JSXUtil
      * Finds the qualified type name for an <element> in JSX. Returns null if
      * the element name is a basic HTML tag.
      */
-    public static String getQualifiedTypeForElementName(String elementName, IASNode node)
+    public static String getQualifiedTypeForElementName(String elementName, IASNode node,
ICompilerProject project)
     {
         String firstChar = elementName.substring(0, 1);
         boolean isHTMLTag = firstChar.toLowerCase().equals(firstChar);
@@ -127,25 +129,15 @@ public class JSXUtil
         {
             return null;
         }
-        ArrayList<IImportNode> importNodes = new ArrayList<IImportNode>();
         IScopedNode scopedNode = node.getContainingScope();
-        scopedNode.getAllImportNodes(importNodes);
-        for (IImportNode importNode : importNodes)
+        IASScope scope = scopedNode.getScope();
+        if (scope instanceof ASScope)
         {
-            if (importNode.isWildcardImport())
-            {
-                continue;
-            }
-            String importName = importNode.getImportName();
-            String importAlias = importNode.getImportAlias();
-            if (importAlias != null && importAlias.equals(elementName))
-            {
-                return importName;
-            }
-            String baseName = Multiname.getBaseNameForQName(importName);
-            if (baseName.equals(elementName))
+            ASScope asScope = (ASScope) scope;
+            IDefinition definition = asScope.findProperty(project, elementName, DependencyType.EXPRESSION);
+            if (definition != null)
             {
-                return importName;
+                return definition.getQualifiedName();
             }
         }
         return elementName;


Mime
View raw message