You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jo...@apache.org on 2016/04/06 01:56:49 UTC
[31/33] git commit: [flex-falcon] [refs/heads/develop] -
JSFlexJSEmitter: fixed issue where the require for Language was omitted if no
other requires exist in the main class
JSFlexJSEmitter: fixed issue where the require for Language was omitted if no other requires exist in the 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/42566284
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/42566284
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/42566284
Branch: refs/heads/develop
Commit: 42566284037c8921c618aea83523bbe3f222dfb2
Parents: c199920
Author: Josh Tynjala <jo...@apache.org>
Authored: Sat Apr 2 13:00:25 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Sat Apr 2 13:00:25 2016 -0700
----------------------------------------------------------------------
.../codegen/js/flexjs/JSFlexJSEmitter.java | 34 ++++++++++++++++----
1 file changed, 28 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/42566284/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 c45a01c..64d3a29 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
@@ -146,14 +146,26 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
boolean foundLanguage = false;
boolean sawRequires = false;
boolean stillSearching = true;
- for (int i = 0; i < lines.length; i++)
+ int addIndex = -1;
+ int len = lines.length;
+ for (int i = 0; i < len; i++)
{
String line = lines[i];
if (stillSearching)
{
- int c = line.indexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
- if (c > -1)
+ int c = line.indexOf(JSGoogEmitterTokens.GOOG_PROVIDE.getToken());
+ if (c != -1)
+ {
+ // if zero requires are found, require Language after the
+ // call to goog.provide
+ addIndex = i + 1;
+ }
+ c = line.indexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
+ if (c != -1)
{
+ // we found other requires, so we'll just add Language at
+ // the end of the list
+ addIndex = -1;
int c2 = line.indexOf(")");
String s = line.substring(c + 14, c2 - 1);
if(s.equals(JSFlexJSEmitterTokens.LANGUAGE_QNAME.getToken()))
@@ -167,7 +179,7 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
continue;
}
}
- else if (sawRequires)
+ else if (sawRequires || i == len - 1)
{
stillSearching = false;
@@ -189,8 +201,18 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
appendString.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
appendString.append(ASEmitterTokens.PAREN_CLOSE.getToken());
appendString.append(ASEmitterTokens.SEMICOLON.getToken());
- finalLines.add(appendString.toString());
- addLineToMappings(i);
+ 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);
+ }
}
}
}