flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [1/2] git commit: [flex-falcon] [refs/heads/develop] - changes to generate info() structure on main class
Date Tue, 12 Apr 2016 05:11:32 GMT
Repository: flex-falcon
Updated Branches:
  refs/heads/develop 2135f681d -> b113ff96c


changes to generate info() structure on main class


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

Branch: refs/heads/develop
Commit: 272be3df34d07ddb131e8d394c39f492ce593e06
Parents: 2135f68
Author: Alex Harui <aharui@apache.org>
Authored: Mon Apr 11 21:49:41 2016 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Mon Apr 11 21:49:41 2016 -0700

----------------------------------------------------------------------
 .../apache/flex/compiler/clients/MXMLJSC.java   |  6 ++-
 .../codegen/js/flexjs/JSFlexJSEmitter.java      |  3 ++
 .../codegen/mxml/flexjs/MXMLFlexJSEmitter.java  | 50 +++++++++++++++++++-
 .../flex/compiler/internal/targets/Target.java  |  2 +-
 .../apache/flex/compiler/targets/ITarget.java   |  9 ++++
 5 files changed, 67 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/272be3df/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java b/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
index 98cd4d2..3ca2f03 100644
--- a/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
@@ -434,7 +434,11 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider,
 
                 File outputFolder = jsPublisher.getOutputFolder();
 
-                List<ICompilationUnit> reachableCompilationUnits = project.getReachableCompilationUnitsInSWFOrder(ImmutableSet.of(mainCU));
+                ArrayList<ICompilationUnit> roots = new ArrayList<ICompilationUnit>();
+                roots.add(mainCU);
+                Set<ICompilationUnit> incs = target.getIncludesCompilationUnits();
+                roots.addAll(incs);
+                List<ICompilationUnit> reachableCompilationUnits = project.getReachableCompilationUnitsInSWFOrder(roots);
                 for (final ICompilationUnit cu : reachableCompilationUnits)
                 {
                     ICompilationUnit.UnitType cuType = cu.getCompilationUnitType();

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/272be3df/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/JSFlexJSEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
index f23f83a..bfc3bfe 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
@@ -22,6 +22,7 @@ package org.apache.flex.compiler.internal.codegen.js.flexjs;
 import java.io.FilterWriter;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.flex.compiler.codegen.js.flexjs.IJSFlexJSEmitter;
 import org.apache.flex.compiler.codegen.js.goog.IJSGoogDocEmitter;
@@ -31,6 +32,7 @@ import org.apache.flex.compiler.definitions.IDefinition;
 import org.apache.flex.compiler.definitions.IPackageDefinition;
 import org.apache.flex.compiler.definitions.ITypeDefinition;
 import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSEmitterTokens;
 import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitter;
 import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
 import org.apache.flex.compiler.internal.codegen.js.jx.AccessorEmitter;
@@ -249,6 +251,7 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
     		}
     		finalLines.add(line);
     	}
+    	
     	return Joiner.on("\n").join(finalLines);
     }
     

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/272be3df/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
index dde558f..094f5c7 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
@@ -161,6 +161,7 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
         boolean foundXML = false;
     	String[] lines = output.split("\n");
     	ArrayList<String> finalLines = new ArrayList<String>();
+    	int endRequires = -1;
     	boolean sawRequires = false;
     	boolean stillSearching = true;
     	for (String line : lines)
@@ -181,7 +182,10 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
 	    				continue;
 	    		}
 	    		else if (sawRequires)
+	    		{
 	    			stillSearching = false;
+	    			endRequires = finalLines.size();
+	    		}
     		}
     		finalLines.add(line);
     	}
@@ -196,9 +200,53 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
             appendString.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
             appendString.append(ASEmitterTokens.PAREN_CLOSE.getToken());
             appendString.append(ASEmitterTokens.SEMICOLON.getToken());
-            finalLines.add(appendString.toString());
+            finalLines.add(endRequires, appendString.toString());
             // TODO (aharui) addLineToMappings(finalLines.size());
         }
+    	// append info() structure if main CU
+        ICompilerProject project = getMXMLWalker().getProject();
+        if (project instanceof FlexJSProject)
+        {
+            FlexJSProject flexJSProject = (FlexJSProject) project;
+            String mainDef = null;
+			try {
+				mainDef = flexJSProject.mainCU.getQualifiedNames().get(0);
+			} catch (InterruptedException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+            String thisDef = documentDefinition.getQualifiedName();
+            if (mainDef != null && mainDef.equals(thisDef))
+            {
+            	Set<String> mixins = flexJSProject.config.getIncludes();
+            	if (mixins.size() > 0)
+            	{
+	            	String infoInject = "\n\n" + thisDef + ".prototype.info = function() {\n" +
+	            						"  return { mixins: [";
+	            	boolean firstOne = true;
+	            	for (String mixin : mixins)
+	            	{
+	            		if (!firstOne)
+	            			infoInject += ", "; 
+	            		infoInject += mixin;
+	            		firstOne = false;
+	                    StringBuilder appendString = new StringBuilder();
+	                    appendString.append(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
+	                    appendString.append(ASEmitterTokens.PAREN_OPEN.getToken());
+	                    appendString.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
+	                    appendString.append(mixin);
+	                    appendString.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
+	                    appendString.append(ASEmitterTokens.PAREN_CLOSE.getToken());
+	                    appendString.append(ASEmitterTokens.SEMICOLON.getToken());
+                        finalLines.add(endRequires, appendString.toString());
+                        //addLineToMappings(finalLines.size());
+	            	}
+	            	infoInject += "]}};";
+                    finalLines.add(infoInject);
+                    //addLineToMappings(finalLines.size());	            	
+            	}
+            }
+        }
     	return Joiner.on("\n").join(finalLines);
     }
     

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/272be3df/compiler/src/org/apache/flex/compiler/internal/targets/Target.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/targets/Target.java b/compiler/src/org/apache/flex/compiler/internal/targets/Target.java
index 0f3a578..cd5a62e 100644
--- a/compiler/src/org/apache/flex/compiler/internal/targets/Target.java
+++ b/compiler/src/org/apache/flex/compiler/internal/targets/Target.java
@@ -444,7 +444,7 @@ public abstract class Target implements ITarget
      * @return a set of {@link ICompilationUnit}s that are included into the
      * build process by -include-classes compiler argument.
      */
-    protected final Set<ICompilationUnit> getIncludesCompilationUnits() throws InterruptedException
+    public final Set<ICompilationUnit> getIncludesCompilationUnits() throws InterruptedException
     {
         Workspace workspace = project.getWorkspace();
         Set<IResolvedQualifiersReference> includesReferences = new HashSet<IResolvedQualifiersReference>();

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/272be3df/compiler/src/org/apache/flex/compiler/targets/ITarget.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/targets/ITarget.java b/compiler/src/org/apache/flex/compiler/targets/ITarget.java
index 3ccaba9..485a59d 100644
--- a/compiler/src/org/apache/flex/compiler/targets/ITarget.java
+++ b/compiler/src/org/apache/flex/compiler/targets/ITarget.java
@@ -21,6 +21,8 @@ package org.apache.flex.compiler.targets;
 
 import java.util.Set;
 
+import org.apache.flex.compiler.units.ICompilationUnit;
+
 /**
  * An ITarget is a promise to build a particular output from the
  * CompilationUnits in an IProject. All ITargets are capable of traversing the
@@ -75,6 +77,13 @@ public interface ITarget
     ITargetSettings getTargetSettings();
 
     /**
+     * Returns mixins.
+     * 
+     * @return settings for this target
+     */
+    Set<ICompilationUnit> getIncludesCompilationUnits() throws InterruptedException;
+
+    /**
      * Returns a report specific to this target.  If the target has been created
      * but not built before getTargetReport() has been called, this method will
      * return null.  If the Target could not be built, null will be returned.


Mime
View raw message