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.jx: similar to Language, the XML require is now inserted in the postProcess() method of JSFlexJSEmitter
Date Thu, 07 Apr 2016 23:38:02 GMT
Repository: flex-falcon
Updated Branches:
  refs/heads/develop 5fc4bfc9a -> 239f935f2


compiler.jx: similar to Language, the XML require is now inserted in the postProcess() method
of JSFlexJSEmitter


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

Branch: refs/heads/develop
Commit: 239f935f2a0b35c6d61bc0435e1ea478b6de8784
Parents: 5fc4bfc
Author: Josh Tynjala <joshtynjala@apache.org>
Authored: Thu Apr 7 16:37:55 2016 -0700
Committer: Josh Tynjala <joshtynjala@apache.org>
Committed: Thu Apr 7 16:37:55 2016 -0700

----------------------------------------------------------------------
 .../codegen/js/flexjs/JSFlexJSEmitter.java      | 36 +++++++++-
 .../mxml/flexjs/MXMLFlexJSPublisher.java        | 70 --------------------
 2 files changed, 33 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/239f935f/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 64d3a29..f23f83a 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
@@ -144,6 +144,7 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
     	String[] lines = output.split("\n");
     	ArrayList<String> finalLines = new ArrayList<String>();
         boolean foundLanguage = false;
+        boolean foundXML = false;
     	boolean sawRequires = false;
     	boolean stillSearching = true;
         int addIndex = -1;
@@ -168,10 +169,14 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
                     addIndex = -1;
 	                int c2 = line.indexOf(")");
 	                String s = line.substring(c + 14, c2 - 1);
-                    if(s.equals(JSFlexJSEmitterTokens.LANGUAGE_QNAME.getToken()))
+                    if (s.equals(JSFlexJSEmitterTokens.LANGUAGE_QNAME.getToken()))
                     {
                         foundLanguage = true;
                     }
+                    else if (s.equals(IASLanguageConstants.XML))
+                    {
+                        foundXML = true;
+                    }
 	    			sawRequires = true;
 	    			if (!usedNames.contains(s))
                     {
@@ -190,8 +195,9 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
                     ICompilerProject project = getWalker().getProject();
                     if (project instanceof FlexJSProject)
                     {
-                        boolean needLanguage = ((FlexJSProject) project).needLanguage;
-                        if(needLanguage && !foundLanguage)
+                        FlexJSProject flexJSProject = (FlexJSProject) project;
+                        boolean needLanguage = flexJSProject.needLanguage;
+                        if (needLanguage && !foundLanguage)
                         {
                             StringBuilder appendString = new StringBuilder();
                             appendString.append(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
@@ -214,6 +220,30 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
                                 addLineToMappings(i);
                             }
                         }
+                        boolean needXML = flexJSProject.needXML;
+                        if (needXML && !foundXML)
+                        {
+                            StringBuilder appendString = new StringBuilder();
+                            appendString.append(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
+                            appendString.append(ASEmitterTokens.PAREN_OPEN.getToken());
+                            appendString.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
+                            appendString.append(IASLanguageConstants.XML);
+                            appendString.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
+                            appendString.append(ASEmitterTokens.PAREN_CLOSE.getToken());
+                            appendString.append(ASEmitterTokens.SEMICOLON.getToken());
+                            if(addIndex != -1)
+                            {
+                                // if we didn't find other requires, this index
+                                // points to the line after goog.provide
+                                finalLines.add(addIndex, appendString.toString());
+                                addLineToMappings(addIndex);
+                            }
+                            else
+                            {
+                                finalLines.add(appendString.toString());
+                                addLineToMappings(i);
+                            }
+                        }
                     }
                 }
     		}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/239f935f/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 4dcc1be..dcd1507 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
@@ -279,7 +279,6 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements IJSPublisher
 
         appendExportSymbol(projectIntermediateJSFilePath, projectName);
         appendEncodedCSS(projectIntermediateJSFilePath, projectName);
-        appendLanguageAndXML(projectIntermediateJSFilePath, projectName);
 
         // if (!subsetGoog)
         // {
@@ -527,75 +526,6 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements IJSPublisher
         }
     }
 
-    private void appendLanguageAndXML(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)
-        {
-	    	boolean afterProvide = false;
-            reqidx = fileData.lastIndexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
-            if (reqidx == -1)
-            {
-            	afterProvide = true;
-                reqidx = fileData.lastIndexOf(JSGoogEmitterTokens.GOOG_PROVIDE.getToken());
-            }
-            reqidx = fileData.indexOf(";", reqidx);
-            String after = fileData.substring(reqidx + 1);
-            String before = fileData.substring(0, reqidx + 1);
-            if (afterProvide)
-            	before += "\n";
-            String s = before + "\n" + appendString.toString() + after;
-            writeFile(path, s, false);
-        }
-        
-        StringBuilder appendStringXML = new StringBuilder();
-        appendStringXML.append(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
-        appendStringXML.append(ASEmitterTokens.PAREN_OPEN.getToken());
-        appendStringXML.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
-        appendStringXML.append(IASLanguageConstants.XML);
-        appendStringXML.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
-        appendStringXML.append(ASEmitterTokens.PAREN_CLOSE.getToken());
-        appendStringXML.append(ASEmitterTokens.SEMICOLON.getToken());
-        appendStringXML.append("\n");
-
-        if (project.needXML)
-        {
-	        fileData = readCode(new File(path));
-	        reqidx = fileData.indexOf(appendStringXML.toString());
-	        if (reqidx == -1)
-	        {
-		    	boolean afterProvide = false;
-	            reqidx = fileData.lastIndexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
-	            if (reqidx == -1)
-	            {
-	            	afterProvide = true;
-	                reqidx = fileData.lastIndexOf(JSGoogEmitterTokens.GOOG_PROVIDE.getToken());
-	            }
-	            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);
-	            if (afterProvide)
-	            	before += "\n";
-	            String s = before + "\n" + appendStringXML.toString() + after;
-	            writeFile(path, s, false);
-	        }
-        }
-    }
-
     protected String readCode(File file)
     {
         String code = "";


Mime
View raw message