You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2016/12/17 05:52:09 UTC
[1/2] git commit: [flex-falcon] [refs/heads/develop] - FLEX-35171 Fix
CSS Combinator handling
Repository: flex-falcon
Updated Branches:
refs/heads/develop 1ad5ed4ab -> 3e266d84b
FLEX-35171 Fix CSS Combinator handling
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/3e266d84
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/3e266d84
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/3e266d84
Branch: refs/heads/develop
Commit: 3e266d84bec856de5f153e5d5b427638d3f6fc66
Parents: 7cca516
Author: Alex Harui <ah...@apache.org>
Authored: Fri Dec 16 21:33:06 2016 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Dec 16 21:33:23 2016 -0800
----------------------------------------------------------------------
.../resources/flexjs/files/CSSTestSource.css | 12 +++-
.../flexjs/files/CSSTestSource_result.css | 16 ++++-
.../org/apache/flex/compiler/internal/css/CSS.g | 70 ++++++++++++--------
.../apache/flex/compiler/internal/css/CSSTree.g | 35 +++++-----
.../flex/compiler/css/CombinatorType.java | 5 +-
.../apache/flex/compiler/css/ConditionType.java | 15 -----
.../flex/compiler/internal/css/CSSSelector.java | 12 +---
.../css/semantics/CSSSemanticAnalyzer.java | 5 +-
8 files changed, 92 insertions(+), 78 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3e266d84/compiler-jx/src/test/resources/flexjs/files/CSSTestSource.css
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/flexjs/files/CSSTestSource.css b/compiler-jx/src/test/resources/flexjs/files/CSSTestSource.css
index 85523f8..0e4d580 100755
--- a/compiler-jx/src/test/resources/flexjs/files/CSSTestSource.css
+++ b/compiler-jx/src/test/resources/flexjs/files/CSSTestSource.css
@@ -20,6 +20,7 @@
*/
@namespace basic "library://ns.apache.org/flexjs/basic";
+@namespace "http://www.w3.org/1999/xhtml";
/*
//----------------------------
@@ -53,12 +54,21 @@
.outer.inner {
width: 512px;
}
+
+.outer .inner {
+ width: 512px;
+}
+
.outer > .innerTitle {
color: #fff;
height: 176px;
background: url('assets/welcome_card.jpg') center / cover;
}
-.outer > .innerMenu {
+.outer>.innerMenu {
+ color: #fff;
+}
+
+.outer> .innerMenu > h4 {
color: #fff;
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3e266d84/compiler-jx/src/test/resources/flexjs/files/CSSTestSource_result.css
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/flexjs/files/CSSTestSource_result.css b/compiler-jx/src/test/resources/flexjs/files/CSSTestSource_result.css
index b3f8b21..3d2ddcd 100755
--- a/compiler-jx/src/test/resources/flexjs/files/CSSTestSource_result.css
+++ b/compiler-jx/src/test/resources/flexjs/files/CSSTestSource_result.css
@@ -49,14 +49,24 @@
}
-.outer > .innerTitle {
+.outer .inner {
+ width: 512px;
+}
+
+
+.outer>.innerTitle {
height: 176px;
color: #fff;
background: url('assets/welcome_card.jpg') center / cover;
}
-.outer > .innerMenu {
+.outer>.innerMenu {
+ color: #fff;
+}
+
+
+.outer>.innerMenu>h4 {
color: #fff;
}
@@ -67,7 +77,7 @@
}
-.outerother-square > .innerTitle {
+.outerother-square>.innerTitle {
color: #fff;
background: url('assets/dog.png') bottom right 15% no-repeat #46B6AC;
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3e266d84/compiler/src/main/antlr3/org/apache/flex/compiler/internal/css/CSS.g
----------------------------------------------------------------------
diff --git a/compiler/src/main/antlr3/org/apache/flex/compiler/internal/css/CSS.g b/compiler/src/main/antlr3/org/apache/flex/compiler/internal/css/CSS.g
index ac92798..6fec15d 100644
--- a/compiler/src/main/antlr3/org/apache/flex/compiler/internal/css/CSS.g
+++ b/compiler/src/main/antlr3/org/apache/flex/compiler/internal/css/CSS.g
@@ -33,7 +33,7 @@ options
tokens
{
I_RULES; I_MEDIUM_CONDITIONS; I_DECL; I_RULE; I_SELECTOR_GROUP; I_SELECTOR;
- I_SIMPLE_SELECTOR; I_ARRAY;
+ I_SIMPLE_SELECTOR; I_CHILD_SELECTOR; I_PRECEDED_SELECTOR; I_SIBLING_SELECTOR; I_ARRAY;
}
@header
@@ -108,13 +108,36 @@ public void displayRecognitionError(String[] tokenNames, RecognitionException e)
/**
* Check if the cursor is at the end of a simple selector.
+ * @return -1 if not end
+ * @return 0 if end
+ * @return 1 if ended by Child combinator
+ * @return 2 if ended by Preceded combinator
+ * @return 3 if ended by Sibling combinator
*/
-private final boolean endOfSimpleSelector()
+private final int endOfSimpleSelector()
{
final CommonToken nextToken = (CommonToken) getTokenStream().LT(1);
if (nextToken == null)
- return true;
+ return 0;
+ final int nextType = nextToken.getType();
+
+ if (nextType == CHILD)
+ {
+ getTokenStream().consume();
+ return 1;
+ }
+ if (nextType == PRECEDED)
+ {
+ getTokenStream().consume();
+ return 2;
+ }
+ if (nextType == TILDE)
+ {
+ getTokenStream().consume();
+ return 3;
+ }
+
// Check if there's white space between the previous token and the next token.
final CommonToken lastToken = (CommonToken) getTokenStream().LT(-1);
if (lastToken != null && nextToken != null)
@@ -123,18 +146,17 @@ private final boolean endOfSimpleSelector()
final int nextStart = nextToken.getStartIndex();
if (lastStop + 1 < nextStart)
{
- return true;
+ return 0;
}
}
// If the next token is "{" or ",", it's also end of a selector.
- final int nextType = nextToken.getType();
if (nextType == BLOCK_OPEN || nextType == COMMA)
{
- return true;
+ return 0;
}
- return false;
+ return -1;
}
}
@@ -250,9 +272,6 @@ selectorGroup
* Each compound selector has one "subject", which is the element name of the
* right most simple selector in the chain.
*
- * Currently, only descendant combinator (space) is supported.
- * If we need to support combinators, add the terminals in this production.
- *
* For example:
* s|VBox s|HBox.content s|Button
*/
@@ -277,8 +296,9 @@ compoundSelector
simpleSelectorStopToken = $l.stop;
adaptor.addChild(currentSimpleSelectorNode, $l.tree);
-
- if (endOfSimpleSelector())
+
+ int end = endOfSimpleSelector();
+ if (end != -1)
{
adaptor.setTokenBoundaries(
currentSimpleSelectorNode,
@@ -289,7 +309,14 @@ compoundSelector
simpleSelectorStartToken = null;
simpleSelectorStopToken = null;
- currentSimpleSelectorNode = adaptor.create(I_SIMPLE_SELECTOR, "I_SIMPLE_SELECTOR");
+ if (end == 1)
+ currentSimpleSelectorNode = adaptor.create(I_CHILD_SELECTOR, "I_CHILD_SELECTOR");
+ else if (end == 2)
+ currentSimpleSelectorNode = adaptor.create(I_PRECEDED_SELECTOR, "I_PRECEDED_SELECTOR");
+ else if (end == 3)
+ currentSimpleSelectorNode = adaptor.create(I_SIBLING_SELECTOR, "I_SIBLING_SELECTOR");
+ else
+ currentSimpleSelectorNode = adaptor.create(I_SIMPLE_SELECTOR, "I_SIMPLE_SELECTOR");
}
}
)+
@@ -336,9 +363,6 @@ condition
| COLON^ ID
| DOUBLE_COLON^ ID
| attributeSelector
- | childSelector
- | precededSelector
- | siblingSelector
)
;
@@ -446,18 +470,6 @@ singleValue
formatOption
: FORMAT ARGUMENTS -> ^(FORMAT ARGUMENTS)
;
-
-childSelector
- : '>' simpleSelectorFraction
- ;
-
-precededSelector
- : TILDE simpleSelectorFraction
- ;
-
-siblingSelector
- : '+' simpleSelectorFraction
- ;
attributeSelector
: SQUARE_OPEN attributeName attributeOperator* attributeValue* SQUARE_END
@@ -515,6 +527,8 @@ LOCAL : 'local' ;
SCALE : 'scale' ;
NULL : 'null' ;
ONLY : 'only' ;
+CHILD : '>' ;
+PRECEDED : '+' ;
NOT
: 'not'
;
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3e266d84/compiler/src/main/antlr3/org/apache/flex/compiler/internal/css/CSSTree.g
----------------------------------------------------------------------
diff --git a/compiler/src/main/antlr3/org/apache/flex/compiler/internal/css/CSSTree.g b/compiler/src/main/antlr3/org/apache/flex/compiler/internal/css/CSSTree.g
index 83d9f80..b8d9587 100644
--- a/compiler/src/main/antlr3/org/apache/flex/compiler/internal/css/CSSTree.g
+++ b/compiler/src/main/antlr3/org/apache/flex/compiler/internal/css/CSSTree.g
@@ -231,10 +231,21 @@ compoundSelector
{
$ruleset::subjects.add(simpleSelectorStack.peek());
}
- : ^(I_SELECTOR simpleSelector[simpleSelectorStack]+)
+ : ^(I_SELECTOR firstSelector[simpleSelectorStack] moreSelectors[simpleSelectorStack]*)
;
-simpleSelector [Stack<CSSSelector> simpleSelectorStack]
+moreSelectors [Stack<CSSSelector> simpleSelectorStack]
+ : ^(I_CHILD_SELECTOR simpleSelector[simpleSelectorStack, CombinatorType.CHILD])
+ | ^(I_PRECEDED_SELECTOR simpleSelector[simpleSelectorStack, CombinatorType.PRECEDED])
+ | ^(I_SIBLING_SELECTOR simpleSelector[simpleSelectorStack, CombinatorType.SIBLING])
+ | ^(I_SIMPLE_SELECTOR simpleSelector[simpleSelectorStack, CombinatorType.DESCENDANT])
+ ;
+
+firstSelector [Stack<CSSSelector> simpleSelectorStack]
+ : ^(I_SIMPLE_SELECTOR simpleSelector[simpleSelectorStack, CombinatorType.DESCENDANT])
+ ;
+
+simpleSelector [Stack<CSSSelector> simpleSelectorStack, CombinatorType combinatorType]
scope
{
String namespace;
@@ -248,7 +259,7 @@ scope
if (simpleSelectorStack.isEmpty())
combinator = null;
else
- combinator = new CSSCombinator(simpleSelectorStack.peek(), CombinatorType.DESCENDANT, $start, tokenStream);
+ combinator = new CSSCombinator(simpleSelectorStack.peek(), combinatorType, $start, tokenStream);
}
@after
{
@@ -261,8 +272,9 @@ scope
tokenStream);
simpleSelectorStack.push(simpleSelector);
}
- : ^(I_SIMPLE_SELECTOR simpleSelectorFraction+)
+ : simpleSelectorFraction+
;
+
simpleSelectorFraction
: elementSelector
@@ -286,9 +298,6 @@ conditionSelector
| ^(COLON s=ID) { type = ConditionType.PSEUDO; name = $s.text; }
| ^(DOUBLE_COLON dc=ID) { type = ConditionType.PSEUDO; name = $dc.text; }
| attributeSelector { type = ConditionType.ATTRIBUTE; name = curAttribute.substring(1); }
- | childSelector { type = ConditionType.CHILD; name = ConditionType.CHILD.toString(); }
- | precededSelector { type = ConditionType.PRECEDED; name = ConditionType.PRECEDED.toString(); }
- | siblingSelector { type = ConditionType.SIBLING; name = ConditionType.SIBLING.toString(); }
;
elementSelector
@@ -303,18 +312,6 @@ elementSelector
{ $simpleSelector::element = $STAR.text; }
;
-childSelector
- : '>' simpleSelectorFraction
- ;
-
-precededSelector
- : TILDE simpleSelectorFraction
- ;
-
-siblingSelector
- : '+' simpleSelectorFraction
- ;
-
attributeSelector
: open = SQUARE_OPEN attributeName attributeOperator* attributeValue* close = SQUARE_END
{ curAttribute = $open.text + curAttribute + $close.text; }
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3e266d84/compiler/src/main/java/org/apache/flex/compiler/css/CombinatorType.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/css/CombinatorType.java b/compiler/src/main/java/org/apache/flex/compiler/css/CombinatorType.java
index 3f30dfc..580542d 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/css/CombinatorType.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/css/CombinatorType.java
@@ -26,7 +26,10 @@ package org.apache.flex.compiler.css;
*/
public enum CombinatorType
{
- DESCENDANT(" ");
+ DESCENDANT(" "),
+ CHILD(">"),
+ PRECEDED("+"),
+ SIBLING("~");
private CombinatorType(String text)
{
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3e266d84/compiler/src/main/java/org/apache/flex/compiler/css/ConditionType.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/css/ConditionType.java b/compiler/src/main/java/org/apache/flex/compiler/css/ConditionType.java
index 46eda58..716db2f 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/css/ConditionType.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/css/ConditionType.java
@@ -40,26 +40,11 @@ public enum ConditionType
PSEUDO(":"),
/**
- * For example: <code>s|Panel > s|Label</code>
- */
- CHILD(">"),
-
- /**
* For example: <code>s|Panel:not(:first-child)</code>
*/
NOT("not"),
/**
- * For example: <code>s|Panel ~ s|Label</code>
- */
- PRECEDED("~"),
-
- /**
- * For example: <code>s|Panel + s|Label</code>
- */
- SIBLING("+"),
-
- /**
* For example: <code>s|Label[loadingState]</code>
*/
ATTRIBUTE("[");
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3e266d84/compiler/src/main/java/org/apache/flex/compiler/internal/css/CSSSelector.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/css/CSSSelector.java b/compiler/src/main/java/org/apache/flex/compiler/internal/css/CSSSelector.java
index a28c9b9..0b0258d 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/internal/css/CSSSelector.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/internal/css/CSSSelector.java
@@ -116,16 +116,8 @@ public class CSSSelector extends CSSNodeBase implements ICSSSelector
for (int i = 0; i < n; i++)
{
ICSSSelectorCondition condition = conditions.get(i);
- if (condition.getConditionType() == ConditionType.CHILD)
- {
- String prefix = condition.getConditionType().prefix + " ";
- s.insert(0, prefix);
- }
- else
- {
- s.append(condition.getConditionType().prefix);
- s.append(condition.getValue());
- }
+ s.append(condition.getConditionType().prefix);
+ s.append(condition.getValue());
}
return s.toString();
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/3e266d84/compiler/src/main/java/org/apache/flex/compiler/internal/css/semantics/CSSSemanticAnalyzer.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/css/semantics/CSSSemanticAnalyzer.java b/compiler/src/main/java/org/apache/flex/compiler/internal/css/semantics/CSSSemanticAnalyzer.java
index a4748f4..64dfa7f 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/internal/css/semantics/CSSSemanticAnalyzer.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/internal/css/semantics/CSSSemanticAnalyzer.java
@@ -272,7 +272,10 @@ public class CSSSemanticAnalyzer
final String qname = xmlNameResolver.resolveXMLNameToQualifiedName(xmlName, MXMLDialect.MXML_2009);
if (qname == null)
{
- problems.add(new CSSUndefinedTypeProblem((CSSSelector)selector));
+ if (defaultNamespace != null && defaultNamespace.getURI().equals("http://www.w3.org/1999/xhtml"))
+ builder.put(selector, selector.getElementName());
+ else
+ problems.add(new CSSUndefinedTypeProblem((CSSSelector)selector));
}
else
{
[2/2] git commit: [flex-falcon] [refs/heads/develop] - report errors
when compiling tests and fix the tests that had errors
Posted by ah...@apache.org.
report errors when compiling tests and fix the tests that had errors
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/7cca5166
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/7cca5166
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/7cca5166
Branch: refs/heads/develop
Commit: 7cca51660442fdcbe57972fc1c969feda24f54f4
Parents: 1ad5ed4
Author: Alex Harui <ah...@apache.org>
Authored: Fri Dec 16 21:31:42 2016 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Dec 16 21:33:23 2016 -0800
----------------------------------------------------------------------
.../compiler/internal/codegen/as/TestClass.java | 2 +-
.../codegen/js/flexjs/TestFlexJSClass.java | 2 +-
.../codegen/js/flexjs/TestFlexJSEmitter.java | 2 +-
.../codegen/js/flexjs/TestFlexJSExpressions.java | 2 +-
.../js/flexjs/TestFlexJSGlobalFunctions.java | 2 +-
.../codegen/js/flexjs/TestFlexJSPackage.java | 4 ++--
.../internal/codegen/js/goog/TestGoogClass.java | 2 +-
.../codegen/js/goog/TestGoogEmitter.java | 2 +-
.../flex/compiler/internal/test/TestBase.java | 19 ++++++++++++++++++-
9 files changed, 27 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7cca5166/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/as/TestClass.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/as/TestClass.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/as/TestClass.java
index 3787d45..7a427c0 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/as/TestClass.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/as/TestClass.java
@@ -165,7 +165,7 @@ public class TestClass extends ASTestBase
+ "public static const A:int = 42;"
+ "protected static const B:Number = 42;"
+ "private static const C:Number = 42;"
- + "foo_bar static const C:String = 'me' + 'you';");
+ + "foo_bar static const C:String = 'me' + 'you';}");
asBlockWalker.visitClass(node);
assertOut("public class A {\n\tpublic static const A:int = 42;\n\t"
+ "protected static const B:Number = 42;\n\tprivate static const "
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7cca5166/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
index fcb93e7..50e7d6e 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java
@@ -243,7 +243,7 @@ public class TestFlexJSClass extends TestGoogClass
+ "public static const A:int = 42;"
+ "protected static const B:Number = 42;"
+ "private static const C:Number = 42;"
- + "foo_bar static const C:String = 'me' + 'you';");
+ + "foo_bar static const C:String = 'me' + 'you';}");
asBlockWalker.visitClass(node);
assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n\n/**\n * @export\n * @const\n * @type {number}\n */\norg.apache.flex.A.A = 42;\n\n\n/**\n * @protected\n * @const\n * @type {number}\n */\norg.apache.flex.A.B = 42;\n\n\n/**\n * @private\n * @const\n * @type {number}\n */\norg.apache.flex.A.C = 42;\n\n\n/**\n * @export\n * @const\n * @type {string}\n */\norg.apache.flex.A.C = 'me' + 'you';");
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7cca5166/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSEmitter.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSEmitter.java
index a52729e..549fd97 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSEmitter.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSEmitter.java
@@ -53,7 +53,7 @@ public class TestFlexJSEmitter extends TestGoogEmitter
+ "private var _privateVar:String = \"do \";"
+ "public var publicProperty:Number = 100;"
+ "public function myFunction(value: String): String{"
- + "return \"Don't \" + _privateVar + value; }";
+ + "return \"Don't \" + _privateVar + value; }}}";
IFileNode node = compileAS(code);
asBlockWalker.visitFile(node);
assertOutWithMetadata("/**\n" +
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7cca5166/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
index c8246c1..f683349 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
@@ -955,7 +955,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions
@Test
public void testComplexBooleanExpression()
{
- IFunctionNode node = getMethod("function foo(b:Boolean):Boolean {var c:String; var d:String; if (!(b ? c : d)) { return b;}");
+ IFunctionNode node = getMethod("function foo(b:Boolean):Boolean {var c:String; var d:String; if (!(b ? c : d)) { return b;}}");
asBlockWalker.visitFunction(node);
assertOut("/**\n * @param {boolean} b\n * @return {boolean}\n */\nFalconTest_A.prototype.foo = function(b) {\n var /** @type {string} */ c;\n var /** @type {string} */ d;\n if (!(b ? c : d)) {\n return b;\n }\n}");
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7cca5166/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalFunctions.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalFunctions.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalFunctions.java
index fc49825..3f40dc7 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalFunctions.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalFunctions.java
@@ -241,7 +241,7 @@ public class TestFlexJSGlobalFunctions extends TestGoogGlobalFunctions
public void testGlobalFunctionInClass()
{
IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
- "public class B {public function b():String { var s:String; s = encodeURIComponent('foo'); return s;}",
+ "public class B {public function b():String { var s:String; s = encodeURIComponent('foo'); return s;}}",
IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
asBlockWalker.visitBinaryOperator(node);
assertOut("s = encodeURIComponent('foo')");
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7cca5166/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSPackage.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSPackage.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSPackage.java
index 4a0bbeb..8565b94 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSPackage.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSPackage.java
@@ -1227,7 +1227,7 @@ public class TestFlexJSPackage extends TestGoogPackage
@Test
public void testPackageSimple_Variable()
{
- IFileNode node = compileAS("package {public var A:String = \"Hello\";");
+ IFileNode node = compileAS("package {public var A:String = \"Hello\";}");
asBlockWalker.visitFile(node);
assertOutWithMetadata("/**\n * A\n *\n * @fileoverview\n *\n * @suppress {checkTypes|accessControls}\n */\n\ngoog.provide('A');\n\n\n\n/**\n * @export\n * @type {string}\n */\nA = \"Hello\"");
}
@@ -1235,7 +1235,7 @@ public class TestFlexJSPackage extends TestGoogPackage
@Test
public void testPackageQualified_Variable()
{
- IFileNode node = compileAS("package foo.bar.baz {public var A:String = \"Hello\";");
+ IFileNode node = compileAS("package foo.bar.baz {public var A:String = \"Hello\";}");
asBlockWalker.visitFile(node);
assertOutWithMetadata("/**\n * foo.bar.baz.A\n *\n * @fileoverview\n *\n * @suppress {checkTypes|accessControls}\n */\n\ngoog.provide('foo.bar.baz.A');\n\n\n\n/**\n * @export\n * @type {string}\n */\nfoo.bar.baz.A = \"Hello\"");
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7cca5166/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogClass.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogClass.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogClass.java
index 59d184b..cd260f4 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogClass.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogClass.java
@@ -199,7 +199,7 @@ public class TestGoogClass extends TestClass
+ "public static const A:int = 42;"
+ "protected static const B:Number = 42;"
+ "private static const C:Number = 42;"
- + "foo_bar static const C:String = 'me' + 'you';");
+ + "foo_bar static const C:String = 'me' + 'you';}");
asBlockWalker.visitClass(node);
assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n/**\n * @const\n * @type {number}\n */\norg.apache.flex.A.A = 42;\n\n/**\n * @protected\n * @const\n * @type {number}\n */\norg.apache.flex.A.B = 42;\n\n/**\n * @private\n * @const\n * @type {number}\n */\norg.apache.flex.A.C = 42;\n\n/**\n * @const\n * @type {string}\n */\norg.apache.flex.A.C = 'me' + 'you';");
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7cca5166/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogEmitter.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogEmitter.java
index 2b882d6..28d4a8a 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogEmitter.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/goog/TestGoogEmitter.java
@@ -47,7 +47,7 @@ public class TestGoogEmitter extends ASTestBase
+ "private var _privateVar:String = \"do \";"
+ "public var publicProperty:Number = 100;"
+ "public function myFunction(value: String): String{"
- + "return \"Don't \" + _privateVar + value; }";
+ + "return \"Don't \" + _privateVar + value; }}}";
IFileNode node = compileAS(code);
asBlockWalker.visitFile(node);
assertOut("goog.provide('com.example.components.MyEventTarget');\n\ngoog.require('flash.events.EventDispatcher');\n\n/**\n * @constructor\n * @extends {flash.events.EventDispatcher}\n */\ncom.example.components.MyEventTarget = function() {\n\tvar self = this;\n\tcom.example.components.MyEventTarget.base(this, 'constructor');\n\tif (foo() != 42) {\n\t\tbar();\n\t}\n};\ngoog.inherits(com.example.components.MyEventTarget, flash.events.EventDispatcher);\n\n/**\n * @private\n * @type {string}\n */\ncom.example.components.MyEventTarget.prototype._privateVar = \"do \";\n\n/**\n * @type {number}\n */\ncom.example.components.MyEventTarget.prototype.publicProperty = 100;\n\n/**\n * @param {string} value\n * @return {string}\n */\ncom.example.components.MyEventTarget.prototype.myFunction = function(value) {\n\tvar self = this;\n\treturn \"Don't \" + self._privateVar + value;\n};");
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/7cca5166/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/TestBase.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/TestBase.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/TestBase.java
index 626b079..916d7ce 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/TestBase.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/TestBase.java
@@ -61,6 +61,7 @@ import org.apache.flex.compiler.tree.as.IASNode;
import org.apache.flex.compiler.tree.as.IFileNode;
import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
import org.apache.flex.compiler.units.ICompilationUnit;
+import org.apache.flex.compiler.units.requests.ISyntaxTreeRequestResult;
import org.apache.flex.utils.EnvProperties;
import org.apache.flex.compiler.visitor.as.IASBlockWalker;
import org.apache.flex.compiler.visitor.mxml.IMXMLBlockWalker;
@@ -159,6 +160,14 @@ public class TestBase implements ITestBase
StringBuilder actualErrors = new StringBuilder();
for (ICompilerProblem problem : errors)
{
+ if (problem.toString().equals("An externally-visible definition with the name 'Object' was unexpectedly found."))
+ continue;
+ if (problem.toString().equals("An externally-visible definition with the name 'String' was unexpectedly found."))
+ continue;
+ if (problem.toString().equals("No externally-visible definition with the name 'externals.as.classes.Object' was found."))
+ continue;
+ if (problem.toString().equals("No externally-visible definition with the name 'externals.as.classes.String' was found."))
+ continue;
actualErrors.append(problem.toString());
}
assertThat(actualErrors.toString(), is(errorReport));
@@ -255,7 +264,15 @@ public class TestBase implements ITestBase
IASNode fileNode = null;
try
{
- fileNode = cu.getSyntaxTreeRequest().get().getAST();
+ ISyntaxTreeRequestResult result = cu.getSyntaxTreeRequest().get();
+ ICompilerProblem[] problems = result.getProblems();
+ if (problems.length > 0)
+ {
+ for (ICompilerProblem problem : problems)
+ System.out.println(problem.toString());
+ return null;
+ }
+ fileNode = result.getAST();
}
catch (InterruptedException e)
{