flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joshtynj...@apache.org
Subject [03/33] git commit: [flex-falcon] [refs/heads/develop] - moved the code that added the goog.require() call for Language into the emitter post process step. the source map needs to be updated when this is added, so it should happen in the emitter.
Date Tue, 05 Apr 2016 23:56:21 GMT
moved the code that added the goog.require() call for Language into the emitter post process
step. the source map needs to be updated when this is added, so it should happen in the emitter.


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

Branch: refs/heads/develop
Commit: f4af8405f2163b81d44c78a83f6554808905806d
Parents: c975160
Author: Josh Tynjala <joshtynjala@apache.org>
Authored: Wed Mar 23 18:54:33 2016 -0700
Committer: Josh Tynjala <joshtynjala@apache.org>
Committed: Wed Mar 23 18:54:33 2016 -0700

----------------------------------------------------------------------
 .../codegen/js/flexjs/JSFlexJSEmitter.java      | 31 +++++++++++++++++++-
 .../mxml/flexjs/MXMLFlexJSPublisher.java        | 28 ------------------
 2 files changed, 30 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/f4af8405/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 a907ea7..ee18337 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
@@ -140,6 +140,7 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
         
     	String[] lines = output.split("\n");
     	ArrayList<String> finalLines = new ArrayList<String>();
+        boolean foundLanguage = false;
     	boolean sawRequires = false;
     	boolean stillSearching = true;
     	for (String line : lines)
@@ -151,12 +152,40 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
 	            {
 	                int c2 = line.indexOf(")");
 	                String s = line.substring(c + 14, c2 - 1);
+                    if(s.equals(JSFlexJSEmitterTokens.LANGUAGE_QNAME.getToken()))
+                    {
+                        foundLanguage = true;
+                    }
 	    			sawRequires = true;
 	    			if (!usedNames.contains(s))
                         continue;
 	    		}
 	    		else if (sawRequires)
-	    			stillSearching = false;
+                {
+                    stillSearching = false;
+
+                    //when we emitted the requires based on the imports, we may
+                    //not have known if Language was needed yet because the
+                    //imports are at the beginning of the file. other code,
+                    //later in the file, may require Language. 
+                    ICompilerProject project = getWalker().getProject();
+                    if (project instanceof FlexJSProject)
+                    {
+                        boolean needLanguage = ((FlexJSProject) project).needLanguage;
+                        if(needLanguage && !foundLanguage)
+                        {
+                            StringBuilder appendString = new StringBuilder();
+                            appendString.append(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
+                            appendString.append(ASEmitterTokens.PAREN_OPEN.getToken());
+                            appendString.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
+                            appendString.append(JSFlexJSEmitterTokens.LANGUAGE_QNAME.getToken());
+                            appendString.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
+                            appendString.append(ASEmitterTokens.PAREN_CLOSE.getToken());
+                            appendString.append(ASEmitterTokens.SEMICOLON.getToken());
+                            finalLines.add(appendString.toString());
+                        }
+                    }
+                }
     		}
     		finalLines.add(line);
     	}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/f4af8405/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
index 2964250..347e01c 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
@@ -278,7 +278,6 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements IJSPublisher
 
         appendExportSymbol(projectIntermediateJSFilePath, projectName);
         appendEncodedCSS(projectIntermediateJSFilePath, projectName);
-        appendLanguage(projectIntermediateJSFilePath, projectName);
 
         // if (!subsetGoog)
         // {
@@ -526,33 +525,6 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements IJSPublisher
         }
     }
 
-    private void appendLanguage(String path, String projectName) throws IOException
-    {
-        StringBuilder appendString = new StringBuilder();
-        appendString.append(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
-        appendString.append(ASEmitterTokens.PAREN_OPEN.getToken());
-        appendString.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
-        appendString.append(JSFlexJSEmitterTokens.LANGUAGE_QNAME.getToken());
-        appendString.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
-        appendString.append(ASEmitterTokens.PAREN_CLOSE.getToken());
-        appendString.append(ASEmitterTokens.SEMICOLON.getToken());
-        appendString.append("\n");
-
-        String fileData = readCode(new File(path));
-        int reqidx = fileData.indexOf(appendString.toString());
-        if (reqidx == -1 && project.needLanguage)
-        {
-            reqidx = fileData.lastIndexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
-            if (reqidx == -1)
-                reqidx = fileData.lastIndexOf(JSGoogEmitterTokens.GOOG_PROVIDE.getToken());
-            reqidx = fileData.indexOf(";", reqidx);
-            String after = fileData.substring(reqidx + 1);
-            String before = fileData.substring(0, reqidx + 1);
-            String s = before + "\n" + appendString.toString() + after;
-            writeFile(path, s, false);
-        }
-    }
-
     protected String readCode(File file)
     {
         String code = "";


Mime
View raw message