You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2016/04/21 13:35:31 UTC
[01/19] git commit: [flex-falcon]
[refs/heads/feature/maven-migration-test] - CSSDocumentCache: implemented
getEndLine() and getEndColumn() to fix error in jenkins that didn't show up
in ant all
Repository: flex-falcon
Updated Branches:
refs/heads/feature/maven-migration-test b42cb998b -> dd5033438
CSSDocumentCache: implemented getEndLine() and getEndColumn() to fix error in jenkins that didn't show up in ant all
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/0b537490
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/0b537490
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/0b537490
Branch: refs/heads/feature/maven-migration-test
Commit: 0b5374907ab7e57616fdc6218f3a707eb6494826
Parents: e9fd628
Author: Josh Tynjala <jo...@apache.org>
Authored: Mon Apr 18 09:49:41 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Mon Apr 18 09:49:41 2016 -0700
----------------------------------------------------------------------
.../flex/compiler/internal/caches/CSSDocumentCache.java | 12 ++++++++++++
1 file changed, 12 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/0b537490/compiler/src/org/apache/flex/compiler/internal/caches/CSSDocumentCache.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/caches/CSSDocumentCache.java b/compiler/src/org/apache/flex/compiler/internal/caches/CSSDocumentCache.java
index 4e009b3..072019e 100644
--- a/compiler/src/org/apache/flex/compiler/internal/caches/CSSDocumentCache.java
+++ b/compiler/src/org/apache/flex/compiler/internal/caches/CSSDocumentCache.java
@@ -169,6 +169,18 @@ public class CSSDocumentCache extends ConcurrentCacheStoreBase<ICSSDocument>
}
@Override
+ public int getEndLine()
+ {
+ return 0;
+ }
+
+ @Override
+ public int getEndColumn()
+ {
+ return 0;
+ }
+
+ @Override
public int getAbsoluteStart()
{
return 0;
[15/19] git commit: [flex-falcon]
[refs/heads/feature/maven-migration-test] - externs/js: more things that
don't need to be excluded anymore
Posted by cd...@apache.org.
externs/js: more things that don't need to be excluded anymore
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/fb2dc7a9
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/fb2dc7a9
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/fb2dc7a9
Branch: refs/heads/feature/maven-migration-test
Commit: fb2dc7a94b19f2c5a25a525880c3c6d69e96f37a
Parents: 5a6e32e
Author: Josh Tynjala <jo...@apache.org>
Authored: Wed Apr 20 11:14:33 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Wed Apr 20 11:14:33 2016 -0700
----------------------------------------------------------------------
.../compiler/internal/codegen/externals/ExternalsTestUtils.java | 5 -----
externs/js/js-compile-config.xml | 5 -----
2 files changed, 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/fb2dc7a9/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java
index da0571a..6eacbde 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java
@@ -58,11 +58,6 @@ public class ExternalsTestUtils
config.addExclude("Date", "valueOf");
config.addExclude("String", "valueOf");
- config.addExclude("HTMLMenuItemElement", "default");
- config.addExclude("MessageEvent", "data"); // TODO returns T
- config.addExclude("MessageEvent", "initMessageEventNS"); // TODO param T
- config.addExclude("MessageEvent", "initMessageEvent"); // TODO param T
-
// SVG
config.addExclude("SVGStylable", "className");
config.addExclude("SVGStylable", "style");
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/fb2dc7a9/externs/js/js-compile-config.xml
----------------------------------------------------------------------
diff --git a/externs/js/js-compile-config.xml b/externs/js/js-compile-config.xml
index 7edd1d6..4597706 100644
--- a/externs/js/js-compile-config.xml
+++ b/externs/js/js-compile-config.xml
@@ -139,11 +139,6 @@
<name>valueOf</name>
</exclude>
- <exclude><class>HTMLMenuItemElement</class><name>default</name></exclude>
- <exclude><class>MessageEvent</class><name>data</name></exclude><!-- TODO returns T -->
- <exclude><class>MessageEvent</class><name>initMessageEventNS</name></exclude> <!-- TODO param T -->
- <exclude><class>MessageEvent</class><name>initMessageEvent</name></exclude> <!-- TODO param T -->
-
<!-- SVG -->
<exclude><class>SVGStylable</class><name>className</name></exclude>
<exclude><class>SVGStylable</class><name>style</name></exclude>
[18/19] git commit: [flex-falcon]
[refs/heads/feature/maven-migration-test] - - Renamed the "generate" goal to
"generate-extern" - Replicated the changes to the node extern to match the
develop branch - Fixed the replace commands in js to generate an ide
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dd503343/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
----------------------------------------------------------------------
diff --cc compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
index aab9712,0000000..4beaf2f
mode 100644,000000..100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
@@@ -1,521 -1,0 +1,526 @@@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.js.jx;
+
+import org.apache.flex.compiler.codegen.ISubEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.definitions.IDefinition;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitterTokens;
+import org.apache.flex.compiler.internal.definitions.AccessorDefinition;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+import org.apache.flex.compiler.internal.tree.as.IdentifierNode;
+import org.apache.flex.compiler.internal.tree.as.MemberAccessExpressionNode;
+import org.apache.flex.compiler.internal.tree.as.UnaryOperatorAtNode;
+import org.apache.flex.compiler.projects.ICompilerProject;
+import org.apache.flex.compiler.tree.ASTNodeID;
+import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.as.IBinaryOperatorNode;
+import org.apache.flex.compiler.tree.as.IClassNode;
+import org.apache.flex.compiler.tree.as.IExpressionNode;
+import org.apache.flex.compiler.tree.as.IIdentifierNode;
+import org.apache.flex.compiler.utils.ASNodeUtils;
+
+public class BinaryOperatorEmitter extends JSSubEmitter implements
+ ISubEmitter<IBinaryOperatorNode>
+{
+
+ public BinaryOperatorEmitter(IJSEmitter emitter)
+ {
+ super(emitter);
+ }
+
+ @Override
+ public void emit(IBinaryOperatorNode node)
+ {
+ // TODO (mschmalle) will remove this cast as more things get abstracted
+ JSFlexJSEmitter fjs = (JSFlexJSEmitter) getEmitter();
+
+ ASTNodeID id = node.getNodeID();
+ /*
+ if (id == ASTNodeID.Op_InID
+ || id == ASTNodeID.Op_LogicalAndAssignID
+ || id == ASTNodeID.Op_LogicalOrAssignID)
+ {
+ super.emitBinaryOperator(node);
+ }
+ else */if (id == ASTNodeID.Op_IsID || id == ASTNodeID.Op_AsID)
+ {
+ fjs.emitIsAs(node, node.getLeftOperandNode(), node.getRightOperandNode(),
+ id, false);
+ }
+ else if (id == ASTNodeID.Op_InstanceOfID)
+ {
+ getWalker().walk(node.getLeftOperandNode());
+
+ startMapping(node, node.getLeftOperandNode());
+ write(ASEmitterTokens.SPACE);
+ writeToken(ASEmitterTokens.INSTANCEOF);
+ endMapping(node);
+
+ IDefinition dnode = (node.getRightOperandNode())
+ .resolve(getProject());
+ if (dnode != null)
+ write(getEmitter()
+ .formatQualifiedName(dnode.getQualifiedName()));
+ else
+ getWalker().walk(node.getRightOperandNode());
+ }
+ else
+ {
+ IExpressionNode leftSide = node.getLeftOperandNode();
+ if (leftSide.getNodeID() == ASTNodeID.MemberAccessExpressionID)
+ {
+ IASNode lnode = leftSide.getChild(0);
+ IASNode rnode = leftSide.getChild(1);
+ IDefinition rnodeDef = (rnode instanceof IIdentifierNode) ?
+ ((IIdentifierNode) rnode).resolve(getWalker().getProject()) :
+ null;
+ if (lnode.getNodeID() == ASTNodeID.SuperID
+ && rnodeDef instanceof AccessorDefinition)
+ {
+ String op = node.getOperator().getOperatorText();
+ boolean isAssignment = op.contains("=")
+ && !op.contains("==")
+ && !(op.startsWith("<") || op.startsWith(">") || op
+ .startsWith("!"));
+ if (isAssignment)
+ {
+ ICompilerProject project = this.getProject();
+ if (project instanceof FlexJSProject)
+ ((FlexJSProject)project).needLanguage = true;
+
+ write(JSFlexJSEmitterTokens.LANGUAGE_QNAME);
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ write(JSFlexJSEmitterTokens.SUPERSETTER);
+ write(ASEmitterTokens.PAREN_OPEN);
+ IClassNode cnode = (IClassNode) node
+ .getAncestorOfType(IClassNode.class);
- write(getEmitter().formatQualifiedName(
++ if (cnode != null)
++ write(getEmitter().formatQualifiedName(
+ cnode.getQualifiedName()));
++ else
++ write(getEmitter().formatQualifiedName(
++ getModel().getCurrentClass().getQualifiedName()));
++
+ writeToken(ASEmitterTokens.COMMA);
+ write(ASEmitterTokens.THIS);
+ writeToken(ASEmitterTokens.COMMA);
+ write(ASEmitterTokens.SINGLE_QUOTE);
+ write(rnodeDef.getBaseName());
+ write(ASEmitterTokens.SINGLE_QUOTE);
+ writeToken(ASEmitterTokens.COMMA);
+
+ if (op.length() > 1) // += and things like that
+ {
+ write(JSFlexJSEmitterTokens.LANGUAGE_QNAME);
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ write(JSFlexJSEmitterTokens.SUPERSETTER);
+ write(ASEmitterTokens.PAREN_OPEN);
+ write(getEmitter().formatQualifiedName(
+ cnode.getQualifiedName()));
+ writeToken(ASEmitterTokens.COMMA);
+ write(ASEmitterTokens.THIS);
+ writeToken(ASEmitterTokens.COMMA);
+ write(ASEmitterTokens.SINGLE_QUOTE);
+ write(rnodeDef.getBaseName());
+ write(ASEmitterTokens.SINGLE_QUOTE);
+ write(ASEmitterTokens.PAREN_CLOSE);
+ write(op.substring(0, 1));
+ }
+
+ getWalker().walk(node.getRightOperandNode());
+ write(ASEmitterTokens.PAREN_CLOSE);
+ return;
+ }
+ }
+ else if (((JSFlexJSEmitter)getEmitter()).isXMLList((MemberAccessExpressionNode)leftSide))
+ {
+ MemberAccessExpressionNode xmlNode = (MemberAccessExpressionNode)leftSide;
+ if (node.getNodeID() == ASTNodeID.Op_AssignId)
+ {
+ getWalker().walk(xmlNode.getLeftOperandNode());
+ IExpressionNode rightSide = xmlNode.getRightOperandNode();
+ if (rightSide instanceof UnaryOperatorAtNode)
+ {
+ write(".setAttribute('");
+ getWalker().walk(((UnaryOperatorAtNode)rightSide).getChild(0));
+ }
+ else
+ {
+ write(".setChild('");
+ getWalker().walk(rightSide);
+ }
+ write("', ");
+ getWalker().walk(node.getRightOperandNode());
+ write(ASEmitterTokens.PAREN_CLOSE);
+ return;
+ }
+ else if (node.getNodeID() == ASTNodeID.Op_AddAssignID)
+ {
+ getWalker().walk(xmlNode);
+ write(".concat(");
+ getWalker().walk(node.getRightOperandNode());
+ write(ASEmitterTokens.PAREN_CLOSE);
+ return;
+ }
+ else if (node.getNodeID() == ASTNodeID.Op_AddID)
+ {
+ getWalker().walk(xmlNode);
+ write(".copy().concat(");
+ getWalker().walk(node.getRightOperandNode());
+ write(ASEmitterTokens.PAREN_CLOSE);
+ return;
+ }
+ }
+ else if (((JSFlexJSEmitter)getEmitter()).isProxy((MemberAccessExpressionNode)leftSide))
+ {
+ MemberAccessExpressionNode proxyNode = (MemberAccessExpressionNode)leftSide;
+ if (node.getNodeID() == ASTNodeID.Op_AssignId)
+ {
+ getWalker().walk(proxyNode.getLeftOperandNode());
+ IExpressionNode rightSide = proxyNode.getRightOperandNode();
+ write(".setProperty('");
+ getWalker().walk(rightSide);
+ write("', ");
+ getWalker().walk(node.getRightOperandNode());
+ write(ASEmitterTokens.PAREN_CLOSE);
+ return;
+ }
+ else if (node.getNodeID() == ASTNodeID.Op_AddAssignID)
+ {
+ IExpressionNode rightSide = proxyNode.getRightOperandNode();
+ getWalker().walk(proxyNode.getLeftOperandNode());
+ write(".setProperty('");
+ getWalker().walk(rightSide);
+ write("', ");
+ getWalker().walk(proxyNode.getLeftOperandNode());
+ write(".getProperty(");
+ write(ASEmitterTokens.SINGLE_QUOTE);
+ getWalker().walk(rightSide);
+ write(ASEmitterTokens.SINGLE_QUOTE);
+ write(ASEmitterTokens.PAREN_CLOSE);
+ write(" + ");
+ getWalker().walk(node.getRightOperandNode());
+ write(ASEmitterTokens.PAREN_CLOSE);
+ return;
+ }
+ }
+ else if (((JSFlexJSEmitter)getEmitter()).isDateProperty((MemberAccessExpressionNode)leftSide))
+ {
+ specialCaseDate(node, (MemberAccessExpressionNode)leftSide);
+ return;
+ }
+ }
+ else if (leftSide.getNodeID() == ASTNodeID.IdentifierID)
+ {
+ IDefinition leftDef = leftSide.resolveType(getWalker().getProject());
+ if ((leftDef != null)
+ && IdentifierNode.isXMLish(leftDef, getWalker().getProject()))
+ {
+ if (node.getNodeID() == ASTNodeID.Op_AddAssignID)
+ {
+ getWalker().walk(leftSide);
+ write(".concat(");
+ getWalker().walk(node.getRightOperandNode());
+ write(ASEmitterTokens.PAREN_CLOSE);
+ return;
+ }
+ }
+ }
+
+ super_emitBinaryOperator(node);
+ /*
+ IExpressionNode leftSide = node.getLeftOperandNode();
+
+ IExpressionNode property = null;
+ int leftSideChildCount = leftSide.getChildCount();
+ if (leftSideChildCount > 0)
+ {
+ IASNode childNode = leftSide.getChild(leftSideChildCount - 1);
+ if (childNode instanceof IExpressionNode)
+ property = (IExpressionNode) childNode;
+ else
+ property = leftSide;
+ }
+ else
+ property = leftSide;
+
+ IDefinition def = null;
+ if (property instanceof IIdentifierNode)
+ def = ((IIdentifierNode) property).resolve(getWalker()
+ .getProject());
+
+ boolean isSuper = false;
+ if (leftSide.getNodeID() == ASTNodeID.MemberAccessExpressionID)
+ {
+ IASNode cnode = leftSide.getChild(0);
+ ASTNodeID cId = cnode.getNodeID();
+
+ isSuper = cId == ASTNodeID.SuperID;
+ }
+
+ String op = node.getOperator().getOperatorText();
+ boolean isAssignment = op.contains("=") && !op.contains("==") &&
+ !(op.startsWith("<") ||
+ op.startsWith(">") ||
+ op.startsWith("!"));
+
+ if (def instanceof AccessorDefinition && isAssignment)
+ {
+ // this will make the set_foo call
+ getWalker().walk(leftSide);
+ }
+ else if (isSuper)
+ {
+ emitSuperCall(node, "");
+ }
+ else
+ {
+ if (ASNodeUtils.hasParenOpen(node))
+ write(ASEmitterTokens.PAREN_OPEN);
+
+ getWalker().walk(leftSide);
+
+ if (node.getNodeID() != ASTNodeID.Op_CommaID)
+ write(ASEmitterTokens.SPACE);
+
+ writeToken(node.getOperator().getOperatorText());
+
+ getWalker().walk(node.getRightOperandNode());
+
+ if (ASNodeUtils.hasParenClose(node))
+ write(ASEmitterTokens.PAREN_CLOSE);
+ }
+ */
+ }
+ }
+
+ private void super_emitBinaryOperator(IBinaryOperatorNode node)
+ {
+ if (ASNodeUtils.hasParenOpen(node))
+ write(ASEmitterTokens.PAREN_OPEN);
+
+ ASTNodeID id = node.getNodeID();
+
+ if (id == ASTNodeID.Op_IsID)
+ {
+ write(ASEmitterTokens.IS);
+ write(ASEmitterTokens.PAREN_OPEN);
+ getWalker().walk(node.getLeftOperandNode());
+ writeToken(ASEmitterTokens.COMMA);
+ getWalker().walk(node.getRightOperandNode());
+ write(ASEmitterTokens.PAREN_CLOSE);
+ }
+ else if (id == ASTNodeID.Op_AsID)
+ {
+ // (is(a, b) ? a : null)
+ write(ASEmitterTokens.PAREN_OPEN);
+ write(ASEmitterTokens.IS);
+ write(ASEmitterTokens.PAREN_OPEN);
+ getWalker().walk(node.getLeftOperandNode());
+ writeToken(ASEmitterTokens.COMMA);
+ getWalker().walk(node.getRightOperandNode());
+ writeToken(ASEmitterTokens.PAREN_CLOSE);
+ writeToken(ASEmitterTokens.TERNARY);
+ getWalker().walk(node.getLeftOperandNode());
+ write(ASEmitterTokens.SPACE);
+ writeToken(ASEmitterTokens.COLON);
+ write(ASEmitterTokens.NULL);
+ write(ASEmitterTokens.PAREN_CLOSE);
+ }
+ else
+ {
+ getWalker().walk(node.getLeftOperandNode());
+
+ startMapping(node, node.getLeftOperandNode());
+
+ if (id != ASTNodeID.Op_CommaID)
+ write(ASEmitterTokens.SPACE);
+
+ // (erikdebruin) rewrite 'a &&= b' to 'a = a && b'
+ if (id == ASTNodeID.Op_LogicalAndAssignID
+ || id == ASTNodeID.Op_LogicalOrAssignID)
+ {
+ IIdentifierNode lnode = (IIdentifierNode) node
+ .getLeftOperandNode();
+
+ writeToken(ASEmitterTokens.EQUAL);
+ endMapping(node);
+ write(lnode.getName());
+
+ startMapping(node, node.getLeftOperandNode());
+ write(ASEmitterTokens.SPACE);
+ write((id == ASTNodeID.Op_LogicalAndAssignID) ? ASEmitterTokens.LOGICAL_AND
+ : ASEmitterTokens.LOGICAL_OR);
+ }
+ else
+ {
+ write(node.getOperator().getOperatorText());
+ }
+
+ write(ASEmitterTokens.SPACE);
+ endMapping(node);
+
+ /*
+ IDefinition definition = node.getRightOperandNode().resolve(getProject());
+ if (definition instanceof FunctionDefinition &&
+ (!(definition instanceof AccessorDefinition)))
+ {
+ }
+ else */
+ getWalker().walk(node.getRightOperandNode());
+ if (node.getNodeID() == ASTNodeID.Op_InID &&
+ ((JSFlexJSEmitter)getEmitter()).isXML(node.getRightOperandNode()))
+ {
+ write(".elementNames()");
+ }
+ else if (node.getNodeID() == ASTNodeID.Op_InID &&
+ ((JSFlexJSEmitter)getEmitter()).isProxy(node.getRightOperandNode()))
+ {
+ write(".propertyNames()");
+ }
+ }
+
+ if (ASNodeUtils.hasParenOpen(node))
+ write(ASEmitterTokens.PAREN_CLOSE);
+ }
+
+ private enum DateProperties
+ {
+ FULLYEAR("fullYear", "setFullYear"),
+ MONTH("month", "setMonth"),
+ DATE("date", "setDate"),
+ FULLYEARUTC("fullYearUTC", "setUTCFullYear"),
+ MONTHUTC("monthUTC", "setUTCMonth"),
+ DATEUTC("dateUTC", "setUTCDate"),
+ HOURS("hours", "setHours"),
+ MINUTES("minutes", "setMinutes"),
+ SECONDS("seconds", "setSeconds"),
+ MILLISECONDS("milliseconds", "setMilliseconds"),
+ HOURSUTC("hoursUTC", "setUTCHours"),
+ MINUTESUTC("minutesUTC", "setUTCMinutes"),
+ SECONDSUTC("secondsUTC", "setUTCSeconds"),
+ MILLISECONDSUTC("millisecondsUTC", "setUTCMilliseconds");
+
+ DateProperties(String value, String functionName)
+ {
+ this.value = value;
+ this.functionName = functionName;
+ }
+
+ private String value;
+ private String functionName;
+
+ public String getFunctionName()
+ {
+ return functionName;
+ }
+ }
+
+ void specialCaseDate(IBinaryOperatorNode node, MemberAccessExpressionNode leftSide)
+ {
+ MemberAccessExpressionNode dateNode = (MemberAccessExpressionNode)leftSide;
+ IIdentifierNode rightSide = (IIdentifierNode)dateNode.getRightOperandNode();
+ getWalker().walk(dateNode.getLeftOperandNode());
+ String rightName = rightSide.getName();
+ DateProperties prop = DateProperties.valueOf(rightName.toUpperCase());
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ write(prop.getFunctionName());
+ write(ASEmitterTokens.PAREN_OPEN);
+ getWalker().walk(node.getRightOperandNode());
+ switch (prop)
+ {
+ case FULLYEAR:
+ write(ASEmitterTokens.COMMA);
+ write(ASEmitterTokens.SPACE);
+ getWalker().walk(dateNode.getLeftOperandNode());
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ write("getMonth()");
+ // fall through
+ case MONTH:
+ write(ASEmitterTokens.COMMA);
+ write(ASEmitterTokens.SPACE);
+ getWalker().walk(dateNode.getLeftOperandNode());
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ write("getDate()");
+ break;
+ case FULLYEARUTC:
+ write(ASEmitterTokens.COMMA);
+ write(ASEmitterTokens.SPACE);
+ getWalker().walk(dateNode.getLeftOperandNode());
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ write("getMonthUTC()");
+ // fall through
+ case MONTHUTC:
+ write(ASEmitterTokens.COMMA);
+ write(ASEmitterTokens.SPACE);
+ getWalker().walk(dateNode.getLeftOperandNode());
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ write("getDateUTC()");
+ break;
+ case HOURS:
+ write(ASEmitterTokens.COMMA);
+ write(ASEmitterTokens.SPACE);
+ getWalker().walk(dateNode.getLeftOperandNode());
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ write("getMinutes()");
+ // fall through
+ case MINUTES:
+ write(ASEmitterTokens.COMMA);
+ write(ASEmitterTokens.SPACE);
+ getWalker().walk(dateNode.getLeftOperandNode());
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ write("getSeconds()");
+ // fall through
+ case SECONDS:
+ write(ASEmitterTokens.COMMA);
+ write(ASEmitterTokens.SPACE);
+ getWalker().walk(dateNode.getLeftOperandNode());
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ write("getMilliseconds()");
+ break;
+ case HOURSUTC:
+ write(ASEmitterTokens.COMMA);
+ write(ASEmitterTokens.SPACE);
+ getWalker().walk(dateNode.getLeftOperandNode());
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ write("getUTCMinutes()");
+ // fall through
+ case MINUTESUTC:
+ write(ASEmitterTokens.COMMA);
+ write(ASEmitterTokens.SPACE);
+ getWalker().walk(dateNode.getLeftOperandNode());
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ write("getUTCSeconds()");
+ // fall through
+ case SECONDSUTC:
+ write(ASEmitterTokens.COMMA);
+ write(ASEmitterTokens.SPACE);
+ getWalker().walk(dateNode.getLeftOperandNode());
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ write("getUTCMilliseconds()");
+ break;
+ }
+ write(ASEmitterTokens.PAREN_CLOSE);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dd503343/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java
----------------------------------------------------------------------
diff --cc compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java
index 7956e25,0000000..6eacbde
mode 100644,000000..100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java
@@@ -1,173 -1,0 +1,147 @@@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.externals;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.flex.compiler.clients.ExternCConfiguration;
+import org.apache.flex.utils.FilenameNormalization;
+
+public class ExternalsTestUtils
+{
+ public static File TEMP_DIR = new File(
+ FilenameNormalization.normalize("temp"));
+
+ // XXX missing.js is a temp location until we can figure out where it should placed in the build
+ public static File MISSING_JS_FILE = FilenameNormalization.normalize(new File(
+ "../externs/js/missing.js"));
+
+ // XXX AS3.as is a namespace needed to override toString in some classes
+ public static File AS3_NAMESPACE_FILE = FilenameNormalization.normalize(new File(
+ "../externs/js/src/AS3.as"));
+
+ public static File EXTERNAL_JS_DIR = FilenameNormalization.normalize(new File(
+ "../externs/js/externs"));
+
+ public static File EXTERNAL_JQUERY_DIR = FilenameNormalization.normalize(new File(
+ "../externs/jquery/externs"));
+
+ public static File EXTERNAL_JASMINE_DIR = FilenameNormalization.normalize(new File(
+ "../externs/jasmine/externs"));
+
+ public static File AS_ROOT_DIR = new File(TEMP_DIR, "externals/as");
+
+ public static void addTestExcludesFull(ExternCConfiguration config)
+ {
+ config.addFieldExclude("Window", "focus");
+ config.addClassExclude("controlRange");
+
+ config.addExclude("Array", "toSource");
+ config.addExclude("Date", "valueOf");
+ config.addExclude("String", "valueOf");
-
- config.addExclude("FontFaceSet", "delete");
-
- config.addExclude("CSSStyleDeclaration", "cssText");
- config.addExclude("CSSStyleRule", "style");
- config.addExclude("CSSFontFaceRule", "style");
- config.addExclude("CSSPageRule", "style");
-
- config.addExclude("Generator", "throw");
- config.addExclude("Generator", "return");
- config.addExclude("HTMLMenuItemElement", "default");
- config.addExclude("MessageEvent", "data"); // TODO returns T
- config.addExclude("MessageEvent", "initMessageEventNS"); // TODO param T
- config.addExclude("MessageEvent", "initMessageEvent"); // TODO param T
- config.addExclude("MessageEvent", "default");
- config.addExclude("Object", "is");
- config.addExclude("Promise", "catch");
-
- config.addExclude("IDBCursor", "continue");
- config.addExclude("IDBCursor", "delete");
- config.addExclude("IDBObjectStore", "delete");
-
- // TODO method treated like field
- config.addFieldExclude("Iterator", "next");
- config.addExclude("Generator", "next");
- config.addExclude("LinkStyle", "sheet");
+
+ // SVG
+ config.addExclude("SVGStylable", "className");
+ config.addExclude("SVGStylable", "style");
+ config.addExclude("SVGLocatable", "farthestViewportElement");
+ config.addExclude("SVGLocatable", "nearestViewportElement");
+
+ // jQuery XXX (these will need to be defined in some config when we get external libs
+ // working correctly with EXTERNC)
+ config.addClassToFunction("$");
+
+ config.addExclude("jQuery", "is");
+ config.addExclude("jQuery", "promise");
+ config.addExclude("jQuery", "getJSON");
+ config.addExclude("jQuery", "ajax");
+ config.addExclude("jQuery", "when");
+ config.addExclude("jQuery", "post");
+ config.addExclude("jQuery", "getScript");
+ config.addExclude("jQuery", "Callbacks");
+
+ config.addClassExclude("Deferred");
+ config.addClassExclude("jQuery.deferred");
+ config.addClassExclude("jQuery.Event");
+ config.addClassExclude("jQuery.Deferred");
+ config.addClassExclude("$.Event");
+ config.addClassExclude("$.Deferred");
+ config.addClassExclude("$.deferred");
+ }
+
+ public static void addTestExternalsFull(ExternCConfiguration config)
+ throws IOException
+ {
+ String coreRoot = ExternalsTestUtils.EXTERNAL_JS_DIR.getAbsolutePath();
+
+ config.addExternal(ExternalsTestUtils.MISSING_JS_FILE);
+ config.addExternal(coreRoot + "/es3.js");
+ config.addExternal(coreRoot + "/es5.js");
+ config.addExternal(coreRoot + "/es6.js");
+
+ config.addExternal(coreRoot + "/browser/w3c_anim_timing.js");
+ config.addExternal(coreRoot + "/browser/w3c_audio.js");
+ config.addExternal(coreRoot + "/browser/w3c_batterystatus.js");
+ config.addExternal(coreRoot + "/browser/w3c_css.js");
+ config.addExternal(coreRoot + "/browser/w3c_css3d.js");
+ config.addExternal(coreRoot + "/browser/w3c_device_sensor_event.js");
+ config.addExternal(coreRoot + "/browser/w3c_dom1.js");
+ config.addExternal(coreRoot + "/browser/w3c_dom2.js");
+ config.addExternal(coreRoot + "/browser/w3c_dom3.js");
+ config.addExternal(coreRoot + "/browser/w3c_elementtraversal.js");
+ config.addExternal(coreRoot + "/browser/w3c_encoding.js");
+ config.addExternal(coreRoot + "/browser/w3c_event.js");
+ config.addExternal(coreRoot + "/browser/w3c_event3.js");
+ config.addExternal(coreRoot + "/browser/w3c_geolocation.js");
+ config.addExternal(coreRoot + "/browser/w3c_indexeddb.js");
+ config.addExternal(coreRoot + "/browser/w3c_navigation_timing.js");
+ config.addExternal(coreRoot + "/browser/w3c_range.js");
+ config.addExternal(coreRoot + "/browser/w3c_rtc.js");
+ config.addExternal(coreRoot + "/browser/w3c_selectors.js");
+ //model.addExternal(coreRoot + "/w3c_serviceworker.js");
+ //model.addExternal(coreRoot + "/w3c_webcrypto.js");
+ config.addExternal(coreRoot + "/browser/w3c_xml.js");
+
+ //model.addExternal(coreRoot + "/fetchapi");
+
+ config.addExternal(coreRoot + "/browser/window.js");
+
+ config.addExternal(coreRoot + "/browser/ie_dom.js");
+ config.addExternal(coreRoot + "/browser/gecko_dom.js");
+
+ config.addExternal(coreRoot + "/browser/webkit_css.js");
+ config.addExternal(coreRoot + "/browser/webkit_dom.js");
+ config.addExternal(coreRoot + "/browser/webkit_event.js");
+ //model.addExternal(coreRoot + "/webkit_notifications.js");
+
+ config.addExternal(coreRoot + "/browser/iphone.js");
+ config.addExternal(coreRoot + "/browser/chrome.js");
+ config.addExternal(coreRoot + "/browser/flash.js");
+
+ config.addExternal(coreRoot + "/browser/page_visibility.js");
+ config.addExternal(coreRoot + "/browser/fileapi.js");
+ config.addExternal(coreRoot + "/browser/html5.js");
+
+ config.addExternal(coreRoot + "/browser/webgl.js");
+ config.addExternal(coreRoot + "/browser/webstorage.js");
+
+ config.addExternal(coreRoot + "/svg.js");
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dd503343/compiler/src/main/java/org/apache/flex/compiler/internal/caches/CSSDocumentCache.java
----------------------------------------------------------------------
diff --cc compiler/src/main/java/org/apache/flex/compiler/internal/caches/CSSDocumentCache.java
index be9e03b,0000000..3a8db86
mode 100644,000000..100644
--- a/compiler/src/main/java/org/apache/flex/compiler/internal/caches/CSSDocumentCache.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/internal/caches/CSSDocumentCache.java
@@@ -1,397 -1,0 +1,400 @@@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.caches;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.zip.ZipFile;
+
+import org.antlr.runtime.ANTLRFileStream;
+import org.antlr.runtime.ANTLRInputStream;
+import org.apache.commons.io.IOUtils;
+
+import org.apache.flex.compiler.config.Configuration;
+import org.apache.flex.compiler.css.ICSSDocument;
+import org.apache.flex.compiler.css.ICSSFontFace;
+import org.apache.flex.compiler.css.ICSSNamespaceDefinition;
+import org.apache.flex.compiler.css.ICSSNode;
+import org.apache.flex.compiler.css.ICSSRule;
+import org.apache.flex.compiler.internal.css.CSSDocument;
+import org.apache.flex.compiler.internal.css.CSSModelTreeType;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.swc.ISWC;
+import org.apache.flex.swc.io.SWCReader;
+import org.apache.flex.utils.FilenameNormalization;
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Cache for {@link ICSSDocument} at workspace level. The CSS model can be a
+ * "defaults.css" file inside a SWC library, or a CSS file on the disk.
+ * <p>
+ * The cache key is normalized path to the SWC file (optional) and the CSS file
+ * name inside the SWC. The cache value is an {@link ICSSDocument}.
+ */
+public class CSSDocumentCache extends ConcurrentCacheStoreBase<ICSSDocument>
+{
+
+ /**
+ * Since {@link ConcurrentCacheStoreBase#get} doesn't return compiler
+ * problems, when there's problem parsing CSS file in
+ * {@link #createEntryValue}, we have to throw a runtime exception to pass
+ * the compiler problems to the caller of the cache store.
+ */
+ public static class ProblemParsingCSSRuntimeException extends RuntimeException
+ {
+ private static final long serialVersionUID = 156921800741800866L;
+
+ public ProblemParsingCSSRuntimeException(final Collection<ICompilerProblem> problems)
+ {
+ super();
+ this.cssParserProblems = problems;
+ }
+
+ /**
+ * A collection of compiler problems from parsing the CSS file.
+ */
+ public final Collection<ICompilerProblem> cssParserProblems;
+ }
+
+ /**
+ * Since {@link ConcurrentCacheStoreBase} does not allow null values, when a
+ * SWC library does not have a "defaults.css" file, this dummy value is
+ * used.
+ */
+ public static final ICSSDocument EMPTY_CSS_DOCUMENT = new ICSSDocument()
+ {
+ @Override
+ public ImmutableList<ICSSRule> getRules()
+ {
+ return ImmutableList.of();
+ }
+
+ @Override
+ public ICSSNamespaceDefinition getNamespaceDefinition(String prefix)
+ {
+ return null;
+ }
+
+ @Override
+ public ImmutableList<ICSSFontFace> getFontFaces()
+ {
+ return ImmutableList.of();
+ }
+
+ @Override
+ public ICSSNamespaceDefinition getDefaultNamespaceDefinition()
+ {
+ return null;
+ }
+
+ @Override
+ public ImmutableList<ICSSNamespaceDefinition> getAtNamespaces()
+ {
+ return ImmutableList.of();
+ }
+
+ @Override
+ public String toStringTree()
+ {
+ return null;
+ }
+
+ @Override
+ public int getArity()
+ {
+ return 0;
+ }
+
+ @Override
+ public ICSSNode getNthChild(int index)
+ {
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public CSSModelTreeType getOperator()
+ {
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public String getSourcePath()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getStart()
+ {
+ return 0;
+ }
+
+ @Override
+ public int getEnd()
+ {
+ return 0;
+ }
+
+ @Override
+ public int getLine()
+ {
+ return 0;
+ }
+
+ @Override
+ public int getColumn()
+ {
+ return 0;
+ }
+
+ @Override
- public int getAbsoluteStart()
++ public int getEndLine()
+ {
+ return 0;
+ }
+
+ @Override
- public int getAbsoluteEnd()
++ public int getEndColumn()
+ {
+ return 0;
+ }
+
+ @Override
- public int getEndLine() {
++ public int getAbsoluteStart()
++ {
+ return 0;
+ }
+
+ @Override
- public int getEndColumn() {
++ public int getAbsoluteEnd()
++ {
+ return 0;
+ }
++
+ };
+
+ private abstract static class CSSDocumentCacheKeyBase extends CacheStoreKeyBase
+ {
+ abstract ICSSDocument parse() throws IOException;
+ }
+
+ /**
+ * Key object for {@code CSSDocumentCache}. It the combination of a
+ * normalized SWC file path and the CSS file inside the SWC. If the
+ * {@code swcFile} is null, the {@code cssFileName} points to a CSS disk
+ * file.
+ */
+ public static class CSSDocumentCacheKey extends CSSDocumentCacheKeyBase
+ {
+ public final ISWC swc;
+ public final String cssFileName;
+
+ public CSSDocumentCacheKey(final ISWC swc, final String cssFileName)
+ {
+ assert cssFileName != null : "CSS file name can't be null.";
+ this.swc = swc;
+ this.cssFileName = cssFileName;
+ }
+
+ @Override
+ public String generateKey()
+ {
+ return String.format(
+ "%s:%s",
+ FilenameNormalization.normalize(swc.getSWCFile()).getAbsolutePath(),
+ cssFileName);
+ }
+
+ /**
+ * Parse a CSS file in a SWC library into {@link ICSSDocument} model. If the
+ * CSS file does not exist, returns {@link #EMPTY_CSS_DOCUMENT} dummy
+ * object.
+ *
+ * @throws IOException IO error.
+ */
+ @Override
+ ICSSDocument parse() throws IOException
+ {
+ final ZipFile zipFile = new ZipFile(swc.getSWCFile(), ZipFile.OPEN_READ);
+ ICSSDocument result = EMPTY_CSS_DOCUMENT;
+ InputStream input = null;
+ try
+ {
+ input = SWCReader.getInputStream(zipFile, cssFileName);
+ if (input != null)
+ {
+ final ANTLRInputStream in = new ANTLRInputStream(input);
+ in.name = String.format("%s:%s", swc.getSWCFile().getName(), cssFileName);
+ final List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>();
+ result = CSSDocument.parse(in, problems);
+ if (!problems.isEmpty())
+ throw new ProblemParsingCSSRuntimeException(problems);
+ }
+ }
+ finally
+ {
+ IOUtils.closeQuietly(input);
+ zipFile.close();
+ }
+ return result;
+ }
+ }
+
+ /**
+ * Key object for {@code CSSDocumentCache}. It the combination of a
+ * normalized SWC file path and the CSS file inside the SWC. If the
+ * {@code swcFile} is null, the {@code cssFileName} points to a CSS disk
+ * file.
+ */
+ protected static class CSSDocumentCacheKey2 extends CSSDocumentCacheKeyBase
+ {
+ protected final String cssFileName; // non-null
+
+ public CSSDocumentCacheKey2(final String cssFileName)
+ {
+ assert cssFileName != null : "CSS file name can't be null.";
+ this.cssFileName = cssFileName;
+ }
+
+ @Override
+ public String generateKey()
+ {
+ return cssFileName;
+ }
+
+ /**
+ * parse a bare CSS file on the file system.
+ */
+ @Override
+ ICSSDocument parse() throws IOException
+ {
+ final List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>();
+ final CSSDocument css = CSSDocument.parse(new ANTLRFileStream(cssFileName), problems);
+ if (!problems.isEmpty())
+ throw new ProblemParsingCSSRuntimeException(problems);
+ if (css != null)
+ return css;
+ return EMPTY_CSS_DOCUMENT;
+ }
+ }
+
+ /**
+ * Create a cache key for {@code CSSDocumentCache} that references
+ * a CSS file in a SWC.
+ *
+ * @param swc SWC file
+ * @param cssFileName CSS file name
+ * @return Key for {@code CSSDocumentCache}.
+ */
+ public static CacheStoreKeyBase createKey(final ISWC swc, final String cssFileName)
+ {
+ return new CSSDocumentCacheKey(swc, cssFileName);
+ }
+
+ /**
+ * Create a cache key for {@code CSSDocumentCache} that references
+ * a CSS file on disk.
+ *
+ * @param cssFileName CSS file name
+ * @return Key for {@code CSSDocumentCache}.
+ */
+ public static CacheStoreKeyBase createKey(final String cssFileName)
+ {
+ return new CSSDocumentCacheKey2(cssFileName);
+ }
+
+ @Override
+ protected ICSSDocument createEntryValue(CacheStoreKeyBase key)
+ {
+ assert key instanceof CSSDocumentCacheKeyBase : "Expected 'CSSDocumentCacheKeyBase' but got " + key.getClass().getSimpleName();
+ final CSSDocumentCacheKeyBase cacheKey = (CSSDocumentCacheKeyBase)key;
+
+ ICSSDocument result = EMPTY_CSS_DOCUMENT;
+ try
+ {
+ result = cacheKey.parse();
+ }
+ catch (IOException e)
+ {
+ // Ignore exception and return dummy value.
+ }
+ return result;
+ }
+
+ public static String[] ALL_DEFAULTS_CSS_FILENAMES = {"defaults.css", "defaults-3.0.0.css" };
+
+ /**
+ * Get the compatible-mode default CSS filename.
+ *
+ * @param version Compatible version.
+ * @return Defaults CSS filename.
+ */
+ private static String getCompatibleModeCSSFilename(final Integer version)
+ {
+ if (version == null)
+ return "defaults.css";
+ else if (version <= Configuration.MXML_VERSION_3_0)
+ return "defaults-3.0.0.css";
+ else
+ return "defaults.css";
+ }
+
+ /**
+ * Get the "default" CSS model in a SWC library. If
+ * {@code compatibility-version=3} is set, this method will try to get
+ * "defaults-3.0.0.css" first. If the compatibility version isn't present,
+ * it will fall back to "defaults.css".
+ *
+ * @param swc SWC file.
+ * @param compatibilityVersion Compatibility version, or null if the
+ * compiler is not under compatibility mode.
+ * @return "defaults" CSS model or null if not found
+ */
+ public ICSSDocument getDefaultsCSS(final ISWC swc, final Integer compatibilityVersion)
+ {
+ final CacheStoreKeyBase key;
+ final String cssFilename = getCompatibleModeCSSFilename(compatibilityVersion);
+ key = createKey(swc, cssFilename);
+
+ final ICSSDocument css = this.get(key);
+ assert css != null : "ConcurrentCacheStoreBase never caches null value.";
+
+ if (css == CSSDocumentCache.EMPTY_CSS_DOCUMENT)
+ {
+ if (compatibilityVersion != null)
+ {
+ // If compatible CSS is not present, fall back to "defaults.css".
+ return getDefaultsCSS(swc, null);
+ }
+ else
+ {
+ return null;
+ }
+ }
+ else
+ {
+ return css;
+ }
+ }
+}
[02/19] git commit: [flex-falcon]
[refs/heads/feature/maven-migration-test] - FLEX-35081 need to handle MXML
case
Posted by cd...@apache.org.
FLEX-35081 need to handle MXML case
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/170ea47e
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/170ea47e
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/170ea47e
Branch: refs/heads/feature/maven-migration-test
Commit: 170ea47e6cf683b9304c1e4c34d3d9ee7c5bf9e3
Parents: 0b53749
Author: Alex Harui <ah...@apache.org>
Authored: Mon Apr 18 23:48:57 2016 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Mon Apr 18 23:49:08 2016 -0700
----------------------------------------------------------------------
.../internal/codegen/js/jx/BinaryOperatorEmitter.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/170ea47e/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
index aab9712..4beaf2f 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
@@ -115,8 +115,13 @@ public class BinaryOperatorEmitter extends JSSubEmitter implements
write(ASEmitterTokens.PAREN_OPEN);
IClassNode cnode = (IClassNode) node
.getAncestorOfType(IClassNode.class);
- write(getEmitter().formatQualifiedName(
+ if (cnode != null)
+ write(getEmitter().formatQualifiedName(
cnode.getQualifiedName()));
+ else
+ write(getEmitter().formatQualifiedName(
+ getModel().getCurrentClass().getQualifiedName()));
+
writeToken(ASEmitterTokens.COMMA);
write(ASEmitterTokens.THIS);
writeToken(ASEmitterTokens.COMMA);
[17/19] git commit: [flex-falcon]
[refs/heads/feature/maven-migration-test] - - Renamed the "generate" goal to
"generate-extern" - Replicated the changes to the node extern to match the
develop branch - Fixed the replace commands in js to generate an ide
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dd503343/compiler/src/main/java/org/apache/flex/compiler/internal/parsing/as/StreamingASTokenizer.java
----------------------------------------------------------------------
diff --cc compiler/src/main/java/org/apache/flex/compiler/internal/parsing/as/StreamingASTokenizer.java
index 61b6e26,0000000..1c90e94
mode 100644,000000..100644
--- a/compiler/src/main/java/org/apache/flex/compiler/internal/parsing/as/StreamingASTokenizer.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/internal/parsing/as/StreamingASTokenizer.java
@@@ -1,1871 -1,0 +1,1884 @@@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.parsing.as;
+
+import java.io.Closeable;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Stack;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.flex.compiler.clients.ASC;
+import org.apache.flex.compiler.constants.IASKeywordConstants;
+import org.apache.flex.compiler.filespecs.IFileSpecification;
+import org.apache.flex.compiler.internal.parsing.ITokenStreamFilter;
+import org.apache.flex.compiler.internal.parsing.SourceFragmentsReader;
+import org.apache.flex.compiler.internal.parsing.TokenBase;
+import org.apache.flex.compiler.internal.units.ASCompilationUnit;
+import org.apache.flex.compiler.parsing.IASToken;
+import org.apache.flex.compiler.parsing.IASTokenizer;
+import org.apache.flex.compiler.parsing.IASToken.ASTokenKind;
+import org.apache.flex.compiler.problems.CyclicalIncludesProblem;
+import org.apache.flex.compiler.problems.ExpectXmlBeforeNamespaceProblem;
+import org.apache.flex.compiler.problems.FileNotFoundProblem;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.problems.InternalCompilerProblem2;
+import org.apache.flex.compiler.problems.UnexpectedTokenProblem;
+import org.apache.flex.utils.ILengthAwareReader;
+import org.apache.flex.utils.NonLockingStringReader;
+import org.apache.flex.utils.ILengthAwareReader.InputType;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * This Tokenizer provides tokens to be used by various clients, most notably
+ * the ASParser. Given the nature of ambiguities in the ActionScript 3 language,
+ * this tokenizer also serves to disambiguate tokens based on a combination of
+ * look behind and lookahead. For all cases of ambiguity, only one token is
+ * needed for look behind, and in our worst case, n tokens forwards where n is
+ * the number of tokens that can be produced. Some other state is kept in order
+ * to know which type of container we may exist in (function, class, interface,
+ * etc). We buffer LA token results to avoid unneeded lookahead
+ */
+public class StreamingASTokenizer implements ASTokenTypes, IASTokenizer, Closeable
+{
+ private static final String FOR_EACH = "for each";
+ private static final String XML = "xml";
+ private static final String DEFAULT_XML_NAMESPACE = "default xml namespace";
+ private static final String ZERO = "0";
+
+ /**
+ * Map from keyword text to token type.
+ * <p>
+ * We use a HashMap here to avoid slowing down the performance of the
+ * underlying lexer. We are avoid the "longest match" problem, requiring a
+ * lot of rescanning on the lexer level to determine keywords from
+ * identifiers. And since hash map lookup is constant, this is (in theory)
+ * faster than doing this in the scanner since we're not bound by i/o or
+ * state machine back-tracing.
+ */
+ private static final Map<String, Integer> keywordToTokenMap = new ImmutableMap.Builder<String, Integer>()
+ .put(IASKeywordConstants.AS, TOKEN_KEYWORD_AS)
+ .put(IASKeywordConstants.IS, TOKEN_KEYWORD_IS)
+ .put(IASKeywordConstants.INSTANCEOF, TOKEN_KEYWORD_INSTANCEOF)
+ .put(IASKeywordConstants.IN, TOKEN_KEYWORD_IN)
+ .put(IASKeywordConstants.DELETE, TOKEN_KEYWORD_DELETE)
+ .put(IASKeywordConstants.TYPEOF, TOKEN_KEYWORD_TYPEOF)
+ .put(IASKeywordConstants.CONST, TOKEN_KEYWORD_CONST)
+ .put(IASKeywordConstants.GET, TOKEN_RESERVED_WORD_GET)
+ .put(IASKeywordConstants.IMPLEMENTS, TOKEN_RESERVED_WORD_IMPLEMENTS)
+ .put(IASKeywordConstants.IMPORT, TOKEN_KEYWORD_IMPORT)
+ .put(IASKeywordConstants.USE, TOKEN_KEYWORD_USE)
+ .put(IASKeywordConstants.EXTENDS, TOKEN_RESERVED_WORD_EXTENDS)
+ .put(IASKeywordConstants.NEW, TOKEN_KEYWORD_NEW)
+ .put(IASKeywordConstants.DYNAMIC, TOKEN_MODIFIER_DYNAMIC)
+ .put(IASKeywordConstants.FINAL, TOKEN_MODIFIER_FINAL)
+ .put(IASKeywordConstants.NATIVE, TOKEN_MODIFIER_NATIVE)
+ .put(IASKeywordConstants.OVERRIDE, TOKEN_MODIFIER_OVERRIDE)
+ .put(IASKeywordConstants.STATIC, TOKEN_MODIFIER_STATIC)
+ .put(IASKeywordConstants.VIRTUAL, TOKEN_MODIFIER_VIRTUAL)
+ .put(IASKeywordConstants.SET, TOKEN_RESERVED_WORD_SET)
+ // Keywords with special token types that affect subsequent blocks
+ .put(IASKeywordConstants.CATCH, TOKEN_KEYWORD_CATCH)
+ .put(IASKeywordConstants.CLASS, TOKEN_KEYWORD_CLASS)
+ .put(IASKeywordConstants.FUNCTION, TOKEN_KEYWORD_FUNCTION)
+ .put(IASKeywordConstants.INTERFACE, TOKEN_KEYWORD_INTERFACE)
+ .put(IASKeywordConstants.PACKAGE, TOKEN_KEYWORD_PACKAGE)
+ // #120009: allow "var" inside parameter list, even though it's not
+ // valid AS (don't turn the subsequent function block open into a block open
+ .put(IASKeywordConstants.VAR, TOKEN_KEYWORD_VAR)
+ .put(IASKeywordConstants.FALSE, TOKEN_KEYWORD_FALSE)
+ .put(IASKeywordConstants.NULL, TOKEN_KEYWORD_NULL)
+ .put(IASKeywordConstants.TRUE, TOKEN_KEYWORD_TRUE)
+ .put(IASKeywordConstants.PUBLIC, HIDDEN_TOKEN_BUILTIN_NS)
+ .put(IASKeywordConstants.PRIVATE, HIDDEN_TOKEN_BUILTIN_NS)
+ .put(IASKeywordConstants.PROTECTED, HIDDEN_TOKEN_BUILTIN_NS)
+ .put(IASKeywordConstants.INTERNAL, HIDDEN_TOKEN_BUILTIN_NS)
+ .put(IASKeywordConstants.INCLUDE, TOKEN_KEYWORD_INCLUDE)
+ // Keywords for statements that affect subsequent blocks
+ .put(IASKeywordConstants.DO, TOKEN_KEYWORD_DO)
+ .put(IASKeywordConstants.WHILE, TOKEN_KEYWORD_WHILE)
+ .put(IASKeywordConstants.BREAK, TOKEN_KEYWORD_BREAK)
+ .put(IASKeywordConstants.CONTINUE, TOKEN_KEYWORD_CONTINUE)
+ .put(IASKeywordConstants.GOTO, TOKEN_RESERVED_WORD_GOTO)
+ .put(IASKeywordConstants.FOR, TOKEN_KEYWORD_FOR)
+ .put(StreamingASTokenizer.FOR_EACH, TOKEN_KEYWORD_FOR)
+ .put(IASKeywordConstants.EACH, TOKEN_RESERVED_WORD_EACH)
+ .put(IASKeywordConstants.WITH, TOKEN_KEYWORD_WITH)
+ .put(IASKeywordConstants.ELSE, TOKEN_KEYWORD_ELSE)
+ .put(IASKeywordConstants.IF, TOKEN_KEYWORD_IF)
+ .put(IASKeywordConstants.SWITCH, TOKEN_KEYWORD_SWITCH)
+ .put(IASKeywordConstants.CASE, TOKEN_KEYWORD_CASE)
+ .put(IASKeywordConstants.DEFAULT, TOKEN_KEYWORD_DEFAULT)
+ .put(IASKeywordConstants.TRY, TOKEN_KEYWORD_TRY)
+ .put(IASKeywordConstants.FINALLY, TOKEN_KEYWORD_FINALLY)
+ // Keywords with a generic keyword token type that have no effect
+ // on subsequent blocks.
+ .put(IASKeywordConstants.NAMESPACE, TOKEN_RESERVED_WORD_NAMESPACE)
+ .put(IASKeywordConstants.CONFIG, TOKEN_RESERVED_WORD_CONFIG)
+ .put(IASKeywordConstants.THROW, TOKEN_KEYWORD_THROW)
+ .put(IASKeywordConstants.SUPER, TOKEN_KEYWORD_SUPER)
+ .put(IASKeywordConstants.THIS, TOKEN_KEYWORD_THIS)
+ .put(IASKeywordConstants.VOID, TOKEN_KEYWORD_VOID)
+ .put(IASKeywordConstants.RETURN, TOKEN_KEYWORD_RETURN)
+ .build();
+
+ /**
+ * Configuration for out tokenizer
+ */
+ private static final class TokenizerConfig
+ {
+ /**
+ * Flag that lets us ignore keywords for more general string parsing
+ */
+ public boolean ignoreKeywords = false;
+
+ /**
+ * Flag that lets us be aware of metadata
+ */
+ public boolean findMetadata = true;
+
+ /**
+ * Flag indicating that we are tokenizing full content/files, and not
+ * segments
+ */
+ public boolean completeContent = true;
+
+ /**
+ * IFilter for old APIs
+ */
+ public ITokenStreamFilter filter;
+
+ /**
+ * Flag indicating we should collect comments
+ */
+ public boolean collectComments = false;
+
+ /**
+ * Flag indicating we follow include statements, including their tokens
+ */
+ public boolean followIncludes = true;
+ }
+
+ private Reader reader;
+
+ //underlying lexer
+ private RawASTokenizer tokenizer;
+
+ //last exception to prevent us from looping forever
+ private Exception lastException = null;
+
+ //LA buffer
+ private final List<ASToken> lookAheadBuffer;
+ private int bufferSize = 0; //maintain size ourselves since it's faster
+
+ //last token we encountered, used for lookback
+ private ASToken lastToken;
+
+ private int offsetAdjustment; //for offset adjustment
+ private int lineAdjustment = 0;
+ private int columnAdjustment = 0;
+
+ private IncludeHandler includeHandler;
+
+ /**
+ * The forked tokenizer for included files. If not null, {@link #next()}
+ * will return a token from this tokenizer.
+ * <p>
+ * After all the tokens are returned from the included source file,
+ * {@link #closeIncludeTokenizer()} closes the tokenizer and set this field
+ * to null.
+ */
+ private StreamingASTokenizer forkIncludeTokenizer;
+
+ /**
+ * Flag to indicate if we have followed include statements
+ */
+ private boolean hasEncounteredIncludeStatements = false;
+
+ private TokenizerConfig config;
+
+ /**
+ * Source file handler. This is used by resolving included file path.
+ * {@link #StreamingASTokenizer(IFileSpecification)} and
+ * {@link #StreamingASTokenizer(IFileSpecification, Stack)} sets the value.
+ */
+ private String sourcePath;
+
+ /**
+ * Lexer problems.
+ * */
+ private final List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>();
+
+ /**
+ * Imaginary tokens generated for {@code asc -in} option.
+ */
+ private Iterator<ASToken> ascIncludeImaginaryTokens;
+
+ /**
+ * You should probably not use this constructor. There is some legacy code
+ * that uses this constructor, but that code should be updated to use one of
+ * the static create methods below.
+ * <p>
+ * TODO: make this private.
+ */
+ public StreamingASTokenizer(final Reader reader)
+ {
+ this();
+ setReader(reader);
+ }
+
+ /**
+ * A pool to reduce duplicated string literals created
+ */
+ private final HashMap<String, String> stringPool;
+
+ /**
+ * You should probably not use this constructor. There is a lot of code that
+ * uses this constructor, but that code should be updated to use one of the
+ * static create methods below.
+ * <p>
+ * TODO: make this private.
+ */
+ public StreamingASTokenizer()
+ {
+ tokenizer = new RawASTokenizer();
+ config = new TokenizerConfig();
+ lookAheadBuffer = new ArrayList<ASToken>(5);
+ includeHandler = IncludeHandler.creatDefaultIncludeHandler();
+ stringPool = new HashMap<String, String>();
+
+ // Initialize string pool with keyword strings. The keyword strings
+ // are declared as constants which are automatically "interned".
+ for (final String keyword : keywordToTokenMap.keySet())
+ {
+ stringPool.put(keyword, keyword);
+ }
+ }
+
+ /**
+ * Creates a tokenizer suitable for the mxml indexing code. fragments the
+ * new tokenizer will tokenize.
+ *
+ * @return A new tokenizer suitable for tokenizing script fragments in an
+ * mxml document that is being tokenized for the full text search index.
+ */
+ public static StreamingASTokenizer createForMXMLIndexing(String fileName)
+ {
+ StreamingASTokenizer result = new StreamingASTokenizer();
+ result.setPath(fileName);
+ result.includeHandler.enterFile(result.sourcePath);
+ return result;
+ }
+
+ /**
+ * Fork a new tokenizer when an "include" directive is found. This method
+ * will pass the {@code StructureTracker} of the current tokenizer down to
+ * the forked tokenizer.
+ *
+ * @param currentTokenizer Current tokenizer.
+ * @param fileSpec File specification of the included file.
+ * @param includeHandler Include handler.
+ * @return A tokenizer for the included file.
+ * @throws FileNotFoundException Error.
+ */
+ private static StreamingASTokenizer createForIncludeFile(
+ final StreamingASTokenizer currentTokenizer,
+ final IFileSpecification fileSpec,
+ final IncludeHandler includeHandler)
+ throws FileNotFoundException
+ {
+ final StreamingASTokenizer tokenizer = create(fileSpec, includeHandler);
+ return tokenizer;
+ }
+
+ /**
+ * Create a tokenizer from a source file. This is the lexer entry-point used
+ * by {@link ASCompilationUnit}.
+ *
+ * @param fileSpec File specification provides the reader and the file path.
+ * @param includeHandler Include handler.
+ * @throws FileNotFoundException error
+ */
+ protected static StreamingASTokenizer create(
+ final IFileSpecification fileSpec,
+ final IncludeHandler includeHandler)
+ throws FileNotFoundException
+ {
+ assert fileSpec != null : "File specification can't be null.";
+ assert includeHandler != null : "Include handler can't be null.";
+
+ final StreamingASTokenizer tokenizer = new StreamingASTokenizer();
+ tokenizer.setReader(fileSpec.createReader());
+ tokenizer.setPath(fileSpec.getPath());
+ tokenizer.includeHandler = includeHandler;
+ tokenizer.includeHandler.enterFile(tokenizer.sourcePath);
+ return tokenizer;
+ }
+
+ /**
+ * Create a tokenizer for {@code ASParser#parseFile()}.
+ *
+ * @param fileSpec File specification provides the reader and the file path.
+ * @param includeHandler Include handler.
+ * @param followIncludes True if included files are also parsed.
+ * @param includedFiles A list of included file paths.
+ * @return Lexer.
+ * @throws FileNotFoundException error
+ */
+ protected static StreamingASTokenizer createForASParser(
+ final IFileSpecification fileSpec,
+ final IncludeHandler includeHandler,
+ final boolean followIncludes,
+ final List<String> includedFiles)
+ throws FileNotFoundException
+ {
+ final StreamingASTokenizer tokenizer = create(fileSpec, includeHandler);
+ tokenizer.setFollowIncludes(followIncludes);
+
+ final ImmutableList.Builder<ASToken> imaginaryTokensBuilder =
+ new ImmutableList.Builder<ASToken>();
+ for (final String filename : includedFiles)
+ {
+ imaginaryTokensBuilder.add(new ASToken(
+ ASTokenTypes.TOKEN_KEYWORD_INCLUDE,
+ 0,
+ 0,
+ 0,
+ 0,
+ "include"));
+ imaginaryTokensBuilder.add(new ASToken(
+ ASTokenTypes.TOKEN_LITERAL_STRING,
+ 0,
+ 0,
+ 0,
+ 0,
+ '"' + filename + '"'));
+ }
+ tokenizer.ascIncludeImaginaryTokens = imaginaryTokensBuilder.build().iterator();
+ return tokenizer;
+ }
+
+ /**
+ * This creator doesn't "enter file" on creation.
+ */
+ protected static StreamingASTokenizer createForInlineScriptScopeBuilding(
+ final Reader reader,
+ final String path,
+ final IncludeHandler includeHandler,
+ final int offsetAdjustment,
+ final int lineAdjustment,
+ final int columnAdjustment)
+ {
+ assert reader != null : "Reader can't be null";
+ assert path != null : "Path can't be null";
+ assert includeHandler != null : "IncludeHandler can't be null";
+
+ final StreamingASTokenizer tokenizer = new StreamingASTokenizer();
+ tokenizer.setReader(reader);
+ tokenizer.setPath(path);
+ tokenizer.includeHandler = includeHandler;
+ tokenizer.setSourcePositionAdjustment(
+ offsetAdjustment, lineAdjustment, columnAdjustment);
+ return tokenizer;
+ }
+
+ /**
+ * Create a tokenizer to parse an Expression.
+ */
+ protected static StreamingASTokenizer createForInlineExpressionParsing(
+ final Reader reader,
+ final String path
+ )
+ {
+ assert reader != null : "Reader can't be null";
+ assert path != null : "Path can't be null";
+
+ final StreamingASTokenizer tokenizer = new StreamingASTokenizer();
+ tokenizer.setReader(reader);
+ tokenizer.setPath(path);
+ tokenizer.includeHandler.enterFile(path);
+
+ // Have to do this to get the tokenizer to work right - some things, like function expressions,
+ // won't tokenize correctly unless the last token is '=' or some other special tokens.
+ tokenizer.lastToken = new ASToken(ASTokenTypes.TOKEN_OPERATOR_ASSIGNMENT, -1, -1, -1, -1, "=");
+
+ return tokenizer;
+ }
+
+ /**
+ * This method can create a {@code StreamingASTokenizer} with optional
+ * "follow includes". If {@code IncludeHandler} is not null, it will follow
+ * {@code include} directives.
+ *
+ * @param reader Input to the tokenizer.
+ * @param path File path of the input.
+ * @param includeHandler If not null, the created tokenizer will follow
+ * {@code include} directives.
+ * @return A {@code StreamingASTokenizer}.
+ */
+ public static StreamingASTokenizer createForRepairingASTokenizer(
+ final Reader reader,
+ final String path,
+ final IncludeHandler includeHandler)
+ {
+ assert path != null || includeHandler == null : "We need a source path to follow includes";
+ final StreamingASTokenizer tokenizer = new StreamingASTokenizer();
+ tokenizer.setReader(reader);
+ tokenizer.setPath(path);
+ if (includeHandler != null)
+ {
+ tokenizer.includeHandler = includeHandler;
+ includeHandler.enterFile(path);
+ }
+ return tokenizer;
+ }
+
+ /**
+ * Sets the {@link Reader} that supplies the content to this tokenizer. It
+ * is up to the client to close any previous readers that have been in use.
+ * It is also up to the client to close the reader once it has been used
+ *
+ * @param reader a {@link Reader}
+ */
+ public void setReader(final Reader reader)
+ {
+ setReader(reader, 0, 0, 0);
+ }
+
+ /**
+ * Sets the {@link Reader} that supplies the content to this tokenizer. It
+ * is up to the client to close any previous readers that have been in use.
+ * It is also up to the client to close the reader once it has been used
+ *
+ * @param reader a {@link Reader}
+ * @param offset Offset adjustment. If the specified reader is reading from
+ * a string extracted from a source file, this should be the offset of the
+ * first character read from the reader in the source file.
+ * @param line Line adjustment.
+ * @param column Column adjustment
+ */
+ public void setReader(final Reader reader, int offset, int line, int column)
+ {
+ this.reader = reader;
+ tokenizer = new RawASTokenizer();
+ tokenizer.yyreset(reader);
+ tokenizer.setCollectComments(config.collectComments);
+ setSourcePositionAdjustment(offset, line, column);
+ }
+
+ /**
+ * Sets the path to the file this tokenizer is scanning
+ *
+ * @param path a file path
+ */
+ @Override
+ public void setPath(String path)
+ {
+ assert path != null : "path of tokenizer shouldn't be null";
+ sourcePath = path;
+ tokenizer.setSourcePath(path);
+ }
+
+ /**
+ * Allows for the adjustment of offset, line and column information when
+ * parsing subsequences of text. This should be called before tokenization
+ * has started
+ *
+ * @param offset The offset where the fragment starts.
+ * @param line The line where the fragment starts. This should be a
+ * ZERO-based line number
+ * @param column The column where the fragment starts. This should be a
+ * ZERO-based column number
+ */
+ public void setSourcePositionAdjustment(int offset, int line, int column)
+ {
+ offsetAdjustment = offset;
+ lineAdjustment = line;
+ columnAdjustment = column;
+ }
+
+ /**
+ * Sets whether we comments are collected: single line and multi-line.
+ * Default is <code>false</code>
+ *
+ * @param collect true if we should collect comments
+ */
+ @Override
+ public void setCollectComments(final boolean collect)
+ {
+ config.collectComments = collect;
+
+ if (tokenizer != null)
+ tokenizer.setCollectComments(collect);
+ }
+
+ /**
+ * Sets whether we follow include statements, including their tokens.
+ * Default is <code>true</code>
+ *
+ * @param followIncludes true if we should follow includes
+ */
+ @Override
+ public void setFollowIncludes(final boolean followIncludes)
+ {
+ config.followIncludes = followIncludes;
+ }
+
+ /**
+ * Closes the underlying reader
+ */
+ @Override
+ public void close() throws IOException
+ {
+ if (tokenizer != null)
+ {
+ tokenizer.reset();
+ tokenizer.yyclose(); //close the reader
+ }
+ }
+
+ /**
+ * Sets whether we ignore keywords while scanning. Default is
+ * <code>false</code>
+ *
+ * @param ignore true if we should ignore keywords
+ */
+ public void setIgnoreKeywords(final boolean ignore)
+ {
+ config.ignoreKeywords = ignore;
+ }
+
+ /**
+ * Sets whether we are scanning a full file, or a fragment. Default is
+ * <code>true</code>
+ *
+ * @param full true if we are scanning a full file.
+ */
+ public void setScanningFullContent(final boolean full)
+ {
+ config.completeContent = full;
+ }
+
+ /**
+ * Sets whether we will find metadata constructs Default is
+ * <code>true</code>
+ *
+ * @param aware true if we will find metadata
+ */
+ public void setIsMetadataAware(final boolean aware)
+ {
+ config.findMetadata = aware;
+ }
+
+ /**
+ * Sets the {@link ITokenStreamFilter} used to filter out unwanted tokens
+ *
+ * @param filter the token filter to alter the stream returned from the
+ * tokenizer
+ */
+ public void setTokenFilter(ITokenStreamFilter filter)
+ {
+ config.filter = filter;
+ }
+
+ /**
+ * Sets the include handler used by this tokenizer to get
+ * {@link IFileSpecification} for included files.
+ *
+ * @param handler {@link IncludeHandler} this tokenizer should use.
+ */
+ public void setIncludeHandler(IncludeHandler handler)
+ {
+ includeHandler = handler;
+ }
+
+ /**
+ * Indicated that we have tokenization problems. Can be called once scanning
+ * has begun
+ *
+ * @return true if problems have been encountered
+ */
+ public boolean hasTokenizationProblems()
+ {
+ return tokenizer.hasProblems() || problems.size() > 0;
+ }
+
+ /**
+ * Indicated whether this tokenizer has encountered include statements,
+ * regardless of whether it is set to follow them or not
+ *
+ * @return true if we have encountered includes
+ */
+ public boolean hasEncounteredIncludeStatements()
+ {
+ return hasEncounteredIncludeStatements;
+ }
+
+ /**
+ * Returns a collection of problems that have been encountered while
+ * scanning.
+ *
+ * @return a list of problems, never null
+ */
+ public List<ICompilerProblem> getTokenizationProblems()
+ {
+ ArrayList<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(this.problems);
+ problems.addAll(tokenizer.getProblems());
+ return problems;
+ }
+
+ public ASToken[] getTokens(final Reader reader, ITokenStreamFilter filter)
+ {
+ setReader(reader);
+ List<ASToken> tokenList = initializeTokenList(reader);
+ ASToken token = null;
+ do
+ {
+ token = next();
+ if (token != null && filter.accept(token))
+ tokenList.add(token.clone()); //make a copy because of object pool
+ }
+ while (token != null);
+ return tokenList.toArray(new ASToken[0]);
+ }
+
+ @Override
+ public ASToken[] getTokens(final Reader reader)
+ {
+ if (config.filter != null)
+ return getTokens(reader, config.filter);
+ setReader(reader);
+ List<ASToken> tokenList = initializeTokenList(reader);
+ ASToken token = null;
+ do
+ {
+ token = next();
+ if (token != null)
+ tokenList.add(token.clone()); //copy ctor because of object pool
+ }
+ while (token != null);
+ return tokenList.toArray(new ASToken[0]);
+ }
+
+ /**
+ * @param reader
+ * @return
+ */
+ private List<ASToken> initializeTokenList(final Reader reader)
+ {
+ List<ASToken> tokenList;
+ int listSize = 8012;
+ if (reader instanceof NonLockingStringReader)
+ {
+ //we know the length of this string. For string of length x, their are roughly x/5 tokens that
+ //can be constructed from that string. size the array appropriately.
+ listSize = 5;
+ if (((NonLockingStringReader)reader).getLength() > 0)
+ {
+ listSize = Math.max((int)((NonLockingStringReader)reader).getLength() / 5, 5);
+ }
+
+ }
+ else if (reader instanceof ILengthAwareReader && ((ILengthAwareReader)reader).getInputType() == InputType.FILE)
+ {
+ listSize = 9;
+ if (((ILengthAwareReader)reader).getLength() > 0)
+ {
+ listSize = Math.max((int)((ILengthAwareReader)reader).getLength() / 9, 9);
+
+ }
+ }
+ tokenList = new ArrayList<ASToken>(listSize);
+ return tokenList;
+ }
+
+ @Override
+ public IASToken[] getTokens(final String range)
+ {
+ return getTokens(new NonLockingStringReader(range));
+ }
+
+ /**
+ * Returns the next token that can be produced from the underlying reader
+ *
+ * @param filter an {@link ITokenStreamFilter} to restrict the tokens that
+ * are returned
+ * @return an ASToken, or null if no more tokens can be produced
+ */
+ public final ASToken next(final ITokenStreamFilter filter)
+ {
+ ASToken retVal = null;
+ while (true)
+ {
+ retVal = next();
+ if (retVal == null || filter.accept(retVal))
+ {
+ break;
+ }
+ }
+ return retVal;
+ }
+
+ /**
+ * Returns the next token that can be produced from the underlying reader.
+ * <p>
+ * If the forked "include file tokenizer" is open (not null), return the
+ * next token from it. If the forked tokenizer reaches the end of the
+ * included file, close (set to null) the forked tokenizer and return token
+ * from the main source file.
+ *
+ * @return an ASToken, or null if no more tokens can be produced
+ */
+ public final ASToken next()
+ {
+ ASToken retVal = null;
+ // If the lexer for the included file is open, read from the included tokenizer.
+ boolean consumeSemi = false;
+ try
+ {
+ // Return token from the main file.
+ if (forkIncludeTokenizer != null)
+ {
+ retVal = forkIncludeTokenizer.next();
+
+ // Check if the forked tokenizer reached EOF.
+ if (retVal == null)
+ {
+ closeIncludeTokenizer();
+ // We should consume the next semicolon we find.
+ // Most include statements are terminated with a semicolon,
+ // and because we read the contents of the included file,
+ // this could cause problems with a semicolon in a place
+ // we don't want it.
+ consumeSemi = true;
+ }
+ else
+ return retVal;
+ }
+ if (bufferSize > 0)
+ {
+ retVal = lookAheadBuffer.remove(0);
+ bufferSize--;
+ }
+ else
+ {
+ retVal = nextTokenFromReader();
+
+ }
+ if (retVal == null)
+ return null;
+ final int tokenType = retVal.getType();
+
+ switch (tokenType)
+ {
+ // if we're seeing each in this part of the loop, it's not a
+ // syntactic keyword
+ // since we do lookahead when we see "for", checking for "each"
+ case TOKEN_RESERVED_WORD_EACH:
+ treatKeywordAsIdentifier(retVal);
+ processUserDefinedNamespace(retVal, 0);
+ return retVal;
+ case TOKEN_KEYWORD_INCLUDE:
+ {
+ // "followIncludes=false" is usually used for code model
+ // partitioner. They want the "include" token.
+ if (!config.followIncludes)
+ return retVal;
+
+ final ASToken token = LT(1);
+
+ // "include" at EOF is always a keyword
+ if (token == null)
+ return retVal;
+
+ if (!matches(token, TOKEN_LITERAL_STRING))
+ {
+ treatKeywordAsIdentifier(retVal); // it's an identifier
+ processUserDefinedNamespace(retVal, 0);
+ }
+ else
+ {
+ hasEncounteredIncludeStatements = true;
+ // Consume the file path after the include token.
+ consume(1);
+ final String filenameTokenText = token.getText();
+ final String includeString = filenameTokenText.substring(1, filenameTokenText.length() - 1);
+
+ if (sourcePath == null)
+ throw new NullPointerException("Source file is needed for resolving included file path.");
+ IFileSpecification includedFileSpec = null;
+ //respond to problems from our file handler
+ includedFileSpec = includeHandler.getFileSpecificationForInclude(sourcePath, includeString);
+ //
+ if (includedFileSpec == null)
+ {
+ ICompilerProblem problem = new FileNotFoundProblem(token, filenameTokenText); //the text will be the path not found
+ problems.add(problem);
+ retVal = next();
+ return retVal;
+ }
+ if (includeHandler.isCyclicInclude(includedFileSpec.getPath()))
+ {
+ ICompilerProblem problem = new CyclicalIncludesProblem(token);
+ problems.add(problem);
+ retVal = next();
+ return retVal;
+ }
+ else
+ {
+ // Fork a tokenizer for the included file
+ try
+ {
+ forkIncludeTokenizer = createForIncludeFile(this, includedFileSpec, includeHandler);
+ retVal = forkIncludeTokenizer.next();
+ }
+ catch (FileNotFoundException fnfe)
+ {
+ includeHandler.handleFileNotFound(includedFileSpec);
+ ICompilerProblem problem = new FileNotFoundProblem(token, includedFileSpec.getPath());
+ problems.add(problem);
+ retVal = next();
+ return retVal;
+ }
+ }
+ }
+
+ // Recover from compiler problems and continue.
+ if (retVal == null)
+ {
+ // Included file is empty.
+ closeIncludeTokenizer();
+ // Fall back to main source.
+ retVal = this.next();
+ }
+ return retVal;
+ }
+ case TOKEN_RESERVED_WORD_CONFIG:
+ if (matches(LT(1), TOKEN_RESERVED_WORD_NAMESPACE))
+ { //we config namespace
+ retVal.setType(TOKEN_RESERVED_WORD_CONFIG);
+ return retVal;
+ }
+ treatKeywordAsIdentifier(retVal); //identifier
+ processUserDefinedNamespace(retVal, 0);
+ return retVal;
+ case HIDDEN_TOKEN_BUILTIN_NS:
+ if (matches(LT(1), TOKEN_OPERATOR_NS_QUALIFIER))
+ { //we have public:: and this structure is not an annotation but a name ref
+ retVal.setType(TOKEN_NAMESPACE_NAME);
+ return retVal;
+ }
+ retVal.setType(TOKEN_NAMESPACE_ANNOTATION);
+ return retVal;
+ case TOKEN_MODIFIER_DYNAMIC:
+ case TOKEN_MODIFIER_FINAL:
+ case TOKEN_MODIFIER_NATIVE:
+ case TOKEN_MODIFIER_OVERRIDE:
+ case TOKEN_MODIFIER_STATIC:
+ case TOKEN_MODIFIER_VIRTUAL:
+ {
+ // previous token is either a modifier or a namespace, or if
+ // null, assume keyword
+ // next token is from a definition or a modifier or a namespace
+ final ASToken nextToken = LT(1);
+ if (nextToken != null)
+ {
+ switch (nextToken.getType())
+ {
+ case TOKEN_KEYWORD_CLASS:
+ case TOKEN_KEYWORD_FUNCTION:
+ case TOKEN_KEYWORD_INTERFACE:
+ case TOKEN_RESERVED_WORD_NAMESPACE:
+ case TOKEN_KEYWORD_VAR:
+ case TOKEN_KEYWORD_CONST:
+ case TOKEN_MODIFIER_DYNAMIC:
+ case TOKEN_MODIFIER_FINAL:
+ case TOKEN_MODIFIER_NATIVE:
+ case TOKEN_MODIFIER_OVERRIDE:
+ case TOKEN_MODIFIER_STATIC:
+ case TOKEN_MODIFIER_VIRTUAL:
+ case TOKEN_NAMESPACE_ANNOTATION:
+ case TOKEN_NAMESPACE_NAME:
+ case HIDDEN_TOKEN_BUILTIN_NS:
+ return retVal;
+ case TOKEN_IDENTIFIER:
+ if (isUserDefinedNamespace(nextToken, 1)) // we're already looking ahead one so make sure we look ahead one further
+ return retVal;
+ default:
+ // Not applicable to other token types.
+ break;
+ }
+ }
+ treatKeywordAsIdentifier(retVal);
+ processUserDefinedNamespace(retVal, 0);
+ return retVal;
+ }
+ //we combine +/- for numeric literals here
+ case TOKEN_OPERATOR_MINUS:
+ case TOKEN_OPERATOR_PLUS:
+ {
+ if (lastToken == null || !lastToken.canPreceedSignedOperator())
+ {
+ final ASToken nextToken = LT(1);
+ if (nextToken != null)
+ {
+ switch (nextToken.getType())
+ {
+ case TOKEN_LITERAL_NUMBER:
+ case TOKEN_LITERAL_HEX_NUMBER:
+ retVal.setEnd(nextToken.getEnd());
+ final StringBuilder builder = new StringBuilder(retVal.getText());
+ builder.append(nextToken.getText());
+ retVal.setText(poolString(builder.toString()));
+ consume(1);
+ retVal.setType(nextToken.getType());
+ break;
+ default:
+ // ignore other tokens
+ break;
+ }
+ }
+ }
+
+ return retVal;
+ }
+ //RECOGNIZE: for each
+ case TOKEN_KEYWORD_FOR:
+ {
+ final ASToken token = LT(1);
+ if (matches(token, TOKEN_RESERVED_WORD_EACH))
+ {
+ retVal.setEnd(token.getEnd());
+ retVal.setText(FOR_EACH);
+ consume(1);
+ return retVal;
+ }
+ if (lastToken != null)
+ {
+ int lastTokenType = lastToken.getType();
+ switch (lastTokenType)
+ {
+ case TOKEN_KEYWORD_VAR:
+ case TOKEN_KEYWORD_FUNCTION:
+ case TOKEN_RESERVED_WORD_GET:
+ case TOKEN_RESERVED_WORD_SET:
+ case TOKEN_OPERATOR_MEMBER_ACCESS:
+ retVal.setType(TOKEN_IDENTIFIER);
+ }
+ }
+ return retVal;
+ }
+ //RECOGNIZE: default xml namespace
+ //default xml namespace must exist on the same line
+ case TOKEN_KEYWORD_DEFAULT:
+ {
+ final ASToken maybeNS = LT(2);
+ final boolean foundTokenNamespace = maybeNS != null &&
+ maybeNS.getType() == TOKEN_RESERVED_WORD_NAMESPACE;
+ final ASToken maybeXML = LT(1);
+ if (foundTokenNamespace)
+ {
+ final boolean foundTokenXML = maybeXML != null &&
+ maybeXML.getType() == TOKEN_IDENTIFIER &&
+ XML.equals(maybeXML.getText());
+ if (!foundTokenXML)
+ {
+ final ICompilerProblem problem =
+ new ExpectXmlBeforeNamespaceProblem(maybeNS);
+ problems.add(problem);
+ }
+
+ //combine all of these tokens together
+ retVal.setEnd(maybeNS.getEnd());
+ retVal.setText(DEFAULT_XML_NAMESPACE);
+ retVal.setType(TOKEN_DIRECTIVE_DEFAULT_XML);
+ consume(2);
+ }
+ // if this isn't "default xml namespace" then
+ // see if it is the default case in a switch
+ // otherwise, assume it is an identiferName
+ else if (maybeXML != null &&
+ maybeXML.getType() != TOKEN_COLON)
+ retVal.setType(TOKEN_IDENTIFIER);
++ else if (lastToken != null)
++ {
++ int lastTokenType = lastToken.getType();
++ switch (lastTokenType)
++ {
++ case TOKEN_KEYWORD_VAR:
++ case TOKEN_KEYWORD_FUNCTION:
++ case TOKEN_RESERVED_WORD_GET:
++ case TOKEN_RESERVED_WORD_SET:
++ case TOKEN_OPERATOR_MEMBER_ACCESS:
++ retVal.setType(TOKEN_IDENTIFIER);
++ }
++ }
+ return retVal;
+ }
+ case TOKEN_KEYWORD_VOID:
+ {
+ //check for void 0
+ final ASToken token = LT(1);
+ if (matches(token, TOKEN_LITERAL_NUMBER) && ZERO.equals(token.getText()))
+ {
+ retVal.setType(TOKEN_VOID_0);
+ combineText(retVal, token);
+ consume(1);
+ }
+ //check for void(0)
+ else if (matches(token, TOKEN_PAREN_OPEN))
+ {
+ final ASToken zeroT = LT(2);
+ if (matches(zeroT, TOKEN_LITERAL_NUMBER) && ZERO.equals(zeroT.getText()))
+ {
+ final ASToken closeParenT = LT(3);
+ if (matches(closeParenT, TOKEN_PAREN_CLOSE))
+ {
+ combineText(retVal, token);
+ combineText(retVal, zeroT);
+ combineText(retVal, closeParenT);
+ retVal.setType(TOKEN_VOID_0);
+ consume(3);
+ }
+ }
+ }
+ return retVal;
+ }
+ case TOKEN_IDENTIFIER:
+ {
+ //check for user-defined namespace before we return anything
+ processUserDefinedNamespace(retVal, 0);
+ return retVal;
+ }
+ //this is for metadata processing
+ case TOKEN_SQUARE_OPEN:
+ {
+ retVal = tryParseMetadata(retVal);
+ return retVal;
+ }
+ case HIDDEN_TOKEN_STAR_ASSIGNMENT:
+ {
+ //this is to solve an ambiguous case, where we can't tell the difference between
+ //var foo:*=null and foo *= null;
+ retVal.setType(TOKEN_OPERATOR_STAR);
+ retVal.setEnd(retVal.getEnd() - 1);
+ retVal.setText("*");
+ //add the equals
+ final ASToken nextToken = tokenizer.buildToken(TOKEN_OPERATOR_ASSIGNMENT,
+ retVal.getEnd() + 1, retVal.getEnd() + 2,
+ retVal.getLine(), retVal.getColumn(), "=");
+ nextToken.setSourcePath(sourcePath);
+ addTokenToBuffer(nextToken);
+ return retVal;
+ }
+ case TOKEN_SEMICOLON:
+ if (consumeSemi)
+ {
+ return next();
+ }
+ return retVal;
+ case TOKEN_VOID_0:
+ case TOKEN_LITERAL_REGEXP:
+ case TOKEN_COMMA:
+ case TOKEN_COLON:
+ case TOKEN_PAREN_OPEN:
+ case TOKEN_PAREN_CLOSE:
+ case TOKEN_SQUARE_CLOSE:
+ case TOKEN_ELLIPSIS:
+ case TOKEN_OPERATOR_PLUS_ASSIGNMENT:
+ case TOKEN_OPERATOR_MINUS_ASSIGNMENT:
+ case TOKEN_OPERATOR_MULTIPLICATION_ASSIGNMENT:
+ case TOKEN_OPERATOR_DIVISION_ASSIGNMENT:
+ case TOKEN_OPERATOR_MODULO_ASSIGNMENT:
+ case TOKEN_OPERATOR_BITWISE_AND_ASSIGNMENT:
+ case TOKEN_OPERATOR_BITWISE_OR_ASSIGNMENT:
+ case TOKEN_OPERATOR_BITWISE_XOR_ASSIGNMENT:
+ case TOKEN_OPERATOR_BITWISE_LEFT_SHIFT_ASSIGNMENT:
+ case TOKEN_OPERATOR_BITWISE_RIGHT_SHIFT_ASSIGNMENT:
+ case TOKEN_OPERATOR_BITWISE_UNSIGNED_RIGHT_SHIFT_ASSIGNMENT:
+ case TOKEN_OPERATOR_STAR:
+ case TOKEN_OPERATOR_NS_QUALIFIER:
+ case TOKEN_ASDOC_COMMENT:
+ case TOKEN_OPERATOR_DIVISION:
+ case TOKEN_OPERATOR_MODULO:
+ case TOKEN_OPERATOR_BITWISE_LEFT_SHIFT:
+ case TOKEN_OPERATOR_BITWISE_RIGHT_SHIFT:
+ case TOKEN_OPERATOR_BITWISE_UNSIGNED_RIGHT_SHIFT:
+ case TOKEN_OPERATOR_LESS_THAN:
+ case TOKEN_OPERATOR_GREATER_THAN:
+ case TOKEN_OPERATOR_LESS_THAN_EQUALS:
+ case TOKEN_OPERATOR_GREATER_THAN_EQUALS:
+ case TOKEN_OPERATOR_EQUAL:
+ case TOKEN_OPERATOR_NOT_EQUAL:
+ case TOKEN_OPERATOR_STRICT_EQUAL:
+ case TOKEN_OPERATOR_STRICT_NOT_EQUAL:
+ case TOKEN_OPERATOR_BITWISE_AND:
+ case TOKEN_OPERATOR_BITWISE_XOR:
+ case TOKEN_OPERATOR_BITWISE_OR:
+ case TOKEN_OPERATOR_LOGICAL_AND:
+ case TOKEN_OPERATOR_LOGICAL_OR:
+ case TOKEN_OPERATOR_LOGICAL_AND_ASSIGNMENT:
+ case TOKEN_OPERATOR_LOGICAL_OR_ASSIGNMENT:
+ case TOKEN_TYPED_COLLECTION_OPEN:
+ case TOKEN_TYPED_COLLECTION_CLOSE:
+ case TOKEN_OPERATOR_MEMBER_ACCESS:
+ case TOKEN_RESERVED_WORD_NAMESPACE:
+ case TOKEN_RESERVED_WORD_GET:
+ case TOKEN_RESERVED_WORD_SET:
+ case TOKEN_OPERATOR_ASSIGNMENT:
+ case TOKEN_TYPED_LITERAL_CLOSE:
+ case TOKEN_TYPED_LITERAL_OPEN:
+ case TOKEN_OPERATOR_TERNARY:
+ case TOKEN_OPERATOR_DECREMENT:
+ case TOKEN_OPERATOR_INCREMENT:
+ case TOKEN_OPERATOR_ATSIGN:
+ case TOKEN_OPERATOR_BITWISE_NOT:
+ case TOKEN_OPERATOR_LOGICAL_NOT:
+ case TOKEN_E4X_BINDING_CLOSE:
+ case TOKEN_E4X_BINDING_OPEN:
+ case TOKEN_OPERATOR_DESCENDANT_ACCESS:
+ case TOKEN_NAMESPACE_ANNOTATION:
+ case TOKEN_NAMESPACE_NAME:
+ case TOKEN_BLOCK_OPEN:
+ case TOKEN_BLOCK_CLOSE:
+ case TOKEN_KEYWORD_FUNCTION:
+ return retVal;
+ case HIDDEN_TOKEN_MULTI_LINE_COMMENT:
+ case HIDDEN_TOKEN_SINGLE_LINE_COMMENT:
+ if (tokenizer.isCollectingComments())
+ {
+ return retVal;
+ }
+ assert (false);
+ return null;
+ case TOKEN_KEYWORD_INSTANCEOF:
+ case TOKEN_KEYWORD_AS:
+ case TOKEN_KEYWORD_IN:
+ case TOKEN_KEYWORD_IS:
+ if (lastToken != null)
+ {
+ int lastTokenType = lastToken.getType();
+ switch (lastTokenType)
+ {
+ case TOKEN_SEMICOLON:
+ case TOKEN_BLOCK_OPEN:
+ case TOKEN_COMMA:
+ retVal.setType(TOKEN_IDENTIFIER);
+ return retVal;
+ }
+ }
+ else
+ {
+ // we are first token so assume identifier
+ retVal.setType(TOKEN_IDENTIFIER);
+ return retVal;
+ }
+ // and fall through
+ case TOKEN_KEYWORD_DELETE:
+ ASToken nextToken = LT(1);
+ if (nextToken != null)
+ {
+ int nextTokenType = nextToken.getType();
+ switch (nextTokenType)
+ {
+ // if followed by a token assume it is the
+ // keyword and not the identiferName;
+ case TOKEN_IDENTIFIER:
+ return retVal;
+ // followed by a comma or semicolon
+ // probably being used in an expression
+ case TOKEN_COMMA:
+ case TOKEN_SEMICOLON:
+ retVal.setType(TOKEN_IDENTIFIER);
+ return retVal;
+ }
+ }
+ // and fall through
+ case TOKEN_KEYWORD_BREAK:
+ case TOKEN_KEYWORD_CASE:
+ case TOKEN_KEYWORD_CATCH:
+ case TOKEN_KEYWORD_CLASS:
+ case TOKEN_KEYWORD_CONST:
+ case TOKEN_KEYWORD_CONTINUE:
+ case TOKEN_KEYWORD_DO:
+ case TOKEN_KEYWORD_ELSE:
+ case TOKEN_KEYWORD_FALSE:
+ case TOKEN_KEYWORD_FINALLY:
+ case TOKEN_KEYWORD_IF:
+ case TOKEN_KEYWORD_IMPORT:
+ case TOKEN_KEYWORD_INTERFACE:
+ case TOKEN_KEYWORD_NULL:
+ case TOKEN_KEYWORD_PACKAGE:
+ case TOKEN_KEYWORD_SUPER:
+ case TOKEN_KEYWORD_SWITCH:
+ case TOKEN_KEYWORD_THIS:
+ case TOKEN_KEYWORD_TRUE:
+ case TOKEN_KEYWORD_TRY:
+ case TOKEN_KEYWORD_TYPEOF:
+ case TOKEN_KEYWORD_USE:
+ case TOKEN_KEYWORD_VAR:
+ case TOKEN_KEYWORD_WHILE:
+ case TOKEN_KEYWORD_WITH:
+ case TOKEN_KEYWORD_RETURN:
+ case TOKEN_KEYWORD_THROW:
+ case TOKEN_KEYWORD_NEW:
+ if (lastToken != null)
+ {
+ int lastTokenType = lastToken.getType();
+ switch (lastTokenType)
+ {
+ case TOKEN_KEYWORD_VAR:
+ case TOKEN_KEYWORD_FUNCTION:
+ case TOKEN_RESERVED_WORD_GET:
+ case TOKEN_RESERVED_WORD_SET:
+ case TOKEN_OPERATOR_MEMBER_ACCESS:
+ retVal.setType(TOKEN_IDENTIFIER);
+ }
+ }
+ return retVal;
+ default:
+ if (ASToken.isE4X(tokenType))
+ return retVal;
+
+ if (retVal.isKeywordOrContextualReservedWord() || retVal.isLiteral())
+ return retVal;
+
+ // If we reach here, the token fails to match any processing logic.
+ final UnexpectedTokenProblem problem = new UnexpectedTokenProblem(
+ retVal,
+ ASTokenKind.UNKNOWN);
+ problems.add(problem);
+ }
+ }
+ catch (final Exception e)
+ {
+ if (lastException != null)
+ {
+ if (lastException.getClass().isInstance(e))
+ {
+ ICompilerProblem problem = new InternalCompilerProblem2(sourcePath, e, "StreamingASTokenizer");
+ problems.add(problem);
+ return null;
+ }
+ }
+ else
+ {
+ lastException = e;
+ retVal = null;
+ return next();
+ }
+ }
+ finally
+ {
+ consumeSemi = false;
+ lastToken = retVal;
+ }
+ return null;
+ }
+
+ /**
+ * Error recovery: convert the given keyword token into an identifier token,
+ * and log a syntax error.
+ *
+ * @param token Keyword token.
+ */
+ private void treatKeywordAsIdentifier(final ASToken token)
+ {
+ assert token != null : "token can't be null";
+ assert token.isKeywordOrContextualReservedWord() : "only transfer reserved words";
+
+ if (token.isKeyword())
+ {
+ final UnexpectedTokenProblem problem = new UnexpectedTokenProblem(token, ASTokenKind.IDENTIFIER);
+ problems.add(problem);
+ }
+ token.setType(TOKEN_IDENTIFIER);
+ }
+
+ /**
+ * Decide within the current context whether the following content can be
+ * parsed as a metadata tag token.
+ *
+ * @param nextToken The next token coming from
+ * {@link #nextTokenFromReader()}.
+ * @return If the following content can be a metadata tag, the result is a
+ * token of type {@link ASTokenTypes#TOKEN_ATTRIBUTE}. Otherwise, the
+ * argument {@code nextToken} is returned.
+ * @throws Exception Parsing error.
+ */
+ private ASToken tryParseMetadata(ASToken nextToken) throws Exception
+ {
+ // Do not initialize this variable so that Java flow-analysis can check if
+ // the following rules cover all the possibilities.
+ final boolean isNextMetadata;
+
+ if (!config.findMetadata)
+ {
+ // The lexer is configured to not recognize metadata.
+ isNextMetadata = false;
+ }
+ else if (lastToken == null)
+ {
+ // An "[" at the beginning of a script is always a part of a metadata.
+ isNextMetadata = true;
+ }
+ else
+ {
+ switch (lastToken.getType())
+ {
+ case TOKEN_ASDOC_COMMENT:
+ case TOKEN_SEMICOLON:
+ case TOKEN_ATTRIBUTE:
+ case TOKEN_BLOCK_OPEN:
+ // "[" after these tokens are always part of a metadata token.
+ isNextMetadata = true;
+ break;
+
+ case TOKEN_SQUARE_CLOSE:
+ case TOKEN_IDENTIFIER:
+ // "[" following a "]" is an array access.
+ // "[" following an identifier is an array access.
+ isNextMetadata = false;
+ break;
+
+ case TOKEN_KEYWORD_INCLUDE:
+ case TOKEN_BLOCK_CLOSE:
+ case TOKEN_OPERATOR_STAR:
+ // "[" after these tokens are part of a metadata token, if
+ // the "[" is on a new line.
+ isNextMetadata = !lastToken.matchesLine(nextToken);
+ break;
+
+ default:
+ // If we are lexing an entire file
+ // then at this point we "know" that the next token
+ // is not meta-data.
+ if (config.completeContent)
+ {
+ isNextMetadata = false;
+ }
+ else
+ {
+ // In "fragment" mode which is used by the syntax coloring code
+ // in builder, we assume the following list of tokens can not
+ // precede meta-data because they all start or occur in expressions.
+ switch (lastToken.getType())
+ {
+ case TOKEN_OPERATOR_EQUAL:
+ case TOKEN_OPERATOR_TERNARY:
+ case TOKEN_COLON:
+ case TOKEN_OPERATOR_PLUS:
+ case TOKEN_OPERATOR_MINUS:
+ case TOKEN_OPERATOR_STAR:
+ case TOKEN_OPERATOR_DIVISION:
+ case TOKEN_OPERATOR_MODULO:
+ case TOKEN_OPERATOR_BITWISE_AND:
+ case TOKEN_OPERATOR_BITWISE_OR:
+ case TOKEN_KEYWORD_AS:
+ case TOKEN_OPERATOR_BITWISE_XOR:
+ case TOKEN_OPERATOR_LOGICAL_AND:
+ case TOKEN_OPERATOR_LOGICAL_OR:
+ case TOKEN_PAREN_OPEN:
+ case TOKEN_COMMA:
+ case TOKEN_OPERATOR_BITWISE_NOT:
+ case TOKEN_OPERATOR_LOGICAL_NOT:
+ case TOKEN_OPERATOR_ASSIGNMENT:
+ case TOKEN_OPERATOR_BITWISE_LEFT_SHIFT:
+ case TOKEN_OPERATOR_BITWISE_RIGHT_SHIFT:
+ case TOKEN_OPERATOR_BITWISE_UNSIGNED_RIGHT_SHIFT:
+ case TOKEN_OPERATOR_LESS_THAN:
+ case TOKEN_OPERATOR_GREATER_THAN:
+ case TOKEN_OPERATOR_LESS_THAN_EQUALS:
+ case TOKEN_OPERATOR_GREATER_THAN_EQUALS:
+ case TOKEN_OPERATOR_NOT_EQUAL:
+ case TOKEN_OPERATOR_STRICT_EQUAL:
+ case TOKEN_OPERATOR_STRICT_NOT_EQUAL:
+ case TOKEN_OPERATOR_PLUS_ASSIGNMENT:
+ case TOKEN_OPERATOR_MINUS_ASSIGNMENT:
+ case TOKEN_OPERATOR_MULTIPLICATION_ASSIGNMENT:
+ case TOKEN_OPERATOR_DIVISION_ASSIGNMENT:
+ case TOKEN_OPERATOR_MODULO_ASSIGNMENT:
+ case TOKEN_OPERATOR_BITWISE_AND_ASSIGNMENT:
+ case TOKEN_OPERATOR_BITWISE_OR_ASSIGNMENT:
+ case TOKEN_OPERATOR_BITWISE_XOR_ASSIGNMENT:
+ case TOKEN_OPERATOR_BITWISE_LEFT_SHIFT_ASSIGNMENT:
+ case TOKEN_OPERATOR_BITWISE_RIGHT_SHIFT_ASSIGNMENT:
+ case TOKEN_OPERATOR_BITWISE_UNSIGNED_RIGHT_SHIFT_ASSIGNMENT:
+ isNextMetadata = false;
+ break;
+ default:
+ isNextMetadata = true;
+ break;
+ }
+ }
+ break;
+ }
+ }
+
+ final ASToken result;
+ if (isNextMetadata)
+ result = consumeMetadata(nextToken);
+ else
+ result = nextToken;
+
+ return result;
+ }
+
+ /**
+ * Close the forked include file tokenizer, and set it to null.
+ */
+ private void closeIncludeTokenizer()
+ {
+ if (forkIncludeTokenizer == null)
+ return;
+
+ try
+ {
+ problems.addAll(forkIncludeTokenizer.problems);
+ forkIncludeTokenizer.close();
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ includeHandler.leaveFile(forkIncludeTokenizer.getEndOffset());
+ forkIncludeTokenizer = null;
+ }
+
+ /**
+ * @throws Exception
+ */
+ private final ASToken consumeMetadata(final ASToken startToken) throws Exception
+ {
+ final ASToken originalToken = new ASToken(startToken);
+ MetaDataPayloadToken payload = new MetaDataPayloadToken(originalToken);
+ final ArrayList<ASToken> safetyNet = new ArrayList<ASToken>(5);
+ boolean isMetadata = true;
+ while (true)
+ {
+ tokenizer.setReuseLastToken();
+ final ASToken next = LT(1);
+ if (next == null)
+ {
+ break;
+ }
+ safetyNet.add(new ASToken(next)); //sadly, we have to deal with the extra object creation if we're wrong
+ payload.addToken(next); //here too
+
+ if (!next.canExistInMetadata())
+ {
+ isMetadata = false;
+ //consume the last token we saw so that we don't get ourselves into an infinite loop
+ //it was the last token of the metadata, and this makes "next" the current token.
+ consume(1);
+ break;
+ }
+ consume(1);
+ if (next.getType() == TOKEN_SQUARE_CLOSE)
+ {
+ break;
+ }
+ }
+ if (!isMetadata)
+ { //we're wrong, so let's add back the tokens to our lookahead buffer
+ lookAheadBuffer.addAll(safetyNet);
+ bufferSize = lookAheadBuffer.size();
+ return originalToken;
+ }
+ return payload;
+
+ }
+
+ private final void fill(final int distance) throws Exception
+ {
+ int pos = 0;
+ while (pos < distance)
+ {
+ addTokenToBuffer(nextTokenFromReader());
+ pos++;
+ }
+ }
+
+ /**
+ * @param nextToken
+ */
+ private final void addTokenToBuffer(final ASToken nextToken)
+ {
+ bufferSize++;
+ lookAheadBuffer.add(nextToken);
+ // at EOF, nextToken can be null.
+ if (nextToken != null)
+ nextToken.lock();
+ }
+
+ /**
+ * Get the pooled version of a given string.
+ *
+ * @param text String literal.
+ * @return Pooled string.
+ */
+ private final String poolString(final String text)
+ {
+ String pooledString = stringPool.get(text);
+ if (pooledString == null)
+ {
+ stringPool.put(text, text);
+ pooledString = text;
+ }
+ return pooledString;
+ }
+
+ /**
+ * Get the next token from the source input. If this tokenizer is created
+ * for a source file by {@link ASC}, and there are files included by
+ * {@code -in} option, the tokenizer will return the
+ * "injected include tokens" before real tokens coming from the JFlex
+ * generated tokenizer.
+ *
+ * @return next token from the source input
+ * @throws IOException error
+ * @see ASCompilationUnit#createMainCompilationUnitForASC()
+ */
+ private final ASToken nextTokenFromReader() throws IOException
+ {
+ final ASToken nextToken;
+ if (ascIncludeImaginaryTokens != null && ascIncludeImaginaryTokens.hasNext())
+ nextToken = ascIncludeImaginaryTokens.next();
+ else if (tokenizer.hasBufferToken())
+ nextToken = tokenizer.getBufferToken();
+ else
+ nextToken = tokenizer.nextToken();
+
+ if (nextToken != null)
+ {
+ // Converting unicode on-the-fly in the lexer is much slower than
+ // converting it here after the token is made, especially for
+ // identifiers.
+ switch (nextToken.getType())
+ {
+ case TOKEN_LITERAL_NUMBER:
+ nextToken.setText(poolString(nextToken.getText()));
+ break;
+ case TOKEN_LITERAL_REGEXP:
+ // Any "backslash-u" entities left after "convertUnicode"
+ // are invalid unicode escape sequences. According to AS3
+ // behavior, the backslash character is dropped.
+ nextToken.setText(poolString(convertUnicode(nextToken.getText()).replaceAll("\\\\u", "u")));
+ break;
+ case TOKEN_IDENTIFIER:
+ // Intern 'identifiers' and 'keywords'.
+ // 'keywords' were 'identifiers' before they are analyzed.
+ final String originalIdentifierName = nextToken.getText();
+ final String normalizedIdentifierName = poolString(convertUnicode(originalIdentifierName));
+ nextToken.setText(normalizedIdentifierName);
+ if (!config.ignoreKeywords)
+ {
+ /**
+ * If the identifier has escaped unicode sequence, it
+ * can't be a keyword.
+ * <p>
+ * According to ASL syntax spec chapter 3.4:
+ * <blockquote> Unicode escape sequences may be used to
+ * spell the names of identifiers that would otherwise
+ * be keywords. This is in contrast to ECMAScript.
+ * </blockquote>
+ */
+ if (originalIdentifierName.equals(normalizedIdentifierName))
+ {
+ // do keyword analysis here
+ final Integer info = keywordToTokenMap.get(nextToken.getText());
+ if (info != null)
+ nextToken.setType(info);
+ }
+ }
+ break;
+ default:
+ // Ignore other tokens.
+ break;
+ }
+
+ //so we want to adjust all of our offsets here, BUT
+ //the column is really only valid for the first line, which is line 0.
+ //if we're not the first line, don't bother
+ nextToken.adjustLocation(
+ offsetAdjustment,
+ lineAdjustment,
+ nextToken.getLine() == 0 ? columnAdjustment : 0);
+ nextToken.storeLocalOffset();
+
+ if (includeHandler != null)
+ {
+ nextToken.setSourcePath(includeHandler.getIncludeStackTop());
+ includeHandler.onNextToken(nextToken);
+ }
+
+ if (nextToken.getSourcePath() == null)
+ nextToken.setSourcePath(sourcePath);
+
+ if (reader instanceof SourceFragmentsReader)
+ ((SourceFragmentsReader)reader).adjustLocation(nextToken);
+ }
+ return nextToken;
+ }
+
+ /**
+ * Consume tokens in the buffer
+ *
+ * @param distance the number of tokens to consume
+ */
+ private final void consume(int distance)
+ {
+ if (bufferSize >= distance)
+ {
+ for (; distance > 0; distance--)
+ {
+ lookAheadBuffer.remove(bufferSize - 1);
+ bufferSize--;
+ }
+ }
+ }
+
+ /**
+ * Returns the next token that will be produced by the underlying lexer
+ *
+ * @param distance distance to look ahead
+ * @return an {@link ASToken}
+ * @throws Exception
+ */
+ private final ASToken LT(final int distance) throws Exception
+ {
+ if (bufferSize < distance)
+ {
+ fill(distance - bufferSize);
+ }
+ return lookAheadBuffer.get(distance - 1);
+ }
+
+ private static final boolean matches(final ASToken token, final int type)
+ {
+ return token != null && token.getType() == type;
+ }
+
+ /**
+ * Retrieve the end offset of the file.
+ * <p>
+ * The result is the end offset of the file, not the offset of the last
+ * token, this allows any trailing space to be included so that the parser
+ * can span the result {@code FileNode} to the entire file.
+ *
+ * @return the end offset of the input file
+ */
+ public final int getEndOffset()
+ {
+ return tokenizer.getOffset() + offsetAdjustment;
+ }
+
+ /**
+ * Computers whether the following token is a user-defined namespace. This
+ * method calls processUserDefinedNamespace which will change token types
+ *
+ * @param token token to start our analysis
+ * @param lookaheadOffset offset of the tokens to look at
+ * @return true if we're a user-defined namespace
+ * @throws Exception
+ */
+ private final boolean isUserDefinedNamespace(final ASToken token, final int lookaheadOffset) throws Exception
+ {
+ processUserDefinedNamespace(token, lookaheadOffset);
+ return token.getType() == TOKEN_NAMESPACE_ANNOTATION || token.getType() == TOKEN_NAMESPACE_NAME;
+ }
+
+ /**
+ * Because AS3 supports qualified/unqualified namespaces as decorators on
+ * definitions, we need to detect them before we even make it to the parser.
+ * These look exactly like names/qnames, and so if they're on the same line
+ * as a definition they might be a namespace name instead of a standard
+ * identifier. This method will detect these cases, and change token types
+ * accordingly
+ *
+ * @param token token token to start our analysis
+ * @param lookaheadOffset offset of the tokens to look at
+ * @throws Exception
+ */
+ private final void processUserDefinedNamespace(final ASToken token, final int lookaheadOffset) throws Exception
+ {
+ token.lock();
+
+ //determine if we have a user-defined namespace
+ //our first token will be an identifier, and the cases we're looking for are:
+ //1.) user_namespace (function|var|dynamic|static|final|native|override)
+ //2.) my.pack.user_namespace (function|var|dynamic|static|final|native|override)
+ //option number 1 is probably the 99% case so optimize for it
+ ASToken nextToken = LT(1 + lookaheadOffset);
+ if (token.matchesLine(nextToken))
+ {
+ // If the next token is an identifier check to see if it should
+ // be modified to a TOKEN_NAMESPACE_ANNOTATION
+ // This is so that code like:
+ // ns1 ns2 var x;
+ // gets parsed correctly (2 namespace annotations, which is an error)
+ if (nextToken.getType() == TOKEN_IDENTIFIER)
+ processUserDefinedNamespace(nextToken, 1 + lookaheadOffset);
+
+ switch (nextToken.getType())
+ {
+ case TOKEN_KEYWORD_FUNCTION:
+ case TOKEN_KEYWORD_VAR:
+ case TOKEN_KEYWORD_CONST:
+ case TOKEN_RESERVED_WORD_NAMESPACE:
+ case TOKEN_MODIFIER_DYNAMIC:
+ case TOKEN_MODIFIER_FINAL:
+ case TOKEN_MODIFIER_NATIVE:
+ case TOKEN_MODIFIER_OVERRIDE:
+ case TOKEN_MODIFIER_STATIC:
+ case TOKEN_MODIFIER_VIRTUAL:
+ case TOKEN_KEYWORD_CLASS:
+ case TOKEN_KEYWORD_INTERFACE:
+ case TOKEN_NAMESPACE_ANNOTATION:
+ case HIDDEN_TOKEN_BUILTIN_NS:
+ token.setType(TOKEN_NAMESPACE_ANNOTATION);
+ return;
+ case TOKEN_OPERATOR_NS_QUALIFIER: //simple name with a :: binding after it. has to be a NS
+ token.setType(TOKEN_NAMESPACE_NAME);
+ return;
+ }
+ if (nextToken.getType() == TOKEN_OPERATOR_MEMBER_ACCESS)
+ {
+ int nextValidPart = TOKEN_IDENTIFIER;
+ final ArrayList<ASToken> toTransform = new ArrayList<ASToken>(3);
+ toTransform.add(token);
+ toTransform.add(nextToken);
+ int laDistance = lookaheadOffset + 1;
+ while (true)
+ {
+ nextToken = LT(++laDistance);
+ if (token.matchesLine(nextToken))
+ {
+ if (nextToken.getType() == nextValidPart)
+ {
+ nextValidPart = (nextToken.getType() == TOKEN_IDENTIFIER) ? TOKEN_OPERATOR_MEMBER_ACCESS : TOKEN_IDENTIFIER;
+ toTransform.add(nextToken);
+ }
+ else if (nextValidPart != TOKEN_IDENTIFIER && nextToken.canFollowUserNamespace())
+ {
+ // Next token is in the follow set of a namespace,
+ // so all the buffered tokens need to be converted
+ // into namespace tokens.
+ for (final ASToken ttToken : toTransform)
+ {
+ if (ttToken.getType() == TOKEN_IDENTIFIER)
+ ttToken.setType(TOKEN_NAMESPACE_ANNOTATION);
+ else
+ ttToken.setType(TOKEN_OPERATOR_MEMBER_ACCESS);
+ }
+ break;
+ }
+ else
+ {
+ break;
+ }
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Combines the text of two tokens, adding whitespace between them and
+ * adjusting offsets appropriately
+ *
+ * @param target the base token that we will add the next to
+ * @param source the source of the text to add
+ */
+ private final void combineText(TokenBase target, TokenBase source)
+ {
+ StringBuilder text = new StringBuilder();
+ text.append(target.getText());
+ //add whitespace for gaps between tokens
+ for (int i = 0; i < (source.getStart() - target.getEnd()); i++)
+ {
+ text.append(" ");
+ }
+ text.append(source.getText());
+ target.setText(poolString(text.toString()));
+ target.setEnd(target.getStart() + text.length());
+ }
+
+ /**
+ * Unicode pattern for {@code \u0000}.
+ */
+ private static final Pattern UNICODE_PATTERN = Pattern.compile(BaseRawASTokenizer.PATTERN_U4);
+
+ /**
+ * Leading characters of a unicode pattern.
+ */
+ private static final String UNICODE_LEADING_CHARS = "\\u";
+
+ /**
+ * Convert escaped unicode sequence in a string. For example:
+ * {@code foo\u0051bar} is converted into {@code fooQbar}.
+ *
+ * @param text input string
+ * @return converted text
+ */
+ static String convertUnicode(final String text)
+ {
+ // Calling Pattern.matcher() is much slower than String.contains(), so
+ // we need this predicate to skip unnecessary RegEx computation.
+ if (text.contains(UNICODE_LEADING_CHARS))
+ {
+ final StringBuilder result = new StringBuilder();
+ final Matcher matcher = UNICODE_PATTERN.matcher(text);
+ int start = 0;
+ while (matcher.find())
+ {
+ result.append(text, start, matcher.start());
+ result.append(Character.toChars(BaseRawASTokenizer.decodeEscapedUnicode(matcher.group())));
+ start = matcher.end();
+ }
+ result.append(text, start, text.length());
+ return result.toString();
+ }
+ else
+ {
+ return text;
+ }
+ }
+
+ /**
+ * Gets the source path to the file being tokenized.
+ */
+ public String getSourcePath()
+ {
+ return sourcePath;
+ }
+}
[14/19] git commit: [flex-falcon]
[refs/heads/feature/maven-migration-test] - compiler: allow default as a
variable name
Posted by cd...@apache.org.
compiler: allow default as a variable name
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/5a6e32e0
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/5a6e32e0
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/5a6e32e0
Branch: refs/heads/feature/maven-migration-test
Commit: 5a6e32e095dbdb5ceb82bf74d2086ba61fd923db
Parents: b1bfa69
Author: Josh Tynjala <jo...@apache.org>
Authored: Wed Apr 20 11:11:43 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Wed Apr 20 11:11:43 2016 -0700
----------------------------------------------------------------------
.../feature-tests/as/ASKeywordTests.java | 21 ++++++++++++++++++++
.../parsing/as/StreamingASTokenizer.java | 13 ++++++++++++
2 files changed, 34 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/5a6e32e0/compiler.tests/feature-tests/as/ASKeywordTests.java
----------------------------------------------------------------------
diff --git a/compiler.tests/feature-tests/as/ASKeywordTests.java b/compiler.tests/feature-tests/as/ASKeywordTests.java
index 1602b3c..8223620 100644
--- a/compiler.tests/feature-tests/as/ASKeywordTests.java
+++ b/compiler.tests/feature-tests/as/ASKeywordTests.java
@@ -292,6 +292,27 @@ public class ASKeywordTests extends ASFeatureTestsBase
}
@Test
+ public void ASKeyword_default_as_variable_name()
+ {
+ // all tests can assume that flash.display.Sprite
+ // flash.system.System and flash.events.Event have been imported
+ String[] imports = new String[]
+ {
+ };
+ String[] declarations = new String[]
+ {
+ "public var default:String;",
+ };
+ String[] testCode = new String[]
+ {
+ "default = 'bar';",
+ "assertEqual('variable named default', default, 'bar');",
+ };
+ String source = getAS(imports, declarations, testCode, new String[0]);
+ compileAndRun(source);
+ }
+
+ @Test
public void ASKeyword_as_member_expression()
{
// all tests can assume that flash.display.Sprite
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/5a6e32e0/compiler/src/org/apache/flex/compiler/internal/parsing/as/StreamingASTokenizer.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/parsing/as/StreamingASTokenizer.java b/compiler/src/org/apache/flex/compiler/internal/parsing/as/StreamingASTokenizer.java
index 61b6e26..1c90e94 100644
--- a/compiler/src/org/apache/flex/compiler/internal/parsing/as/StreamingASTokenizer.java
+++ b/compiler/src/org/apache/flex/compiler/internal/parsing/as/StreamingASTokenizer.java
@@ -1025,6 +1025,19 @@ public class StreamingASTokenizer implements ASTokenTypes, IASTokenizer, Closeab
else if (maybeXML != null &&
maybeXML.getType() != TOKEN_COLON)
retVal.setType(TOKEN_IDENTIFIER);
+ else if (lastToken != null)
+ {
+ int lastTokenType = lastToken.getType();
+ switch (lastTokenType)
+ {
+ case TOKEN_KEYWORD_VAR:
+ case TOKEN_KEYWORD_FUNCTION:
+ case TOKEN_RESERVED_WORD_GET:
+ case TOKEN_RESERVED_WORD_SET:
+ case TOKEN_OPERATOR_MEMBER_ACCESS:
+ retVal.setType(TOKEN_IDENTIFIER);
+ }
+ }
return retVal;
}
case TOKEN_KEYWORD_VOID:
[11/19] git commit: [flex-falcon]
[refs/heads/feature/maven-migration-test] - compiler.jx: when externc
encounters a file with a duplicate name (such as buffer and Buffer,
with different cases), puts the duplicate into a different directory
Posted by cd...@apache.org.
compiler.jx: when externc encounters a file with a duplicate name (such as buffer and Buffer, with different cases), puts the duplicate into a different directory
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/2a001751
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/2a001751
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/2a001751
Branch: refs/heads/feature/maven-migration-test
Commit: 2a00175191bffa10f5e9a1b783585e4e57851213
Parents: 0c73140
Author: Josh Tynjala <jo...@apache.org>
Authored: Wed Apr 20 10:19:26 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Wed Apr 20 10:19:26 2016 -0700
----------------------------------------------------------------------
.../compiler/clients/ExternCConfiguration.java | 7 +++++++
.../externals/emit/ReferenceEmitter.java | 20 ++++++++++++++++++++
2 files changed, 27 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2a001751/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java b/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java
index 7eea457..c15786a 100644
--- a/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java
@@ -51,6 +51,7 @@ public class ExternCConfiguration extends Configuration
private File asFunctionRoot;
private File asConstantRoot;
private File asTypeDefRoot;
+ private File asDuplicatesRoot;
private List<ExternalFile> externals = new ArrayList<ExternalFile>();
private List<ExternalFile> externalExterns = new ArrayList<ExternalFile>();
@@ -85,6 +86,7 @@ public class ExternCConfiguration extends Configuration
asFunctionRoot = new File(asRoot, "functions");
asConstantRoot = new File(asRoot, "constants");
asTypeDefRoot = new File(asRoot, "typedefs");
+ asDuplicatesRoot = new File(asRoot, "duplicates");
}
public File getAsClassRoot()
@@ -112,6 +114,11 @@ public class ExternCConfiguration extends Configuration
return asTypeDefRoot;
}
+ public File getAsDuplicatesRoot()
+ {
+ return asDuplicatesRoot;
+ }
+
public Collection<ExternalFile> getExternals()
{
return externals;
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2a001751/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/emit/ReferenceEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/emit/ReferenceEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/emit/ReferenceEmitter.java
index 957d352..c7d3c45 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/emit/ReferenceEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/emit/ReferenceEmitter.java
@@ -68,6 +68,10 @@ public class ReferenceEmitter
emit(reference, sb);
File sourceFile = reference.getFile(model.getConfiguration().getAsInterfaceRoot());
+ if(sourceFile.exists())
+ {
+ sourceFile = reference.getFile(model.getConfiguration().getAsDuplicatesRoot());
+ }
FileUtils.write(sourceFile, sb.toString());
sb.setLength(0);
@@ -91,6 +95,10 @@ public class ReferenceEmitter
emit(reference, sb);
File sourceFile = reference.getFile(model.getConfiguration().getAsClassRoot());
+ if(sourceFile.exists())
+ {
+ sourceFile = reference.getFile(model.getConfiguration().getAsDuplicatesRoot());
+ }
FileUtils.write(sourceFile, sb.toString());
sb.setLength(0);
@@ -112,6 +120,10 @@ public class ReferenceEmitter
emit(reference, sb);
File sourceFile = reference.getFile(model.getConfiguration().getAsTypeDefRoot());
+ if(sourceFile.exists())
+ {
+ sourceFile = reference.getFile(model.getConfiguration().getAsDuplicatesRoot());
+ }
FileUtils.write(sourceFile, sb.toString());
sb.setLength(0);
@@ -129,6 +141,10 @@ public class ReferenceEmitter
emit(reference, sb);
File sourceFile = reference.getFile(model.getConfiguration().getAsFunctionRoot());
+ if(sourceFile.exists())
+ {
+ sourceFile = reference.getFile(model.getConfiguration().getAsDuplicatesRoot());
+ }
FileUtils.write(sourceFile, sb.toString());
sb.setLength(0);
@@ -146,6 +162,10 @@ public class ReferenceEmitter
emit(reference, sb);
File sourceFile = reference.getFile(model.getConfiguration().getAsConstantRoot());
+ if(sourceFile.exists())
+ {
+ sourceFile = reference.getFile(model.getConfiguration().getAsDuplicatesRoot());
+ }
FileUtils.write(sourceFile, sb.toString());
sb.setLength(0);
[03/19] git commit: [flex-falcon]
[refs/heads/feature/maven-migration-test] - .gitignore: ignore externs for
node
Posted by cd...@apache.org.
.gitignore: ignore externs for node
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/a21948d1
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/a21948d1
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/a21948d1
Branch: refs/heads/feature/maven-migration-test
Commit: a21948d12a2762fd67c10678c0960d71deb8f512
Parents: 170ea47
Author: Josh Tynjala <jo...@apache.org>
Authored: Tue Apr 19 14:18:18 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Tue Apr 19 14:18:18 2016 -0700
----------------------------------------------------------------------
.gitignore | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a21948d1/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index f5a9ea6..ff2f6b8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,6 +35,7 @@ externs/jasmine/externs
externs/createjs/externs
externs/createjs/in
externs/google_maps/externs
+externs/node/externs
# debugger output folders
debugger/bin/
[13/19] git commit: [flex-falcon]
[refs/heads/feature/maven-migration-test] - compiler.jx: externc can now
handle templates on fields
Posted by cd...@apache.org.
compiler.jx: externc can now handle templates on fields
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/b1bfa692
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/b1bfa692
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/b1bfa692
Branch: refs/heads/feature/maven-migration-test
Commit: b1bfa692007d10de4ee3f3b9a8434e36aaae462d
Parents: a6887f8
Author: Josh Tynjala <jo...@apache.org>
Authored: Wed Apr 20 10:31:23 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Wed Apr 20 10:31:23 2016 -0700
----------------------------------------------------------------------
.../codegen/externals/reference/FieldReference.java | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b1bfa692/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java
index d99a66d..e01a72a 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java
@@ -20,6 +20,7 @@
package org.apache.flex.compiler.internal.codegen.externals.reference;
import org.apache.flex.compiler.clients.ExternCConfiguration.ExcludedMember;
+import org.apache.flex.compiler.internal.codegen.externals.utils.FunctionUtils;
import org.apache.flex.compiler.internal.codegen.externals.utils.JSTypeUtils;
import com.google.javascript.rhino.JSDocInfo;
@@ -220,7 +221,13 @@ public class FieldReference extends MemberReference
{
if (overrideStringType != null)
return overrideStringType;
- return JSTypeUtils.toFieldTypeString(this);
+ String typeString = JSTypeUtils.toFieldTypeString(this);
+ if (FunctionUtils.hasTemplate(this)
+ && FunctionUtils.containsTemplate(this, typeString))
+ {
+ return "Object";
+ }
+ return typeString;
}
@Override
[08/19] git commit: [flex-falcon]
[refs/heads/feature/maven-migration-test] - externc: hasTemplate() and
containsTemplate() in FunctionUtils updated to grab templates from the parent
class too
Posted by cd...@apache.org.
externc: hasTemplate() and containsTemplate() in FunctionUtils updated to grab templates from the parent class too
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/2b5fb56f
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/2b5fb56f
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/2b5fb56f
Branch: refs/heads/feature/maven-migration-test
Commit: 2b5fb56f147f927c638e3643d954ce4586a35b79
Parents: 36b65ef
Author: Josh Tynjala <jo...@apache.org>
Authored: Tue Apr 19 16:29:57 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Tue Apr 19 16:29:57 2016 -0700
----------------------------------------------------------------------
.../codegen/externals/utils/FunctionUtils.java | 38 +++++++++++++++-----
1 file changed, 30 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2b5fb56f/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java
index f384689..5a9b658 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java
@@ -21,6 +21,7 @@ package org.apache.flex.compiler.internal.codegen.externals.utils;
import org.apache.flex.compiler.internal.codegen.externals.reference.BaseReference;
import org.apache.flex.compiler.internal.codegen.externals.reference.ClassReference;
+import org.apache.flex.compiler.internal.codegen.externals.reference.MemberReference;
import org.apache.flex.compiler.internal.codegen.externals.reference.ReferenceModel;
import com.google.common.base.Strings;
@@ -214,19 +215,40 @@ public class FunctionUtils
public static boolean hasTemplate(BaseReference reference)
{
+ if(reference instanceof MemberReference)
+ {
+ MemberReference memberRef = (MemberReference) reference;
+ if(memberRef.getClassReference().getComment().getTemplateTypeNames().size() > 0)
+ {
+ return true;
+ }
+ }
return reference.getComment().getTemplateTypeNames().size() > 0;
}
public static boolean containsTemplate(BaseReference reference, String name)
{
- for (String template : reference.getComment().getTemplateTypeNames())
- {
- if (name.contains("<" + template + ">"))
- return true;
- if (name.equals(template))
- return true;
- }
- return false;
+ if(reference instanceof MemberReference)
+ {
+ MemberReference memberRef = (MemberReference) reference;
+ if(commentContainsTemplate(memberRef.getClassReference().getComment(), name))
+ {
+ return true;
+ }
+ }
+ return commentContainsTemplate(reference.getComment(), name);
+ }
+
+ private static boolean commentContainsTemplate(JSDocInfo comment, String name)
+ {
+ for (String template : comment.getTemplateTypeNames())
+ {
+ if (name.contains("<" + template + ">"))
+ return true;
+ if (name.equals(template))
+ return true;
+ }
+ return false;
}
}
[07/19] git commit: [flex-falcon]
[refs/heads/feature/maven-migration-test] - externs/node: updated
configuration files to build without error based on the recent changes to
externc
Posted by cd...@apache.org.
externs/node: updated configuration files to build without error based on the recent changes to externc
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/36b65ef6
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/36b65ef6
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/36b65ef6
Branch: refs/heads/feature/maven-migration-test
Commit: 36b65ef6695058e0bcede897ce063046568a5aff
Parents: 4ed67a8
Author: Josh Tynjala <jo...@apache.org>
Authored: Tue Apr 19 16:12:32 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Tue Apr 19 16:12:32 2016 -0700
----------------------------------------------------------------------
externs/node/compile-config.xml | 2 +-
externs/node/node-compile-config.xml | 14 +++++++-------
2 files changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/36b65ef6/externs/node/compile-config.xml
----------------------------------------------------------------------
diff --git a/externs/node/compile-config.xml b/externs/node/compile-config.xml
index 564ba44..91df9e3 100644
--- a/externs/node/compile-config.xml
+++ b/externs/node/compile-config.xml
@@ -33,7 +33,7 @@
</compiler>
<include-sources>
- <path-element>out/as/constants</path-element>
+ <!--<path-element>out/as/constants</path-element>-->
<path-element>out/as/classes</path-element>
<path-element>out/as/functions</path-element>
<path-element>out/as/typedefs</path-element>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/36b65ef6/externs/node/node-compile-config.xml
----------------------------------------------------------------------
diff --git a/externs/node/node-compile-config.xml b/externs/node/node-compile-config.xml
index c0a3e50..aa97477 100644
--- a/externs/node/node-compile-config.xml
+++ b/externs/node/node-compile-config.xml
@@ -33,11 +33,11 @@
<external>
<path-element>missing.js</path-element>
<path-element>externs/assert.js</path-element>
- <path-element>externs/buffer.js</path-element>
- <path-element>externs/child_process.js</path-element>
- <path-element>externs/cluster.js</path-element>
+ <!--<path-element>externs/buffer.js</path-element>-->
+ <!--<path-element>externs/child_process.js</path-element>-->
+ <!--<path-element>externs/cluster.js</path-element>-->
<path-element>externs/crypto.js</path-element>
- <path-element>externs/dgram.js</path-element>
+ <!--<path-element>externs/dgram.js</path-element>-->
<path-element>externs/dns.js</path-element>
<path-element>externs/domain.js</path-element>
<path-element>externs/events.js</path-element>
@@ -48,12 +48,12 @@
<path-element>externs/net.js</path-element>
<path-element>externs/os.js</path-element>
<path-element>externs/path.js</path-element>
- <path-element>externs/punycode.js</path-element>
- <path-element>externs/querystring.js</path-element>
+ <!--<path-element>externs/punycode.js</path-element>-->
+ <!--<path-element>externs/querystring.js</path-element>-->
<path-element>externs/readline.js</path-element>
<path-element>externs/repl.js</path-element>
<path-element>externs/stream.js</path-element>
- <path-element>externs/string_decoder.js</path-element>
+ <!--<path-element>externs/string_decoder.js</path-element>-->
<path-element>externs/tls.js</path-element>
<path-element>externs/tty.js</path-element>
<path-element>externs/url.js</path-element>
[05/19] git commit: [flex-falcon]
[refs/heads/feature/maven-migration-test] - node externs: compiles downloaded
externs into SWC, but skips some due to errors from externc
Posted by cd...@apache.org.
node externs: compiles downloaded externs into SWC, but skips some due to errors from externc
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/e6409b27
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/e6409b27
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/e6409b27
Branch: refs/heads/feature/maven-migration-test
Commit: e6409b279120c7e7fa9835597604de13c2be9727
Parents: 8bfea6d
Author: Josh Tynjala <jo...@apache.org>
Authored: Tue Apr 19 14:30:42 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Tue Apr 19 14:30:42 2016 -0700
----------------------------------------------------------------------
externs/node/compile-config.xml | 115 +++++++++++++++++++++++++++++-
externs/node/externs/node.js | 30 --------
externs/node/missing.js | 30 ++++++++
externs/node/node-compile-config.xml | 30 +++++++-
4 files changed, 172 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e6409b27/externs/node/compile-config.xml
----------------------------------------------------------------------
diff --git a/externs/node/compile-config.xml b/externs/node/compile-config.xml
index 66ae820..564ba44 100644
--- a/externs/node/compile-config.xml
+++ b/externs/node/compile-config.xml
@@ -33,11 +33,122 @@
</compiler>
<include-sources>
+ <path-element>out/as/constants</path-element>
+ <path-element>out/as/classes</path-element>
<path-element>out/as/functions</path-element>
+ <path-element>out/as/typedefs</path-element>
</include-sources>
<include-file>
- <name>externs/node.js</name>
- <path>externs/node.js</path>
+ <name>externs/missing.js</name>
+ <path>missing.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/assert.js</name>
+ <path>externs/assert.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/buffer.js</name>
+ <path>externs/buffer.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/child_process.js</name>
+ <path>externs/child_process.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/cluster.js</name>
+ <path>externs/cluster.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/crypto.js</name>
+ <path>externs/crypto.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/dgram.js</name>
+ <path>externs/dgram.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/dns.js</name>
+ <path>externs/dns.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/domain.js</name>
+ <path>externs/domain.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/events.js</name>
+ <path>externs/events.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/fs.js</name>
+ <path>externs/fs.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/http.js</name>
+ <path>externs/http.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/https.js</name>
+ <path>externs/https.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/net.js</name>
+ <path>externs/net.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/os.js</name>
+ <path>externs/os.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/path.js</name>
+ <path>externs/path.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/punycode.js</name>
+ <path>externs/punycode.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/querystring.js</name>
+ <path>externs/querystring.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/readline.js</name>
+ <path>externs/readline.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/repl.js</name>
+ <path>externs/repl.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/stream.js</name>
+ <path>externs/stream.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/string_decoder.js</name>
+ <path>externs/string_decoder.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/tls.js</name>
+ <path>externs/tls.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/tty.js</name>
+ <path>externs/tty.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/url.js</name>
+ <path>externs/url.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/util.js</name>
+ <path>externs/util.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/vm.js</name>
+ <path>externs/vm.js</path>
+ </include-file>
+ <include-file>
+ <name>externs/zlib.js</name>
+ <path>externs/zlib.js</path>
</include-file>
</flex-config>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e6409b27/externs/node/externs/node.js
----------------------------------------------------------------------
diff --git a/externs/node/externs/node.js b/externs/node/externs/node.js
deleted file mode 100644
index ebacb75..0000000
--- a/externs/node/externs/node.js
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- * @fileoverview Externs for Node.js
- * @see https://nodejs.org/api/
- * @externs
- */
-
-/**
- * @param {string} id
- * @return {*}
- */
-function require(id) {};
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e6409b27/externs/node/missing.js
----------------------------------------------------------------------
diff --git a/externs/node/missing.js b/externs/node/missing.js
new file mode 100644
index 0000000..ebacb75
--- /dev/null
+++ b/externs/node/missing.js
@@ -0,0 +1,30 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @fileoverview Externs for Node.js
+ * @see https://nodejs.org/api/
+ * @externs
+ */
+
+/**
+ * @param {string} id
+ * @return {*}
+ */
+function require(id) {};
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e6409b27/externs/node/node-compile-config.xml
----------------------------------------------------------------------
diff --git a/externs/node/node-compile-config.xml b/externs/node/node-compile-config.xml
index e4f88dc..c0a3e50 100644
--- a/externs/node/node-compile-config.xml
+++ b/externs/node/node-compile-config.xml
@@ -31,7 +31,35 @@
</compiler>
<external>
- <path-element>externs/node.js</path-element>
+ <path-element>missing.js</path-element>
+ <path-element>externs/assert.js</path-element>
+ <path-element>externs/buffer.js</path-element>
+ <path-element>externs/child_process.js</path-element>
+ <path-element>externs/cluster.js</path-element>
+ <path-element>externs/crypto.js</path-element>
+ <path-element>externs/dgram.js</path-element>
+ <path-element>externs/dns.js</path-element>
+ <path-element>externs/domain.js</path-element>
+ <path-element>externs/events.js</path-element>
+ <path-element>externs/fs.js</path-element>
+ <!--<path-element>externs/globals.js</path-element>-->
+ <!--<path-element>externs/http.js</path-element>-->
+ <!--<path-element>externs/https.js</path-element>-->
+ <path-element>externs/net.js</path-element>
+ <path-element>externs/os.js</path-element>
+ <path-element>externs/path.js</path-element>
+ <path-element>externs/punycode.js</path-element>
+ <path-element>externs/querystring.js</path-element>
+ <path-element>externs/readline.js</path-element>
+ <path-element>externs/repl.js</path-element>
+ <path-element>externs/stream.js</path-element>
+ <path-element>externs/string_decoder.js</path-element>
+ <path-element>externs/tls.js</path-element>
+ <path-element>externs/tty.js</path-element>
+ <path-element>externs/url.js</path-element>
+ <path-element>externs/util.js</path-element>
+ <path-element>externs/vm.js</path-element>
+ <!--<path-element>externs/zlib.js</path-element>-->
</external>
<as-root>out/as</as-root>
[09/19] git commit: [flex-falcon]
[refs/heads/feature/maven-migration-test] - externs/js: some of the excludes
can now be included because externc issues have been fixed
Posted by cd...@apache.org.
externs/js: some of the excludes can now be included because externc issues have been fixed
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/15e753a7
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/15e753a7
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/15e753a7
Branch: refs/heads/feature/maven-migration-test
Commit: 15e753a7c70a12affeb6c8c572e20a645909a600
Parents: 2b5fb56
Author: Josh Tynjala <jo...@apache.org>
Authored: Tue Apr 19 16:36:18 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Tue Apr 19 16:36:18 2016 -0700
----------------------------------------------------------------------
.../codegen/externals/ExternalsTestUtils.java | 21 --------------------
externs/js/js-compile-config.xml | 20 -------------------
2 files changed, 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/15e753a7/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java
index 7956e25..da0571a 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java
@@ -58,31 +58,10 @@ public class ExternalsTestUtils
config.addExclude("Date", "valueOf");
config.addExclude("String", "valueOf");
- config.addExclude("FontFaceSet", "delete");
-
- config.addExclude("CSSStyleDeclaration", "cssText");
- config.addExclude("CSSStyleRule", "style");
- config.addExclude("CSSFontFaceRule", "style");
- config.addExclude("CSSPageRule", "style");
-
- config.addExclude("Generator", "throw");
- config.addExclude("Generator", "return");
config.addExclude("HTMLMenuItemElement", "default");
config.addExclude("MessageEvent", "data"); // TODO returns T
config.addExclude("MessageEvent", "initMessageEventNS"); // TODO param T
config.addExclude("MessageEvent", "initMessageEvent"); // TODO param T
- config.addExclude("MessageEvent", "default");
- config.addExclude("Object", "is");
- config.addExclude("Promise", "catch");
-
- config.addExclude("IDBCursor", "continue");
- config.addExclude("IDBCursor", "delete");
- config.addExclude("IDBObjectStore", "delete");
-
- // TODO method treated like field
- config.addFieldExclude("Iterator", "next");
- config.addExclude("Generator", "next");
- config.addExclude("LinkStyle", "sheet");
// SVG
config.addExclude("SVGStylable", "className");
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/15e753a7/externs/js/js-compile-config.xml
----------------------------------------------------------------------
diff --git a/externs/js/js-compile-config.xml b/externs/js/js-compile-config.xml
index 2346f10..7edd1d6 100644
--- a/externs/js/js-compile-config.xml
+++ b/externs/js/js-compile-config.xml
@@ -138,31 +138,11 @@
<class>String</class>
<name>valueOf</name>
</exclude>
- <exclude><class>FontFaceSet</class><name>delete</name></exclude>
- <exclude><class>CSSStyleDeclaration</class><name>cssText</name></exclude>
- <exclude><class>CSSStyleRule</class><name>style</name></exclude>
- <exclude><class>CSSFontFaceRule</class><name>style</name></exclude>
- <exclude><class>CSSPageRule</class><name>style</name></exclude>
-
- <exclude><class>Generator</class><name>throw</name></exclude>
- <exclude><class>Generator</class><name>return</name></exclude>
<exclude><class>HTMLMenuItemElement</class><name>default</name></exclude>
<exclude><class>MessageEvent</class><name>data</name></exclude><!-- TODO returns T -->
<exclude><class>MessageEvent</class><name>initMessageEventNS</name></exclude> <!-- TODO param T -->
<exclude><class>MessageEvent</class><name>initMessageEvent</name></exclude> <!-- TODO param T -->
- <exclude><class>MessageEvent</class><name>default</name></exclude>
- <exclude><class>Object</class><name>is</name></exclude>
- <exclude><class>Promise</class><name>catch</name></exclude>
-
- <exclude><class>IDBCursor</class><name>continue</name></exclude>
- <exclude><class>IDBCursor</class><name>delete</name></exclude>
- <exclude><class>IDBObjectStore</class><name>delete</name></exclude>
-
- <!-- TODO method treated like field -->
- <field-exclude><class>Iterator</class><field>next</field></field-exclude>
- <exclude><class>Generator</class><name>next</name></exclude>
- <exclude><class>LinkStyle</class><name>sheet</name></exclude>
<!-- SVG -->
<exclude><class>SVGStylable</class><name>className</name></exclude>
[10/19] git commit: [flex-falcon]
[refs/heads/feature/maven-migration-test] - compiler.jx: externc can now
handle typedefs inside packages
Posted by cd...@apache.org.
compiler.jx: externc can now handle typedefs inside packages
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/0c731405
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/0c731405
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/0c731405
Branch: refs/heads/feature/maven-migration-test
Commit: 0c731405da7569ab7b745c0cedb706afd033da5d
Parents: 15e753a
Author: Josh Tynjala <jo...@apache.org>
Authored: Wed Apr 20 09:35:14 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Wed Apr 20 09:35:14 2016 -0700
----------------------------------------------------------------------
.../internal/codegen/externals/pass/CollectTypesPass.java | 10 ++++++++++
1 file changed, 10 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/0c731405/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/CollectTypesPass.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/CollectTypesPass.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/CollectTypesPass.java
index 8ddde76..44a9cc4 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/CollectTypesPass.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/CollectTypesPass.java
@@ -92,6 +92,16 @@ public class CollectTypesPass extends AbstractCompilerPass
}
}
}
+ else
+ {
+ comment = container.getJSDocInfo();
+ boolean isConstructor = comment != null
+ && (comment.getTypedefType() != null);
+ if (isConstructor)
+ {
+ model.addTypeDef(container, container.getQualifiedName());
+ }
+ }
}
private void visitFunction(Node child)
[04/19] git commit: [flex-falcon]
[refs/heads/feature/maven-migration-test] - compiler.jx: downloads externs
for Node.js from closure-compiler repository and copies them into
externs/node/externs
Posted by cd...@apache.org.
compiler.jx: downloads externs for Node.js from closure-compiler repository and copies them into externs/node/externs
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/8bfea6d0
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/8bfea6d0
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/8bfea6d0
Branch: refs/heads/feature/maven-migration-test
Commit: 8bfea6d0a124d68e6e4e233293d7986d842690d4
Parents: a21948d
Author: Josh Tynjala <jo...@apache.org>
Authored: Tue Apr 19 14:29:25 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Tue Apr 19 14:29:25 2016 -0700
----------------------------------------------------------------------
compiler.jx/downloads.xml | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8bfea6d0/compiler.jx/downloads.xml
----------------------------------------------------------------------
diff --git a/compiler.jx/downloads.xml b/compiler.jx/downloads.xml
index de6bfe5..50b5648 100644
--- a/compiler.jx/downloads.xml
+++ b/compiler.jx/downloads.xml
@@ -253,11 +253,42 @@
<mkdir dir="${basedir}/../externs/jquery/externs" />
<mkdir dir="${basedir}/../externs/jasmine/externs" />
<mkdir dir="${basedir}/../externs/google_maps/externs" />
+ <mkdir dir="${basedir}/../externs/node/externs" />
<unzip src="${download.dir}/temp/externs/externs.zip" dest="${basedir}/../externs/js/externs" />
<get src="https://closureidl.googlecode.com/files/svg.js" dest="${basedir}/../externs/js/externs/svg.js"/>
<get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/externs/jquery-1.9.js" dest="${basedir}/../externs/jquery/externs/jquery-1.9.js"/>
<get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/externs/jasmine-2.0.js" dest="${basedir}/../externs/jasmine/externs/jasmine-2.0.js"/>
<get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/externs/maps/google_maps_api_v3_11.js" dest="${basedir}/../externs/google_maps/externs/google_maps_api_v3_11.js"/>
+ <!-- start node externs-->
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/assert.js" dest="${basedir}/../externs/node/externs/assert.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/buffer.js" dest="${basedir}/../externs/node/externs/buffer.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/child_process.js" dest="${basedir}/../externs/node/externs/child_process.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/cluster.js" dest="${basedir}/../externs/node/externs/cluster.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/crypto.js" dest="${basedir}/../externs/node/externs/crypto.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/dgram.js" dest="${basedir}/../externs/node/externs/dgram.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/dns.js" dest="${basedir}/../externs/node/externs/dns.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/domain.js" dest="${basedir}/../externs/node/externs/domain.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/events.js" dest="${basedir}/../externs/node/externs/events.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/fs.js" dest="${basedir}/../externs/node/externs/fs.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/globals.js" dest="${basedir}/../externs/node/externs/globals.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/http.js" dest="${basedir}/../externs/node/externs/http.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/https.js" dest="${basedir}/../externs/node/externs/https.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/net.js" dest="${basedir}/../externs/node/externs/net.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/os.js" dest="${basedir}/../externs/node/externs/os.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/path.js" dest="${basedir}/../externs/node/externs/path.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/punycode.js" dest="${basedir}/../externs/node/externs/punycode.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/querystring.js" dest="${basedir}/../externs/node/externs/querystring.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/readline.js" dest="${basedir}/../externs/node/externs/readline.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/repl.js" dest="${basedir}/../externs/node/externs/repl.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/stream.js" dest="${basedir}/../externs/node/externs/stream.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/string_decoder.js" dest="${basedir}/../externs/node/externs/string_decoder.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/tls.js" dest="${basedir}/../externs/node/externs/tls.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/tty.js" dest="${basedir}/../externs/node/externs/tty.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/url.js" dest="${basedir}/../externs/node/externs/url.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/util.js" dest="${basedir}/../externs/node/externs/util.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/vm.js" dest="${basedir}/../externs/node/externs/vm.js"/>
+ <get src="https://raw.githubusercontent.com/google/closure-compiler/master/contrib/nodejs/zlib.js" dest="${basedir}/../externs/node/externs/zlib.js"/>
+ <!-- end node externs-->
</target>
<target name="download-dependency-jar" if="project.download.jar" description="Downloads a jar to the lib directory.">
[16/19] git commit: [flex-falcon]
[refs/heads/feature/maven-migration-test] - - Renamed the "generate" goal to
"generate-extern" - Replicated the changes to the node extern to match the
develop branch - Fixed the replace commands in js to generate an ide
Posted by cd...@apache.org.
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dd503343/compiler/src/test/java/as/ASKeywordTests.java
----------------------------------------------------------------------
diff --cc compiler/src/test/java/as/ASKeywordTests.java
index 1602b3c,0000000..8223620
mode 100644,000000..100644
--- a/compiler/src/test/java/as/ASKeywordTests.java
+++ b/compiler/src/test/java/as/ASKeywordTests.java
@@@ -1,347 -1,0 +1,368 @@@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package as;
+
+import org.junit.Test;
+
+/**
+ * Feature tests for AS Namespaces.
+ */
+public class ASKeywordTests extends ASFeatureTestsBase
+{
+ @Test
+ public void ASKeyword_SwitchStatement()
+ {
+ // all tests can assume that flash.display.Sprite
+ // flash.system.System and flash.events.Event have been imported
+ String[] imports = new String[]
+ {
+ };
+ String[] declarations = new String[]
+ {
+ "public var foo:String;",
+ "public function hasSwitch(switcher:int):Boolean {",
+ " trace('hey, a method named namespace worked');",
+ " switch (switcher) {",
+ " case 1:",
+ " foo = 'bar';",
+ " break;",
+ " default:",
+ " foo = 'baz';",
+ " break;",
+ " }",
+ " return true;",
+ "}",
+ };
+ String[] testCode = new String[]
+ {
+ "hasSwitch(1);",
+ "assertEqual('switch worked', foo, 'bar');",
+ "hasSwitch(0);",
+ "assertEqual('switch worked', foo, 'baz');",
+ };
+ String source = getAS(imports, declarations, testCode, new String[0]);
+ compileAndRun(source);
+ }
+
+ @Test
+ public void ASKeyword_Namespace_as_method_name()
+ {
+ // all tests can assume that flash.display.Sprite
+ // flash.system.System and flash.events.Event have been imported
+ String[] imports = new String[]
+ {
+ };
+ String[] declarations = new String[]
+ {
+ "public var foo:String;",
+ "public function namespace(instance:Object):Boolean {",
+ " trace('hey, a method named namespace worked');",
+ " foo = 'as';",
+ " return true;",
+ "}",
+ };
+ String[] testCode = new String[]
+ {
+ "namespace(this);",
+ "assertEqual('method named namespace', foo, 'as');",
+ };
+ String source = getAS(imports, declarations, testCode, new String[0]);
+ compileAndRun(source);
+ }
+
+ @Test
+ public void ASKeyword_Default_as_method_name()
+ {
+ // all tests can assume that flash.display.Sprite
+ // flash.system.System and flash.events.Event have been imported
+ String[] imports = new String[]
+ {
+ };
+ String[] declarations = new String[]
+ {
+ "public var foo:String;",
+ "public function default(instance:Object):Boolean {",
+ " trace('hey, a method named default worked');",
+ " foo = 'as';",
+ " return true;",
+ "}",
+ };
+ String[] testCode = new String[]
+ {
+ "default(this);",
+ "assertEqual('method named default', foo, 'as');",
+ };
+ String source = getAS(imports, declarations, testCode, new String[0]);
+ compileAndRun(source);
+ }
+
+ @Test
+ public void ASKeyword_for_as_method_name()
+ {
+ // all tests can assume that flash.display.Sprite
+ // flash.system.System and flash.events.Event have been imported
+ String[] imports = new String[]
+ {
+ };
+ String[] declarations = new String[]
+ {
+ "public var foo:String;",
+ "public function for(instance:Object):Boolean {",
+ " trace('hey, a method named default worked');",
+ " foo = 'as';",
+ " return true;",
+ "}",
+ };
+ String[] testCode = new String[]
+ {
+ "this.for(this);",
+ "assertEqual('method named default', foo, 'as');",
+ };
+ String source = getAS(imports, declarations, testCode, new String[0]);
+ compileAndRun(source);
+ }
+
+ @Test
+ public void ASKeyword_Get_as_method_name()
+ {
+ // all tests can assume that flash.display.Sprite
+ // flash.system.System and flash.events.Event have been imported
+ String[] imports = new String[]
+ {
+ };
+ String[] declarations = new String[]
+ {
+ "public var foo:String;",
+ "public function get(instance:Object):Boolean {",
+ " trace('hey, a method named get worked');",
+ " foo = 'as';",
+ " return true;",
+ "}",
+ };
+ String[] testCode = new String[]
+ {
+ "get(this);",
+ "assertEqual('method named get', foo, 'as');",
+ };
+ String source = getAS(imports, declarations, testCode, new String[0]);
+ compileAndRun(source);
+ }
+
+ @Test
+ public void ASKeyword_Get_as_getter_name()
+ {
+ // all tests can assume that flash.display.Sprite
+ // flash.system.System and flash.events.Event have been imported
+ String[] imports = new String[]
+ {
+ };
+ String[] declarations = new String[]
+ {
+ "public var foo:String;",
+ "public function get get():Boolean {",
+ " trace('hey, a getter named get worked');",
+ " foo = 'as';",
+ " return true;",
+ "}",
+ };
+ String[] testCode = new String[]
+ {
+ "var bar:Boolean = get;",
+ "assertEqual('getter named get', foo, 'as');",
+ };
+ String source = getAS(imports, declarations, testCode, new String[0]);
+ compileAndRun(source);
+ }
+
+ @Test
+ public void ASKeyword_Get_as_member_expression_name()
+ {
+ // all tests can assume that flash.display.Sprite
+ // flash.system.System and flash.events.Event have been imported
+ String[] imports = new String[]
+ {
+ };
+ String[] declarations = new String[]
+ {
+ "public var foo:String;",
+ "public function get get():Boolean {",
+ " trace('hey, a getter named get worked');",
+ " foo = 'as';",
+ " return true;",
+ "}",
+ };
+ String[] testCode = new String[]
+ {
+ "var bar:Boolean = this.get;",
+ "assertEqual('getter named get', foo, 'as');",
+ };
+ String source = getAS(imports, declarations, testCode, new String[0]);
+ compileAndRun(source);
+ }
+
+ @Test
+ public void ASKeyword_as_method_name()
+ {
+ // all tests can assume that flash.display.Sprite
+ // flash.system.System and flash.events.Event have been imported
+ String[] imports = new String[]
+ {
+ };
+ String[] declarations = new String[]
+ {
+ "public var foo:String;",
+ "public function as(instance:Object):Boolean {",
+ " trace('hey, a method named as worked');",
+ " foo = 'as';",
+ " return true;",
+ "}",
+ };
+ String[] testCode = new String[]
+ {
+ "as(this);",
+ "assertEqual('method named as', foo, 'as');",
+ };
+ String source = getAS(imports, declarations, testCode, new String[0]);
+ compileAndRun(source);
+ }
+
+ @Test
+ public void ASKeyword_as_property_name()
+ {
+ // all tests can assume that flash.display.Sprite
+ // flash.system.System and flash.events.Event have been imported
+ String[] imports = new String[]
+ {
+ };
+ String[] declarations = new String[]
+ {
+ "public var foo:String;",
+ "public function get as():String {",
+ " return foo;",
+ "}",
+ "public function set as(value:String):void {",
+ " foo = value;",
+ "}",
+ };
+ String[] testCode = new String[]
+ {
+ "as = 'bar';",
+ "assertEqual('property named as', as, 'bar');",
+ };
+ String source = getAS(imports, declarations, testCode, new String[0]);
+ compileAndRun(source);
+ }
+
+ @Test
+ public void ASKeyword_as_variable_name()
+ {
+ // all tests can assume that flash.display.Sprite
+ // flash.system.System and flash.events.Event have been imported
+ String[] imports = new String[]
+ {
+ };
+ String[] declarations = new String[]
+ {
+ "public var as:String;",
+ };
+ String[] testCode = new String[]
+ {
+ "as = 'bar';",
+ "assertEqual('variable named as', as, 'bar');",
+ };
+ String source = getAS(imports, declarations, testCode, new String[0]);
+ compileAndRun(source);
+ }
+
+ @Test
++ public void ASKeyword_default_as_variable_name()
++ {
++ // all tests can assume that flash.display.Sprite
++ // flash.system.System and flash.events.Event have been imported
++ String[] imports = new String[]
++ {
++ };
++ String[] declarations = new String[]
++ {
++ "public var default:String;",
++ };
++ String[] testCode = new String[]
++ {
++ "default = 'bar';",
++ "assertEqual('variable named default', default, 'bar');",
++ };
++ String source = getAS(imports, declarations, testCode, new String[0]);
++ compileAndRun(source);
++ }
++
++ @Test
+ public void ASKeyword_as_member_expression()
+ {
+ // all tests can assume that flash.display.Sprite
+ // flash.system.System and flash.events.Event have been imported
+ String[] imports = new String[]
+ {
+ };
+ String[] declarations = new String[]
+ {
+ "public var as:String;",
+ };
+ String[] testCode = new String[]
+ {
+ "this.as = 'bar';",
+ "assertEqual('variable named as', this.as, 'bar');",
+ };
+ String source = getAS(imports, declarations, testCode, new String[0]);
+ compileAndRun(source);
+ }
+
+ @Test
+ public void AS_new_function_returned_from_function()
+ {
+ // all tests can assume that flash.display.Sprite
+ // flash.system.System and flash.events.Event have been imported
+ String[] imports = new String[]
+ {
+ };
+ String[] declarations = new String[]
+ {
+ };
+ String[] testCode = new String[]
+ {
+ "function getClass(index:Number):Class {",
+ " if (index == 0) return Inner;",
+ " return Number;",
+ "}",
+ "var foo:Inner = new getClass(0)('foo');",
+ "assertEqual('foo.value', foo.value, 'foo');",
+ };
+ String[] extra = new String[]
+ {
+ "class Inner {",
+ " public function Inner(value:String) {",
+ " this.value = value;",
+ " }",
+ " public var value:String;",
+ "}",
+ };
+ String source = getAS(imports, declarations, testCode, extra);
+ compileAndRun(source);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dd503343/externs/js/pom.xml
----------------------------------------------------------------------
diff --cc externs/js/pom.xml
index c41fae1,0000000..bd3dd0f
mode 100644,000000..100644
--- a/externs/js/pom.xml
+++ b/externs/js/pom.xml
@@@ -1,159 -1,0 +1,160 @@@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.flex.flexjs.externs</groupId>
+ <artifactId>flexjs-externs</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>flexjs-externs-js</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ <packaging>swc</packaging>
+
+ <name>Apache Flex - FlexJS: Externs: JS</name>
+
+ <build>
+ <plugins>
+ <!-- Download JavaScript form GitHub -->
+ <plugin>
+ <groupId>com.googlecode.maven-download-plugin</groupId>
+ <artifactId>download-maven-plugin</artifactId>
+ <version>1.2.1</version>
+ <executions>
+ <execution>
+ <id>get-createjs</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>wget</goal>
+ </goals>
+ <configuration>
+ <url>https://closureidl.googlecode.com/files/svg.js</url>
+ <outputFileName>svg.js</outputFileName>
+ <outputDirectory>${project.build.directory}/downloads</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.flex.flexjs.compiler</groupId>
+ <artifactId>compiler-build-tools</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <id>unpack-closure-externs</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>unpack-resources</goal>
+ </goals>
+ <configuration>
+ <resource>externs.zip</resource>
+ </configuration>
+ </execution>
+ <execution>
+ <id>pre-process-javascript-sources-svg</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>pre-process-sources</goal>
+ </goals>
+ <configuration>
+ <operations>
+ <replace-regexp-operation><match>@type \{function\(new:.*</match><replace/></replace-regexp-operation>
+ <replace-regexp-operation><match>Window\.prototype\..*</match><replace/></replace-regexp-operation>
+ <replace-regexp-operation><match>EventListener\|\(function\(Event\)</match><replace>EventListener|(function(!Event)</replace></replace-regexp-operation>
+ </operations>
+ <includes>
+ <include>svg.js</include>
+ </includes>
+ </configuration>
+ </execution>
+ <execution>
+ <id>pre-process-javascript-sources-es3</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>pre-process-sources</goal>
+ </goals>
+ <configuration>
+ <operations>
+ <replace-regexp-operation><match>(The constructor of the current object\.\n.*)@type\s\{Function\}</match><replace>$1@type {Class}</replace></replace-regexp-operation>
+ <replace-regexp-operation><match>Object\.prototype\.constructor\s=\sfunction\(\)\s\{\};</match><replace>Object.prototype.constructor;</replace></replace-regexp-operation>
- <replace-regexp-operation><match>(Transposes the elements of an array in place.*\n.*\n.*)(\n.*\s@this)</match><replace>$1 @return {!Array<?>}$2</replace></replace-regexp-operation>
++ <replace-regexp-operation><match>(Transposes the elements of an array in place.*\n.*\n.*)(\n.*\s@this)</match><replace>$1\n \* @return {!Array<?>}$2</replace></replace-regexp-operation>
++ <replace-regexp-operation><match>(Sorts the elements of an array in place.*\n..*)(\n.*\s@param)</match><replace>$1\n \* @return {!Array<?>}$2</replace></replace-regexp-operation>
+ </operations>
+ <includes>
+ <include>es3.js</include>
+ </includes>
+ </configuration>
+ </execution>
+ </executions>
+ <!--
+ Dependency to the closure compiler externs artifact so
+ the "unpack-resources" goal can find the externs.zip
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>com.google.javascript</groupId>
+ <artifactId>closure-compiler-externs</artifactId>
+ <version>v20151015</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.flex.flexjs.compiler</groupId>
+ <artifactId>flexjs-maven-plugin</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ <extensions>true</extensions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.flex.flexjs.compiler</groupId>
+ <artifactId>compiler-jx</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.flex.flexjs.compiler</groupId>
+ <artifactId>compiler-build-tools</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <id>pre-process-actionscript-sources</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>pre-process-sources</goal>
+ </goals>
+ <configuration>
+ <operations>
+ <replace-regexp-operation><match>base\:Number\)</match><replace>base:Number = 10)</replace></replace-regexp-operation>
+ </operations>
+ <downloadesSourceDirectory>target/generated-sources/externc</downloadesSourceDirectory>
+ <includes>
+ <include>functions/parseInt.as</include>
+ </includes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dd503343/externs/js/src/main/config/externc-config.xml
----------------------------------------------------------------------
diff --cc externs/js/src/main/config/externc-config.xml
index f4a3b20,0000000..8ce6c29
mode 100644,000000..100644
--- a/externs/js/src/main/config/externc-config.xml
+++ b/externs/js/src/main/config/externc-config.xml
@@@ -1,173 -1,0 +1,173 @@@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License</name></exclude> you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<flex-config>
+
+ <compiler>
+ <accessible>true</accessible>
+
+ <!--
+ <external-library-path>
+ <path-element>${env.PLAYERGLOBAL_HOME}/${playerglobal.version}/playerglobal.swc</path-element>
+ <path-element>../../libs/framework.swc</path-element>
+ <path-element>../../libs/mx/mx.swc</path-element>
+ <path-element>../../libs/osmf.swc</path-element>
+ <path-element>../../libs/textLayout.swc</path-element>
+ </external-library-path>
+
+ <keep-as3-metadata>
+ <name>SkinPart</name>
+ </keep-as3-metadata>
+
+ <mxml>
+ <minimum-supported-version>4.0.0</minimum-supported-version>
+ </mxml>
+ -->
+
+ <locale/>
+
+ <library-path/>
+
+ <!--
+ <namespaces>
+ <namespace>
+ <uri>library://ns.adobe.com/flex/spark</uri>
+ <manifest>manifest.xml</manifest>
+ </namespace>
+ </namespaces>
+ -->
+
+ <source-path>
+ <path-element>src</path-element>
+ </source-path>
+
+ <warn-no-constructor>false</warn-no-constructor>
+ </compiler>
+
+ <external>
+ <path-element>../javascript/missing.js</path-element>
+ <path-element>../../../target/downloads/es3.js</path-element>
+ <path-element>../../../target/downloads/es5.js</path-element>
+ <path-element>../../../target/downloads/es6.js</path-element>
+ <path-element>../../../target/downloads/browser/w3c_anim_timing.js</path-element>
+ <path-element>../../../target/downloads/browser/w3c_audio.js</path-element>
+ <path-element>../../../target/downloads/browser/w3c_batterystatus.js</path-element>
+ <path-element>../../../target/downloads/browser/w3c_css.js</path-element>
+ <path-element>../../../target/downloads/browser/w3c_css3d.js</path-element>
+ <path-element>../../../target/downloads/browser/w3c_device_sensor_event.js</path-element>
+ <path-element>../../../target/downloads/browser/w3c_dom1.js</path-element>
+ <path-element>../../../target/downloads/browser/w3c_dom2.js</path-element>
+ <path-element>../../../target/downloads/browser/w3c_dom3.js</path-element>
+ <path-element>../../../target/downloads/browser/w3c_elementtraversal.js</path-element>
+ <path-element>../../../target/downloads/browser/w3c_encoding.js</path-element>
+ <path-element>../../../target/downloads/browser/w3c_event.js</path-element>
+ <path-element>../../../target/downloads/browser/w3c_event3.js</path-element>
+ <path-element>../../../target/downloads/browser/w3c_geolocation.js</path-element>
+ <path-element>../../../target/downloads/browser/w3c_indexeddb.js</path-element>
+ <path-element>../../../target/downloads/browser/w3c_navigation_timing.js</path-element>
+ <path-element>../../../target/downloads/browser/w3c_range.js</path-element>
+ <path-element>../../../target/downloads/browser/w3c_rtc.js</path-element>
+ <path-element>../../../target/downloads/browser/w3c_selectors.js</path-element>
+ <!-- path-element>../../../target/downloads/browser/w3c_serviceworker.js</path-element> -->
+ <!-- path-element>../../../target/downloads/browser/w3c_webcrypto.js</path-element> -->
+ <path-element>../../../target/downloads/browser/w3c_xml.js</path-element>
+
- <!-- path-element>externs/fetchapi</path-element> -->
++ <!-- path-element>../../../target/downloads/fetchapi</path-element> -->
+
+ <path-element>../../../target/downloads/browser/window.js</path-element>
+
+ <path-element>../../../target/downloads/browser/ie_dom.js</path-element>
+ <path-element>../../../target/downloads/browser/gecko_dom.js</path-element>
+ <path-element>../../../target/downloads/browser/gecko_xml.js</path-element>
+ <path-element>../../../target/downloads/browser/gecko_event.js</path-element>
+
+ <path-element>../../../target/downloads/browser/webkit_css.js</path-element>
+ <path-element>../../../target/downloads/browser/webkit_dom.js</path-element>
+ <path-element>../../../target/downloads/browser/webkit_event.js</path-element>
+ <!-- path-element>externs/webkit_notifications.js</path-element> -->
+
+ <path-element>../../../target/downloads/browser/iphone.js</path-element>
+ <path-element>../../../target/downloads/browser/chrome.js</path-element>
+ <path-element>../../../target/downloads/browser/flash.js</path-element>
+
+ <path-element>../../../target/downloads/browser/page_visibility.js</path-element>
+ <path-element>../../../target/downloads/browser/fileapi.js</path-element>
+ <path-element>../../../target/downloads/browser/html5.js</path-element>
+
+ <path-element>../../../target/downloads/browser/webgl.js</path-element>
+ <path-element>../../../target/downloads/browser/webstorage.js</path-element>
+
+ <path-element>../../../target/downloads/svg.js</path-element>
+ </external>
+
+ <as-root>../../../target/generated-sources/externc</as-root>
+
+ <field-exclude>
+ <class>Window</class>
+ <field>focus</field>
+ </field-exclude>
+
+ <class-exclude>
+ <class>controlRange</class>
+ </class-exclude>
+
+ <exclude>
+ <class>Array</class>
+ <name>toSource</name>
+ </exclude>
+ <exclude>
+ <class>Date</class>
+ <name>valueOf</name>
+ </exclude>
+ <exclude>
+ <class>String</class>
+ <name>valueOf</name>
+ </exclude>
+ <exclude><class>FontFaceSet</class><name>delete</name></exclude>
-
++
+ <exclude><class>CSSStyleDeclaration</class><name>cssText</name></exclude>
+ <exclude><class>CSSStyleRule</class><name>style</name></exclude>
+ <exclude><class>CSSFontFaceRule</class><name>style</name></exclude>
+ <exclude><class>CSSPageRule</class><name>style</name></exclude>
-
++
+ <exclude><class>Generator</class><name>throw</name></exclude>
+ <exclude><class>Generator</class><name>return</name></exclude>
+ <exclude><class>HTMLMenuItemElement</class><name>default</name></exclude>
+ <exclude><class>MessageEvent</class><name>data</name></exclude><!-- TODO returns T -->
+ <exclude><class>MessageEvent</class><name>initMessageEventNS</name></exclude> <!-- TODO param T -->
+ <exclude><class>MessageEvent</class><name>initMessageEvent</name></exclude> <!-- TODO param T -->
+ <exclude><class>MessageEvent</class><name>default</name></exclude>
+ <exclude><class>Object</class><name>is</name></exclude>
+ <exclude><class>Promise</class><name>catch</name></exclude>
-
++
+ <exclude><class>IDBCursor</class><name>continue</name></exclude>
+ <exclude><class>IDBCursor</class><name>delete</name></exclude>
+ <exclude><class>IDBObjectStore</class><name>delete</name></exclude>
-
++
+ <!-- TODO method treated like field -->
+ <field-exclude><class>Iterator</class><field>next</field></field-exclude>
+ <exclude><class>Generator</class><name>next</name></exclude>
+ <exclude><class>LinkStyle</class><name>sheet</name></exclude>
-
++
+ <!-- SVG -->
+ <exclude><class>SVGStylable</class><name>className</name></exclude>
+ <exclude><class>SVGStylable</class><name>style</name></exclude>
+ <exclude><class>SVGLocatable</class><name>farthestViewportElement</name></exclude>
+ <exclude><class>SVGLocatable</class><name>nearestViewportElement</name></exclude>
+
+</flex-config>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dd503343/externs/node/pom.xml
----------------------------------------------------------------------
diff --cc externs/node/pom.xml
index 9e448ab,0000000..7233c7a
mode 100644,000000..100644
--- a/externs/node/pom.xml
+++ b/externs/node/pom.xml
@@@ -1,64 -1,0 +1,90 @@@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.flex.flexjs.externs</groupId>
+ <artifactId>flexjs-externs</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>flexjs-externs-node</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ <packaging>swc</packaging>
+
+ <name>Apache Flex - FlexJS: Externs: Node</name>
+
+ <build>
+ <plugins>
++ <!-- Download JavaScript form GitHub -->
++ <plugin>
++ <groupId>com.googlecode.maven-download-plugin</groupId>
++ <artifactId>download-maven-plugin</artifactId>
++ <version>1.2.1</version>
++ <executions>
++ <execution>
++ <id>get-closure-sources</id>
++ <phase>validate</phase>
++ <goals>
++ <goal>wget</goal>
++ </goals>
++ <configuration>
++ <url>https://github.com/google/closure-compiler/archive/master.zip</url>
++ <!--
++ Give it a number matching the date so we can
++ trigger a new download by updating the date
++ -->
++ <outputFileName>closure-compiler-20160421.zip</outputFileName>
++ <outputDirectory>${project.build.directory}/downloads</outputDirectory>
++ <unpack>true</unpack>
++ </configuration>
++ </execution>
++ </executions>
++ </plugin>
++
+ <plugin>
+ <groupId>org.apache.flex.flexjs.compiler</groupId>
+ <artifactId>flexjs-maven-plugin</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ <extensions>true</extensions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.flex.flexjs.compiler</groupId>
+ <artifactId>compiler-jx</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.flex.flexjs.externs</groupId>
+ <artifactId>flexjs-externs-js</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ <type>swc</type>
+ <scope>external</scope>
+ </dependency>
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dd503343/externs/node/src/main/config/compile-as-config.xml
----------------------------------------------------------------------
diff --cc externs/node/src/main/config/compile-as-config.xml
index db19882,0000000..2af392d
mode 100644,000000..100644
--- a/externs/node/src/main/config/compile-as-config.xml
+++ b/externs/node/src/main/config/compile-as-config.xml
@@@ -1,42 -1,0 +1,159 @@@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<flex-config>
+
+ <compiler>
+ <accessible>true</accessible>
+
+ <external-library-path>
+ </external-library-path>
-
++
+ <source-path>
++ <path-element>generated-sources/externc/constants</path-element>
++ <path-element>generated-sources/externc/classes</path-element>
+ <path-element>generated-sources/externc/functions</path-element>
++ <path-element>generated-sources/externc/typedefs</path-element>
++ <path-element>generated-sources/externc/duplicates</path-element>
+ </source-path>
+
+ <warn-no-constructor>false</warn-no-constructor>
+ </compiler>
+
+ <include-sources>
++ <path-element>generated-sources/externc/constants</path-element>
++ <path-element>generated-sources/externc/classes</path-element>
+ <path-element>generated-sources/externc/functions</path-element>
++ <path-element>generated-sources/externc/typedefs</path-element>
++ <path-element>generated-sources/externc/duplicates</path-element>
+ </include-sources>
+
+ <include-file>
- <name>externs/node.js</name>
- <path>../src/main/javascript/node.js</path>
++ <name>externs/missing.js</name>
++ <path>../src/main/javascript/missing.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/assert.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/assert.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/buffer.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/buffer.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/child_process.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/child_process.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/cluster.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/cluster.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/crypto.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/crypto.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/dgram.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/dgram.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/dns.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/dns.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/domain.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/domain.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/events.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/events.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/fs.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/fs.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/http.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/http.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/https.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/https.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/net.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/net.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/os.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/os.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/path.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/path.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/punycode.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/punycode.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/querystring.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/querystring.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/readline.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/readline.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/repl.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/repl.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/stream.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/stream.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/string_decoder.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/string_decoder.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/tls.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/tls.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/tty.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/tty.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/url.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/url.js</path>
+ </include-file>
++ <include-file>
++ <name>externs/util.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/util.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/vm.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/vm.js</path>
++ </include-file>
++ <include-file>
++ <name>externs/zlib.js</name>
++ <path>downloads/closure-compiler-master/contrib/nodejs/zlib.js</path>
++ </include-file>
++
+</flex-config>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dd503343/externs/node/src/main/config/externc-config.xml
----------------------------------------------------------------------
diff --cc externs/node/src/main/config/externc-config.xml
index ecde54f,0000000..ce578d2
mode 100644,000000..100644
--- a/externs/node/src/main/config/externc-config.xml
+++ b/externs/node/src/main/config/externc-config.xml
@@@ -1,39 -1,0 +1,71 @@@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License</name></exclude> you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<flex-config>
+
+ <compiler>
+ <accessible>true</accessible>
+
+ <locale/>
+
+ <source-path>
+ <path-element>src/main/javascript</path-element>
+ </source-path>
+
+ <warn-no-constructor>false</warn-no-constructor>
+ </compiler>
-
++
+ <external>
- <path-element>../javascript/node.js</path-element>
++ <path-element>../javascript/missing.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/assert.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/buffer.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/child_process.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/cluster.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/crypto.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/dgram.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/dns.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/domain.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/events.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/fs.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/globals.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/http.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/https.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/net.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/os.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/path.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/punycode.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/querystring.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/readline.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/repl.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/stream.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/string_decoder.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/tls.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/tty.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/url.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/util.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/vm.js</path-element>
++ <path-element>../../../target/downloads/closure-compiler-master/contrib/nodejs/zlib.js</path-element>
+ </external>
++ <exclude>
++ <class>Buffer</class>
++ <name>toJSON</name>
++ </exclude>
+
+ <as-root>../../../target/generated-sources/externc</as-root>
+
+</flex-config>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dd503343/externs/node/src/main/javascript/missing.js
----------------------------------------------------------------------
diff --cc externs/node/src/main/javascript/missing.js
index 0000000,0000000..d6c73f3
new file mode 100644
--- /dev/null
+++ b/externs/node/src/main/javascript/missing.js
@@@ -1,0 -1,0 +1,25 @@@
++/*
++ *
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache License, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ *
++ */
++
++/**
++ * @fileoverview Externs for Node.js
++ * @see https://nodejs.org/api/
++ * @externs
++ */
++
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dd503343/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/ExterncMojo.java
----------------------------------------------------------------------
diff --cc flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/ExterncMojo.java
index 53e8a56,0000000..dd14db5
mode 100644,000000..100644
--- a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/ExterncMojo.java
+++ b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/ExterncMojo.java
@@@ -1,62 -1,0 +1,62 @@@
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flex.maven.flexjs;
+
+import org.apache.flex.tools.FlexTool;
+import org.apache.flex.tools.FlexToolGroup;
+import org.apache.flex.tools.FlexToolRegistry;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+import java.io.File;
+
+/**
+ * goal which generates actionscript code from javascript.
+ */
- @Mojo(name="generate",defaultPhase = LifecyclePhase.PROCESS_SOURCES)
++@Mojo(name="generate-extern",defaultPhase = LifecyclePhase.PROCESS_SOURCES)
+public class ExterncMojo
+ extends AbstractMojo
+{
+
+ @Parameter(defaultValue="${basedir}/src/main/config/externc-config.xml")
+ private File configFile;
+
+ public void execute()
+ throws MojoExecutionException
+ {
+ if(!configFile.exists()) {
+ getLog().info("Skipping Generation of ActionScript code due to missing config file: " +
+ configFile.getPath());
+ return;
+ }
+
+ FlexToolRegistry toolRegistry = new FlexToolRegistry();
+ FlexToolGroup toolGroup = toolRegistry.getToolGroup("FlexJS");
+ if(toolGroup == null) {
+ throw new MojoExecutionException("Could not find tool group: FlexJS");
+ }
+
+ // TODO: Change this to a flex-tool-api constant ...
+ FlexTool compc = toolGroup.getFlexTool("EXTERNC");
+ String[] args = {"+flexlib=externs", "-debug", "-load-config=" + configFile.getPath()};
+ compc.execute(args);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dd503343/flexjs-maven-plugin/src/main/resources/META-INF/plexus/components.xml
----------------------------------------------------------------------
diff --cc flexjs-maven-plugin/src/main/resources/META-INF/plexus/components.xml
index 7329c8f,0000000..c84be9c
mode 100644,000000..100644
--- a/flexjs-maven-plugin/src/main/resources/META-INF/plexus/components.xml
+++ b/flexjs-maven-plugin/src/main/resources/META-INF/plexus/components.xml
@@@ -1,71 -1,0 +1,71 @@@
+<?xml version="1.0"?>
+<component-set>
+ <components>
+ <component>
+ <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
+ <role-hint>swc</role-hint>
+ <implementation>
+ org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping
+ </implementation>
+ <configuration>
+ <lifecycles>
+ <lifecycle>
+ <id>default</id>
+ <phases>
+ <generate-sources>
- org.apache.flex.flexjs.compiler:flexjs-maven-plugin:generate
++ org.apache.flex.flexjs.compiler:flexjs-maven-plugin:generate-extern
+ </generate-sources>
+ <process-resources>
+ org.apache.maven.plugins:maven-resources-plugin:resources
+ </process-resources>
+ <compile>
+ org.apache.flex.flexjs.compiler:flexjs-maven-plugin:compile-js,
+ org.apache.flex.flexjs.compiler:flexjs-maven-plugin:compile-as
+ </compile>
+ <process-test-resources>
+ org.apache.maven.plugins:maven-resources-plugin:testResources
+ </process-test-resources>
+ <!--generate-test-sources>
+
+ </generate-test-sources-->
+ <!--generate-test-resources>
+
+ </generate-test-resources-->
+ <!--test-compile>
+ org.apache.flex.flexjs.compiler:flexjs-maven-plugin:testCompile
+ </test-compile-->
+ <process-test-classes>
+ org.apache.flex.flexjs.compiler:flexjs-maven-plugin:trust
+ </process-test-classes>
+ <!--test>
+ org.apache.maven.plugins:maven-surefire-plugin:test
+ </test-->
+ <!--package>
+ org.apache.flex.flexjs.compiler:flexjs-maven-plugin:package
+ </package-->
+ <install>
+ org.apache.maven.plugins:maven-install-plugin:install
+ </install>
+ <deploy>
+ org.apache.maven.plugins:maven-deploy-plugin:deploy
+ </deploy>
+ </phases>
+ </lifecycle>
+ </lifecycles>
+ </configuration>
+ </component>
+ <component>
+ <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+ <role-hint>swc</role-hint>
+ <implementation>
+ org.apache.maven.artifact.handler.DefaultArtifactHandler
+ </implementation>
+ <configuration>
+ <type>swc</type>
+ <extension>swc</extension>
+ <language>flex</language>
+ <addedToClasspath>true</addedToClasspath>
+ </configuration>
+ </component>
+ </components>
+</component-set>
[06/19] git commit: [flex-falcon]
[refs/heads/feature/maven-migration-test] - externc: add ability to handle
methods declared without = function() by detecting if param or returns JSDoc
is present
Posted by cd...@apache.org.
externc: add ability to handle methods declared without = function() by detecting if param or returns JSDoc is present
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/4ed67a8f
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/4ed67a8f
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/4ed67a8f
Branch: refs/heads/feature/maven-migration-test
Commit: 4ed67a8fed775a92d0d7dcd998aabbb2f7fd10fd
Parents: e6409b2
Author: Josh Tynjala <jo...@apache.org>
Authored: Tue Apr 19 16:06:22 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Tue Apr 19 16:06:22 2016 -0700
----------------------------------------------------------------------
.../codegen/externals/pass/AddMemberPass.java | 43 +++++++++++++++++++-
.../externals/reference/MethodReference.java | 33 ++++++++++++++-
.../externals/reference/ParameterReference.java | 6 +++
.../codegen/externals/utils/FunctionUtils.java | 2 +-
4 files changed, 81 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/4ed67a8f/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/AddMemberPass.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/AddMemberPass.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/AddMemberPass.java
index 8379af9..9308ff0 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/AddMemberPass.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/pass/AddMemberPass.java
@@ -23,6 +23,7 @@ import org.apache.flex.compiler.internal.codegen.externals.reference.ReferenceMo
import com.google.javascript.jscomp.AbstractCompiler;
import com.google.javascript.jscomp.NodeTraversal;
+import com.google.javascript.rhino.JSDocInfo;
import com.google.javascript.rhino.Node;
public class AddMemberPass extends AbstractCompilerPass
@@ -80,7 +81,19 @@ public class AddMemberPass extends AbstractCompilerPass
}
else if (first.isGetProp())
{
- visitGetProp(t, first);
+ JSDocInfo jsDocInfo = first.getJSDocInfo();
+ if (jsDocInfo != null
+ && (jsDocInfo.getParameterCount() > 0
+ || jsDocInfo.getReturnType() != null))
+ {
+ // instance or static method that isn't declared as a
+ // function, but has @param or @returns
+ visitMethodFromJSDoc(t, first);
+ }
+ else
+ {
+ visitGetProp(t, first);
+ }
}
}
}
@@ -119,6 +132,34 @@ public class AddMemberPass extends AbstractCompilerPass
log(n);
}
}
+ private void visitMethodFromJSDoc(NodeTraversal t, Node n)
+ {
+ String qName = n.getQualifiedName();
+
+ if (n.isGetProp())
+ {
+ int protoType = qName.indexOf(".prototype.");
+ if (protoType != -1)
+ {
+ String className = qName.substring(0, protoType);
+ String memberName = qName.substring(protoType + 11,
+ qName.length());
+ model.addMethod(n, className, memberName);
+ }
+ else
+ {
+ String className = qName.substring(0, qName.lastIndexOf("."));
+ String memberName = qName.substring(qName.lastIndexOf(".") + 1,
+ qName.length());
+ model.addStaticMethod(n, className, memberName);
+ }
+ }
+ else if (n.isName())
+ {
+ err("visitMethod() non impl");
+ log(n);
+ }
+ }
private void visitGetProp(NodeTraversal t, Node n)
{
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/4ed67a8f/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java
index 96aa9f2..6cfbadf 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java
@@ -28,6 +28,7 @@ import org.apache.flex.compiler.internal.codegen.externals.utils.FunctionUtils;
import com.google.common.collect.Lists;
import com.google.javascript.rhino.JSDocInfo;
+import com.google.javascript.rhino.JSTypeExpression;
import com.google.javascript.rhino.Node;
import com.google.javascript.rhino.jstype.JSType;
@@ -122,6 +123,20 @@ public class MethodReference extends MemberReference
parameters.add(parameterReference);
}
}
+ else if(comment.getParameterCount() > 0 || comment.getReturnType() != null)
+ {
+ for (int i = 0; i < comment.getParameterCount(); i++)
+ {
+ String parameterName = comment.getParameterNameAt(i);
+ String qualifiedName = FunctionUtils.toParameterType(this, parameterName);
+ ParameterReference parameterReference = new ParameterReference(getModel(), parameterName, qualifiedName);
+ parameters.add(parameterReference);
+ }
+ }
+ else
+ {
+ System.out.println(getQualifiedName() + " parameters not found! " + " " + comment.getParameterCount());
+ }
}
@Override
@@ -300,7 +315,23 @@ public class MethodReference extends MemberReference
private String toParameterString()
{
- return FunctionUtils.toParameterString(getContext(), getContext().getComment(), paramNode, outputJS);
+ if (paramNode != null)
+ {
+ return FunctionUtils.toParameterString(getContext(), getContext().getComment(), paramNode, outputJS);
+ }
+ StringBuilder sb = new StringBuilder();
+ sb.append("(");
+ int len = comment.getParameterCount();
+ for (int i = 0; i < len; i++)
+ {
+ String parameterName = comment.getParameterNameAt(i);
+ JSTypeExpression parameterType = comment.getParameterType(i);
+ sb.append(FunctionUtils.toParameter(getContext(), comment, parameterName, parameterType, outputJS));
+ if (i < len - 1)
+ sb.append(", ");
+ }
+ sb.append(")");
+ return sb.toString();
}
public boolean isOverride()
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/4ed67a8f/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ParameterReference.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ParameterReference.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ParameterReference.java
index 4823873..30d7c15 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ParameterReference.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ParameterReference.java
@@ -35,6 +35,12 @@ public class ParameterReference extends BaseReference
name = node.getString();
}
+ public ParameterReference(final ReferenceModel model, final String name, final String qualifiedName)
+ {
+ super(model, null, qualifiedName, null);
+ this.name = name;
+ }
+
public ParameterReference(final ReferenceModel model, final Node parameterNode)
{
this(model, parameterNode, "Object");
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/4ed67a8f/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java
index 473e42c..f384689 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java
@@ -154,7 +154,7 @@ public class FunctionUtils
return canImport;
}
- private static String toParameter(BaseReference reference, JSDocInfo comment, String paramName,
+ public static String toParameter(BaseReference reference, JSDocInfo comment, String paramName,
JSTypeExpression parameterType, boolean outputJS)
{
final StringBuilder sb = new StringBuilder();
[12/19] git commit: [flex-falcon]
[refs/heads/feature/maven-migration-test] - externs/node: can now build all
JS externs without error
Posted by cd...@apache.org.
externs/node: can now build all JS externs without error
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/a6887f8f
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/a6887f8f
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/a6887f8f
Branch: refs/heads/feature/maven-migration-test
Commit: a6887f8f6d7d1fb200761c3d4ef0fd5a11286573
Parents: 2a00175
Author: Josh Tynjala <jo...@apache.org>
Authored: Wed Apr 20 10:20:13 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Wed Apr 20 10:20:13 2016 -0700
----------------------------------------------------------------------
externs/node/compile-config.xml | 7 ++++++-
externs/node/missing.js | 5 -----
externs/node/node-compile-config.xml | 26 +++++++++++++++-----------
3 files changed, 21 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a6887f8f/externs/node/compile-config.xml
----------------------------------------------------------------------
diff --git a/externs/node/compile-config.xml b/externs/node/compile-config.xml
index 91df9e3..5b072dd 100644
--- a/externs/node/compile-config.xml
+++ b/externs/node/compile-config.xml
@@ -26,17 +26,22 @@
</external-library-path>
<source-path>
+ <path-element>out/as/constants</path-element>
+ <path-element>out/as/classes</path-element>
<path-element>out/as/functions</path-element>
+ <path-element>out/as/typedefs</path-element>
+ <path-element>out/as/duplicates</path-element>
</source-path>
<warn-no-constructor>false</warn-no-constructor>
</compiler>
<include-sources>
- <!--<path-element>out/as/constants</path-element>-->
+ <path-element>out/as/constants</path-element>
<path-element>out/as/classes</path-element>
<path-element>out/as/functions</path-element>
<path-element>out/as/typedefs</path-element>
+ <path-element>out/as/duplicates</path-element>
</include-sources>
<include-file>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a6887f8f/externs/node/missing.js
----------------------------------------------------------------------
diff --git a/externs/node/missing.js b/externs/node/missing.js
index ebacb75..d6c73f3 100644
--- a/externs/node/missing.js
+++ b/externs/node/missing.js
@@ -23,8 +23,3 @@
* @externs
*/
-/**
- * @param {string} id
- * @return {*}
- */
-function require(id) {};
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a6887f8f/externs/node/node-compile-config.xml
----------------------------------------------------------------------
diff --git a/externs/node/node-compile-config.xml b/externs/node/node-compile-config.xml
index aa97477..d836f6d 100644
--- a/externs/node/node-compile-config.xml
+++ b/externs/node/node-compile-config.xml
@@ -33,34 +33,38 @@
<external>
<path-element>missing.js</path-element>
<path-element>externs/assert.js</path-element>
- <!--<path-element>externs/buffer.js</path-element>-->
- <!--<path-element>externs/child_process.js</path-element>-->
- <!--<path-element>externs/cluster.js</path-element>-->
+ <path-element>externs/buffer.js</path-element>
+ <path-element>externs/child_process.js</path-element>
+ <path-element>externs/cluster.js</path-element>
<path-element>externs/crypto.js</path-element>
- <!--<path-element>externs/dgram.js</path-element>-->
+ <path-element>externs/dgram.js</path-element>
<path-element>externs/dns.js</path-element>
<path-element>externs/domain.js</path-element>
<path-element>externs/events.js</path-element>
<path-element>externs/fs.js</path-element>
- <!--<path-element>externs/globals.js</path-element>-->
- <!--<path-element>externs/http.js</path-element>-->
- <!--<path-element>externs/https.js</path-element>-->
+ <path-element>externs/globals.js</path-element>
+ <path-element>externs/http.js</path-element>
+ <path-element>externs/https.js</path-element>
<path-element>externs/net.js</path-element>
<path-element>externs/os.js</path-element>
<path-element>externs/path.js</path-element>
- <!--<path-element>externs/punycode.js</path-element>-->
- <!--<path-element>externs/querystring.js</path-element>-->
+ <path-element>externs/punycode.js</path-element>
+ <path-element>externs/querystring.js</path-element>
<path-element>externs/readline.js</path-element>
<path-element>externs/repl.js</path-element>
<path-element>externs/stream.js</path-element>
- <!--<path-element>externs/string_decoder.js</path-element>-->
+ <path-element>externs/string_decoder.js</path-element>
<path-element>externs/tls.js</path-element>
<path-element>externs/tty.js</path-element>
<path-element>externs/url.js</path-element>
<path-element>externs/util.js</path-element>
<path-element>externs/vm.js</path-element>
- <!--<path-element>externs/zlib.js</path-element>-->
+ <path-element>externs/zlib.js</path-element>
</external>
+ <exclude>
+ <class>Buffer</class>
+ <name>toJSON</name>
+ </exclude>
<as-root>out/as</as-root>
[19/19] git commit: [flex-falcon]
[refs/heads/feature/maven-migration-test] - - Renamed the "generate" goal to
"generate-extern" - Replicated the changes to the node extern to match the
develop branch - Fixed the replace commands in js to generate an ide
Posted by cd...@apache.org.
- Renamed the "generate" goal to "generate-extern"
- Replicated the changes to the node extern to match the develop branch
- Fixed the replace commands in js to generate an identical es3.js (Adjusted the build helper too)
- Merged upstream changes
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/dd503343
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/dd503343
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/dd503343
Branch: refs/heads/feature/maven-migration-test
Commit: dd5033438d69769a6e49e1f32cee6da66a9996a5
Parents: b42cb99 fb2dc7a
Author: Christofer Dutz <ch...@codecentric.de>
Authored: Thu Apr 21 13:35:19 2016 +0200
Committer: Christofer Dutz <ch...@codecentric.de>
Committed: Thu Apr 21 13:35:19 2016 +0200
----------------------------------------------------------------------
.gitignore | 1 +
.../patchfiles/ReplaceRegexpOperation.java | 3 +
.../compiler/clients/ExternCConfiguration.java | 7 ++
.../externals/emit/ReferenceEmitter.java | 20 +++
.../codegen/externals/pass/AddMemberPass.java | 43 ++++++-
.../externals/pass/CollectTypesPass.java | 10 ++
.../externals/reference/FieldReference.java | 9 +-
.../externals/reference/MethodReference.java | 33 ++++-
.../externals/reference/ParameterReference.java | 6 +
.../codegen/externals/utils/FunctionUtils.java | 40 ++++--
.../codegen/js/jx/BinaryOperatorEmitter.java | 7 +-
.../codegen/externals/ExternalsTestUtils.java | 26 ----
.../internal/caches/CSSDocumentCache.java | 11 +-
.../parsing/as/StreamingASTokenizer.java | 13 ++
compiler/src/test/java/as/ASKeywordTests.java | 21 ++++
externs/js/pom.xml | 3 +-
externs/js/src/main/config/externc-config.xml | 12 +-
externs/node/pom.xml | 26 ++++
.../node/src/main/config/compile-as-config.xml | 123 ++++++++++++++++++-
externs/node/src/main/config/externc-config.xml | 36 +++++-
externs/node/src/main/javascript/missing.js | 25 ++++
externs/node/src/main/javascript/node.js | 30 -----
.../apache/flex/maven/flexjs/ExterncMojo.java | 2 +-
.../resources/META-INF/plexus/components.xml | 2 +-
24 files changed, 422 insertions(+), 87 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dd503343/.gitignore
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dd503343/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/patchfiles/ReplaceRegexpOperation.java
----------------------------------------------------------------------
diff --cc compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/patchfiles/ReplaceRegexpOperation.java
index f295692,0000000..fbfcd2e
mode 100644,000000..100644
--- a/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/patchfiles/ReplaceRegexpOperation.java
+++ b/compiler-build-tools/src/main/java/org/apache/flex/compiler/tools/patchfiles/ReplaceRegexpOperation.java
@@@ -1,84 -1,0 +1,87 @@@
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flex.compiler.tools.patchfiles;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+/**
+ * Created by christoferdutz on 16.03.16.
+ */
+public class ReplaceRegexpOperation extends Operation {
+
+ private String match;
+ private String replace;
+ private String flags;
+
+ public ReplaceRegexpOperation() {
+ }
+
+ public String getMatch() {
+ return match;
+ }
+
+ public void setMatch(String match) {
+ this.match = match;
+ }
+
+ public String getReplace() {
+ return replace;
+ }
+
+ public void setReplace(String replace) {
+ this.replace = replace;
+ }
+
+ public String getFlags() {
+ return flags;
+ }
+
+ public void setFlags(String flags) {
+ this.flags = flags;
+ }
+
+ @Override
+ public void perform(File file) throws IOException {
+ String content = IOUtils.toString(new FileInputStream(file), "UTF-8");
+ // TODO: Add the "flags" support
+ String matchExpression = match;
+ if(matchExpression.contains("§{file.base}")) {
+ matchExpression = matchExpression.replaceAll("§\\{file.base\\}", FilenameUtils.getBaseName(file.getName()));
+ }
+ String replaceExpression = (replace == null) ? "" : replace;
+ if(replaceExpression.contains("§{file.base}")) {
+ replaceExpression = replaceExpression.replaceAll("§\\{file.base\\}", FilenameUtils.getBaseName(file.getName()));
+ }
+ if(replaceExpression.contains("_")) {
+ replaceExpression = replaceExpression.replaceAll("_", " ");
+ }
++ if(replaceExpression.contains("\\n")) {
++ replaceExpression = replaceExpression.replaceAll("\\\\n", "\n");
++ }
+
+ //content = Pattern.compile(matchExpression, Pattern.DOTALL).matcher(content).replaceAll(replaceExpression);
+ content = content.replaceAll(matchExpression, replaceExpression);
+ IOUtils.write(content, new FileOutputStream(file), "UTF-8");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dd503343/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ExternCConfiguration.java
----------------------------------------------------------------------
diff --cc compiler-jx/src/main/java/org/apache/flex/compiler/clients/ExternCConfiguration.java
index 7eea457,0000000..c15786a
mode 100644,000000..100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ExternCConfiguration.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ExternCConfiguration.java
@@@ -1,357 -1,0 +1,364 @@@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.clients;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.flex.compiler.config.Configuration;
+import org.apache.flex.compiler.config.ConfigurationValue;
+import org.apache.flex.compiler.exceptions.ConfigurationException.CannotOpen;
+import org.apache.flex.compiler.exceptions.ConfigurationException.IncorrectArgumentCount;
+import org.apache.flex.compiler.internal.codegen.externals.pass.ReferenceCompiler.ExternalFile;
+import org.apache.flex.compiler.internal.codegen.externals.reference.BaseReference;
+import org.apache.flex.compiler.internal.codegen.externals.reference.ClassReference;
+import org.apache.flex.compiler.internal.codegen.externals.reference.FieldReference;
+import org.apache.flex.compiler.internal.codegen.externals.reference.MemberReference;
+import org.apache.flex.compiler.internal.config.annotations.Arguments;
+import org.apache.flex.compiler.internal.config.annotations.Config;
+import org.apache.flex.compiler.internal.config.annotations.InfiniteArguments;
+import org.apache.flex.compiler.internal.config.annotations.Mapping;
+import org.apache.flex.utils.FilenameNormalization;
+
+public class ExternCConfiguration extends Configuration
+{
+ private File jsRoot;
+
+ private File asRoot;
+
+ private File asClassRoot;
+ private File asInterfaceRoot;
+ private File asFunctionRoot;
+ private File asConstantRoot;
+ private File asTypeDefRoot;
++ private File asDuplicatesRoot;
+
+ private List<ExternalFile> externals = new ArrayList<ExternalFile>();
+ private List<ExternalFile> externalExterns = new ArrayList<ExternalFile>();
+
+ private List<String> classToFunctions = new ArrayList<String>();
+ private List<ExcludedMember> excludesClass = new ArrayList<ExcludedMember>();
+ private List<ExcludedMember> excludesField = new ArrayList<ExcludedMember>();
+ private List<ExcludedMember> excludes = new ArrayList<ExcludedMember>();
+
+ public ExternCConfiguration()
+ {
+ }
+
+ public File getAsRoot()
+ {
+ return asRoot;
+ }
+
+ @Config
+ @Mapping("as-root")
+ public void setASRoot(ConfigurationValue cfgval, String filename) throws CannotOpen
+ {
+ setASRoot(new File(FilenameNormalization.normalize(getOutputPath(cfgval, filename))));
+ }
+
+ public void setASRoot(File file)
+ {
+ this.asRoot = file;
+
+ asClassRoot = new File(asRoot, "classes");
+ asInterfaceRoot = new File(asRoot, "interfaces");
+ asFunctionRoot = new File(asRoot, "functions");
+ asConstantRoot = new File(asRoot, "constants");
+ asTypeDefRoot = new File(asRoot, "typedefs");
++ asDuplicatesRoot = new File(asRoot, "duplicates");
+ }
+
+ public File getAsClassRoot()
+ {
+ return asClassRoot;
+ }
+
+ public File getAsInterfaceRoot()
+ {
+ return asInterfaceRoot;
+ }
+
+ public File getAsFunctionRoot()
+ {
+ return asFunctionRoot;
+ }
+
+ public File getAsConstantRoot()
+ {
+ return asConstantRoot;
+ }
+
+ public File getAsTypeDefRoot()
+ {
+ return asTypeDefRoot;
+ }
+
++ public File getAsDuplicatesRoot()
++ {
++ return asDuplicatesRoot;
++ }
++
+ public Collection<ExternalFile> getExternals()
+ {
+ return externals;
+ }
+
+ public Collection<ExternalFile> getExternalExterns()
+ {
+ return externalExterns;
+ }
+
+ public boolean isClassToFunctions(String className)
+ {
+ return classToFunctions.contains(className);
+ }
+
+ public void addClassToFunction(String className)
+ {
+ classToFunctions.add(className);
+ }
+
+ public void addExternal(File file) throws IOException
+ {
+ if (!file.exists())
+ throw new IOException(file.getAbsolutePath() + " does not exist.");
+ externals.add(new ExternalFile(file));
+ }
+
+ public void addExternal(String externalFile) throws IOException
+ {
+ addExternal(new File(FilenameNormalization.normalize(externalFile)));
+ }
+
+ public void addExternalExtern(File file) throws IOException
+ {
+ if (!file.exists())
+ throw new IOException(file.getAbsolutePath() + " does not exist.");
+ externalExterns.add(new ExternalFile(file));
+ }
+
+ public void addExternalExtern(String externalFile) throws IOException
+ {
+ addExternalExtern(new File(FilenameNormalization.normalize(externalFile)));
+ }
+
+ @Config(allowMultiple = true)
+ @Mapping("class-to-function")
+ @Arguments(Arguments.CLASS)
+ public void setClassToFunctions(ConfigurationValue cfgval, List<String> values) throws IncorrectArgumentCount
+ {
+ addClassToFunction(values.get(0));
+ }
+
+ @Config(allowMultiple = true, isPath = true)
+ @Mapping("external")
+ @Arguments(Arguments.PATH_ELEMENT)
+ @InfiniteArguments
+ public void setExternal(ConfigurationValue cfgval, String[] vals) throws IOException, CannotOpen
+ {
+ for (String val : vals)
+ addExternal(resolvePathStrict(val, cfgval));
+ }
+
+ @Config(allowMultiple = true, isPath = true)
+ @Mapping("external-externs")
+ @Arguments(Arguments.PATH_ELEMENT)
+ @InfiniteArguments
+ public void setExternalExterns(ConfigurationValue cfgval, String[] vals) throws IOException, CannotOpen
+ {
+ for (String val : vals)
+ addExternalExtern(resolvePathStrict(val, cfgval));
+ }
+
+ public boolean isExternalExtern(BaseReference reference)
+ {
+ String sourceFileName = reference.getNode().getSourceFileName();
+ for (ExternalFile file : externalExterns)
+ {
+ if (sourceFileName.equals("[" + file.getName() + "]"))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public ExcludedMember isExcludedClass(ClassReference classReference)
+ {
+ for (ExcludedMember memeber : excludesClass)
+ {
+ if (memeber.isExcluded(classReference, null))
+ return memeber;
+ }
+ return null;
+ }
+
+ public ExcludedMember isExcludedMember(ClassReference classReference,
+ MemberReference memberReference)
+ {
+ if (memberReference instanceof FieldReference)
+ {
+ for (ExcludedMember memeber : excludesField)
+ {
+ if (memeber.isExcluded(classReference, memberReference))
+ return memeber;
+ }
+ }
+ for (ExcludedMember memeber : excludes)
+ {
+ if (memeber.isExcluded(classReference, memberReference))
+ return memeber;
+ }
+ return null;
+ }
+
+ @Config(allowMultiple = true)
+ @Mapping("exclude")
+ @Arguments({"class", "name"})
+ public void setExcludes(ConfigurationValue cfgval, List<String> values) throws IncorrectArgumentCount
+ {
+ final int size = values.size();
+ if (size % 2 != 0)
+ throw new IncorrectArgumentCount(size + 1, size, cfgval.getVar(), cfgval.getSource(), cfgval.getLine());
+
+ for (int nameIndex = 0; nameIndex < size - 1; nameIndex += 2)
+ {
+ final String className = values.get(nameIndex);
+ final String name = values.get(nameIndex + 1);
+ addExclude(className, name);
+ }
+ }
+
+ public void addExclude(String className, String name)
+ {
+ excludes.add(new ExcludedMember(className, name));
+ }
+
+ public void addExclude(String className, String name, String description)
+ {
+ excludes.add(new ExcludedMember(className, name, description));
+ }
+
+ @Config(allowMultiple = true)
+ @Mapping("field-exclude")
+ @Arguments({"class", "field"})
+ public void setFieldExcludes(ConfigurationValue cfgval, List<String> values) throws IncorrectArgumentCount
+ {
+ final int size = values.size();
+ if (size % 2 != 0)
+ throw new IncorrectArgumentCount(size + 1, size, cfgval.getVar(), cfgval.getSource(), cfgval.getLine());
+
+ for (int nameIndex = 0; nameIndex < size - 1; nameIndex += 2)
+ {
+ final String className = values.get(nameIndex);
+ final String fieldName = values.get(nameIndex + 1);
+ addFieldExclude(className, fieldName);
+ }
+ }
+
+ public void addFieldExclude(String className, String fieldName)
+ {
+ excludesField.add(new ExcludedMember(className, fieldName, ""));
+ }
+
+ @Config(allowMultiple = true)
+ @Mapping("class-exclude")
+ @Arguments("class")
+ public void setClassExcludes(ConfigurationValue cfgval, List<String> values)
+ {
+ for (String className : values)
+ addClassExclude(className);
+ }
+ public void addClassExclude(String className)
+ {
+ excludesClass.add(new ExcludedMember(className, null, ""));
+ }
+
+ public File getJsRoot()
+ {
+ return jsRoot;
+ }
+
+ @Config
+ @Mapping("js-root")
+ public void setJSRoot(ConfigurationValue cfgval, String filename) throws CannotOpen
+ {
+ this.jsRoot = new File(filename);
+ }
+
+
+ public static class ExcludedMember
+ {
+ private String className;
+ private String name;
+ private String description;
+
+ public String getClassName()
+ {
+ return className;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public ExcludedMember(String className, String name)
+ {
+ this.className = className;
+ this.name = name;
+ }
+
+ public ExcludedMember(String className, String name, String description)
+ {
+ this.className = className;
+ this.name = name;
+ this.description = description;
+ }
+
+ public boolean isExcluded(ClassReference classReference,
+ MemberReference memberReference)
+ {
+ if (memberReference == null)
+ {
+ return classReference.getQualifiedName().equals(className);
+ }
+ return classReference.getQualifiedName().equals(className)
+ && memberReference.getQualifiedName().equals(name);
+ }
+
+ public void print(StringBuilder sb)
+ {
+ if (description != null)
+ sb.append("// " + description + "\n");
+ sb.append("//");
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dd503343/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/emit/ReferenceEmitter.java
----------------------------------------------------------------------
diff --cc compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/emit/ReferenceEmitter.java
index 957d352,0000000..c7d3c45
mode 100644,000000..100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/emit/ReferenceEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/emit/ReferenceEmitter.java
@@@ -1,166 -1,0 +1,186 @@@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.externals.emit;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.flex.compiler.internal.codegen.externals.reference.BaseReference;
+import org.apache.flex.compiler.internal.codegen.externals.reference.ClassReference;
+import org.apache.flex.compiler.internal.codegen.externals.reference.ConstantReference;
+import org.apache.flex.compiler.internal.codegen.externals.reference.FunctionReference;
+import org.apache.flex.compiler.internal.codegen.externals.reference.ReferenceModel;
+
+public class ReferenceEmitter
+{
+ private ReferenceModel model;
+
+ public ReferenceEmitter(ReferenceModel model)
+ {
+ this.model = model;
+ }
+
+ public void emit() throws IOException
+ {
+ final File asRoot = model.getConfiguration().getAsRoot();
+ if (!asRoot.exists())
+ asRoot.mkdirs();
+
+ emitClasses();
+ emitInterfaces();
+ emitTypedefs();
+ emitFunctions();
+ emitConstants();
+ }
+
+ protected void emitInterfaces() throws IOException
+ {
+ final StringBuilder sb = new StringBuilder();
+ for (ClassReference reference : model.getClasses())
+ {
+ if (model.isExcludedClass(reference) != null)
+ continue;
+
+ if (!reference.isInterface())
+ continue;
+
+ if (model.getConfiguration().isExternalExtern(reference))
+ continue;
+
+ emit(reference, sb);
+
+ File sourceFile = reference.getFile(model.getConfiguration().getAsInterfaceRoot());
++ if(sourceFile.exists())
++ {
++ sourceFile = reference.getFile(model.getConfiguration().getAsDuplicatesRoot());
++ }
+ FileUtils.write(sourceFile, sb.toString());
+
+ sb.setLength(0);
+ }
+ }
+
+ protected void emitClasses() throws IOException
+ {
+ final StringBuilder sb = new StringBuilder();
+ for (ClassReference reference : model.getClasses())
+ {
+ if (model.isExcludedClass(reference) != null)
+ continue;
+
+ if (reference.isInterface())
+ continue;
+
+ if (model.getConfiguration().isExternalExtern(reference))
+ continue;
+
+ emit(reference, sb);
+
+ File sourceFile = reference.getFile(model.getConfiguration().getAsClassRoot());
++ if(sourceFile.exists())
++ {
++ sourceFile = reference.getFile(model.getConfiguration().getAsDuplicatesRoot());
++ }
+ FileUtils.write(sourceFile, sb.toString());
+
+ sb.setLength(0);
+ }
+ }
+
+ protected void emitTypedefs() throws IOException
+ {
+ final StringBuilder sb = new StringBuilder();
+ // TODO figure out how to resolve/emit @typedef
+ for (ClassReference reference : model.getTypedefs())
+ {
+ if (model.isExcludedClass(reference) != null)
+ continue;
+
+ if (model.getConfiguration().isExternalExtern(reference))
+ continue;
+
+ emit(reference, sb);
+
+ File sourceFile = reference.getFile(model.getConfiguration().getAsTypeDefRoot());
++ if(sourceFile.exists())
++ {
++ sourceFile = reference.getFile(model.getConfiguration().getAsDuplicatesRoot());
++ }
+ FileUtils.write(sourceFile, sb.toString());
+
+ sb.setLength(0);
+ }
+ }
+
+ protected void emitFunctions() throws IOException
+ {
+ final StringBuilder sb = new StringBuilder();
+ for (FunctionReference reference : model.getFunctions())
+ {
+ if (model.getConfiguration().isExternalExtern(reference))
+ continue;
+
+ emit(reference, sb);
+
+ File sourceFile = reference.getFile(model.getConfiguration().getAsFunctionRoot());
++ if(sourceFile.exists())
++ {
++ sourceFile = reference.getFile(model.getConfiguration().getAsDuplicatesRoot());
++ }
+ FileUtils.write(sourceFile, sb.toString());
+
+ sb.setLength(0);
+ }
+ }
+
+ protected void emitConstants() throws IOException
+ {
+ final StringBuilder sb = new StringBuilder();
+ for (ConstantReference reference : model.getConstants())
+ {
+ if (model.getConfiguration().isExternalExtern(reference))
+ continue;
+
+ emit(reference, sb);
+
+ File sourceFile = reference.getFile(model.getConfiguration().getAsConstantRoot());
++ if(sourceFile.exists())
++ {
++ sourceFile = reference.getFile(model.getConfiguration().getAsDuplicatesRoot());
++ }
+ FileUtils.write(sourceFile, sb.toString());
+
+ sb.setLength(0);
+ }
+ }
+
+ public void emit(BaseReference reference, StringBuilder sb)
+ {
+ reference.emit(sb);
+ }
+
+ public String emit(BaseReference reference)
+ {
+ final StringBuilder sb = new StringBuilder();
+ reference.emit(sb);
+ return sb.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dd503343/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/pass/AddMemberPass.java
----------------------------------------------------------------------
diff --cc compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/pass/AddMemberPass.java
index 8379af9,0000000..9308ff0
mode 100644,000000..100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/pass/AddMemberPass.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/pass/AddMemberPass.java
@@@ -1,150 -1,0 +1,191 @@@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.externals.pass;
+
+import org.apache.flex.compiler.internal.codegen.externals.reference.ReferenceModel;
+
+import com.google.javascript.jscomp.AbstractCompiler;
+import com.google.javascript.jscomp.NodeTraversal;
++import com.google.javascript.rhino.JSDocInfo;
+import com.google.javascript.rhino.Node;
+
+public class AddMemberPass extends AbstractCompilerPass
+{
+
+ public AddMemberPass(ReferenceModel model, AbstractCompiler compiler)
+ {
+ super(model, compiler);
+ }
+
+ @Override
+ public boolean shouldTraverse(NodeTraversal nodeTraversal, Node n,
+ Node parent)
+ {
+ return n.isBlock() || n.isScript();
+ }
+
+ @Override
+ public void visit(NodeTraversal t, Node n, Node parent)
+ {
+ for (Node child : n.children())
+ {
+ //log(child);
+
+ if (child.isExprResult())
+ {
+ Node first = child.getFirstChild();
+
+ if (first.isVar())
+ {
+ // visitVar(t, n);
+ }
+ else if (first.isFunction())
+ {
+ // visitFunction(t, n);
+ }
+ else if (first.isAssign())
+ {
+ if (first.getFirstChild().isGetProp()
+ && first.getLastChild().isFunction())
+ {
+ // instance or static method
+ visitMethod(t, first);
+ }
+ else
+ {
+ // DOMException.INDEX_SIZE_ERR = 1;
+ // The first child of the assign is the GetProp node,
+ // if later you need the value, either change this or check
+ // for a parent assign node when creating the FieldReference
+ // which the value would be n.getLastChild()
+ // XXX visitStaticField(t, n);
+ //System.err.println(n.toStringTree());
+ }
+ }
+ else if (first.isGetProp())
+ {
- visitGetProp(t, first);
++ JSDocInfo jsDocInfo = first.getJSDocInfo();
++ if (jsDocInfo != null
++ && (jsDocInfo.getParameterCount() > 0
++ || jsDocInfo.getReturnType() != null))
++ {
++ // instance or static method that isn't declared as a
++ // function, but has @param or @returns
++ visitMethodFromJSDoc(t, first);
++ }
++ else
++ {
++ visitGetProp(t, first);
++ }
+ }
+ }
+ }
+ }
+
+ // n == ASSIGN
+ private void visitMethod(NodeTraversal t, Node n)
+ {
+ String qName = n.getFirstChild().getQualifiedName();
+
+ if (n.getFirstChild().isGetProp())
+ {
+ int protoType = qName.indexOf(".prototype.");
+ if (protoType != -1)
+ {
+ String className = qName.substring(0, protoType);
+ String memberName = qName.substring(protoType + 11,
+ qName.length());
+ //log("Prototype:: className [" + className
+ // + "] memberName [" + memberName + "]");
+ model.addMethod(n, className, memberName);
+ }
+ else
+ {
+ String className = qName.substring(0, qName.lastIndexOf("."));
+ String memberName = qName.substring(qName.lastIndexOf(".") + 1,
+ qName.length());
+ //log("className [" + className + "] memberName ["
+ // + memberName + "]");
+ model.addStaticMethod(n, className, memberName);
+ }
+ }
+ else if (n.getFirstChild().isName())
+ {
+ err("visitMethod() non impl");
+ log(n);
+ }
+ }
++ private void visitMethodFromJSDoc(NodeTraversal t, Node n)
++ {
++ String qName = n.getQualifiedName();
++
++ if (n.isGetProp())
++ {
++ int protoType = qName.indexOf(".prototype.");
++ if (protoType != -1)
++ {
++ String className = qName.substring(0, protoType);
++ String memberName = qName.substring(protoType + 11,
++ qName.length());
++ model.addMethod(n, className, memberName);
++ }
++ else
++ {
++ String className = qName.substring(0, qName.lastIndexOf("."));
++ String memberName = qName.substring(qName.lastIndexOf(".") + 1,
++ qName.length());
++ model.addStaticMethod(n, className, memberName);
++ }
++ }
++ else if (n.isName())
++ {
++ err("visitMethod() non impl");
++ log(n);
++ }
++ }
+
+ private void visitGetProp(NodeTraversal t, Node n)
+ {
+ String qualifiedName = n.getQualifiedName();
+
+ log("visitGetProp [" + qualifiedName + "]");
+
+ int protoType = qualifiedName.indexOf(".prototype.");
+ if (protoType != -1)
+ {
+ String className = qualifiedName.substring(0, protoType);
+ String memberName = qualifiedName.substring(protoType + 11,
+ qualifiedName.length());
+ //log("Prototype:: className [" + className
+ // + "] memberName [" + memberName + "]");
+ model.addField(n, className, memberName);
+ }
+ else
+ {
+ String className = qualifiedName.substring(0,
+ qualifiedName.lastIndexOf("."));
+ String memberName = qualifiedName.substring(
+ qualifiedName.lastIndexOf(".") + 1, qualifiedName.length());
+ //log("className [" + className + "] memberName ["
+ // + memberName + "]");
+ model.addStaticField(n, className, memberName);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dd503343/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/pass/CollectTypesPass.java
----------------------------------------------------------------------
diff --cc compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/pass/CollectTypesPass.java
index 8ddde76,0000000..44a9cc4
mode 100644,000000..100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/pass/CollectTypesPass.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/pass/CollectTypesPass.java
@@@ -1,165 -1,0 +1,175 @@@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.externals.pass;
+
+import org.apache.flex.compiler.internal.codegen.externals.reference.ReferenceModel;
+
+import com.google.javascript.jscomp.AbstractCompiler;
+import com.google.javascript.jscomp.NodeTraversal;
+import com.google.javascript.rhino.JSDocInfo;
+import com.google.javascript.rhino.Node;
+
+public class CollectTypesPass extends AbstractCompilerPass
+{
+ public CollectTypesPass(ReferenceModel model, AbstractCompiler compiler)
+ {
+ super(model, compiler);
+ }
+
+ @Override
+ public boolean shouldTraverse(NodeTraversal nodeTraversal, Node n,
+ Node parent)
+ {
+ return n.isBlock() || n.isScript();
+ }
+
+ @Override
+ public void visit(NodeTraversal t, Node n, Node parent)
+ {
+ for (Node child : n.children())
+ {
+ if (child.isVar())
+ {
+ visitVar(child);
+ }
+ else if (child.isFunction())
+ {
+ visitFunction(child);
+ }
+ else if (child.isExprResult())
+ {
+ visitExprResult(child);
+ }
+ }
+ }
+
+ private void visitExprResult(Node child)
+ {
+ JSDocInfo comment = null;
+
+ Node container = child.getFirstChild();
+ if (container.isAssign())
+ {
+ comment = container.getJSDocInfo();
+
+ Node left = container.getFirstChild();
+ Node right = container.getLastChild();
+
+ if (left.isName() && right.isFunction())
+ {
+ if (comment.isConstructor() || comment.isInterface())
+ {
+ // Foo = function () {};
+ model.addClass(container, left.getString());
+ }
+
+ }
+ else if (left.isGetProp() && right.isFunction())
+ {
+ boolean isConstructor = comment != null
+ && (comment.isConstructor() || comment.isInterface());
+ // foo.bar.Baz = function () {};
+ if (isConstructor)
+ {
+ model.addClass(container, left.getQualifiedName());
+ }
+ }
+ }
++ else
++ {
++ comment = container.getJSDocInfo();
++ boolean isConstructor = comment != null
++ && (comment.getTypedefType() != null);
++ if (isConstructor)
++ {
++ model.addTypeDef(container, container.getQualifiedName());
++ }
++ }
+ }
+
+ private void visitFunction(Node child)
+ {
+ JSDocInfo comment = child.getJSDocInfo();
+
+ boolean isConstructor = comment != null
+ && (comment.isConstructor() || comment.isInterface());
+
+ if (isConstructor)
+ {
+ // function Goo () {};
+ model.addClass(child, child.getFirstChild().getString());
+ }
+ else
+ {
+ model.addFunction(child, child.getFirstChild().getString());
+ }
+ }
+
+ private void visitVar(Node child)
+ {
+ JSDocInfo comment = child.getJSDocInfo();
+
+ Node first = child.getFirstChild();
+ if (first.isName())
+ {
+ Node subFirst = first.getFirstChild();
+ if (subFirst != null && subFirst.isObjectLit())
+ {
+ if (comment.hasEnumParameterType())
+ {
+
+ }
+ else
+ {
+ //System.out.println(first.getFirstChild().toStringTree());
+ //log("Encountered namespace [" + first.getQualifiedName() + "]");
+ model.addNamespace(child, first.getQualifiedName());
+ }
+ }
+ else if (subFirst != null && subFirst.isFunction())
+ {
+ boolean isConstructor = comment != null
+ && (comment.isConstructor() || comment.isInterface());
+ // foo.bar.Baz = function () {};
+ if (isConstructor)
+ {
+ model.addClass(child, first.getString());
+ }
+ }
+ else
+ {
+ boolean isConstructor = comment != null
+ && (comment.getTypedefType() != null);
+ // * @typedef
+ // var foo;
+ if (isConstructor)
+ {
+ // model.addClass(child, first.getString());
+ model.addTypeDef(child, first.getString());
+ }
+ else if (comment != null && comment.isConstant())
+ {
+ //System.out.println(child.toStringTree());
+ model.addConstant(child, first.getString());
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dd503343/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java
----------------------------------------------------------------------
diff --cc compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java
index d99a66d,0000000..e01a72a
mode 100644,000000..100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/FieldReference.java
@@@ -1,264 -1,0 +1,271 @@@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.externals.reference;
+
+import org.apache.flex.compiler.clients.ExternCConfiguration.ExcludedMember;
++import org.apache.flex.compiler.internal.codegen.externals.utils.FunctionUtils;
+import org.apache.flex.compiler.internal.codegen.externals.utils.JSTypeUtils;
+
+import com.google.javascript.rhino.JSDocInfo;
+import com.google.javascript.rhino.JSTypeExpression;
+import com.google.javascript.rhino.Node;
+import com.google.javascript.rhino.jstype.JSType;
+
+public class FieldReference extends MemberReference
+{
+
+ private boolean isStatic;
+ private boolean isConst;
+ private String overrideStringType;
+ private Node constantValueNode;
+
+ public boolean isStatic()
+ {
+ return isStatic;
+ }
+
+ public void setStatic(boolean isStatic)
+ {
+ this.isStatic = isStatic;
+ }
+
+ public boolean isConst()
+ {
+ return isConst;
+ }
+
+ public void setConst(boolean isConst)
+ {
+ this.isConst = isConst;
+ }
+
+ public void setOverrideStringType(String overrideStringType)
+ {
+ this.overrideStringType = overrideStringType;
+ }
+
+ public void setConstantValueNode(Node constantValueNode)
+ {
+ this.constantValueNode = constantValueNode;
+ }
+
+ public String toTypeAnnotationString()
+ {
+ JSType jsType = null;
+ if (getComment() != null && getComment().getType() != null)
+ {
+ jsType = getModel().evaluate(getComment().getType());
+ }
+ return jsType != null ? jsType.toAnnotationString() : "Object";
+ }
+
+ public FieldReference(ReferenceModel model, ClassReference classReference, Node node, String name,
+ JSDocInfo comment, boolean isStatic)
+ {
+ super(model, classReference, node, name, comment);
+ this.isStatic = isStatic;
+ }
+
+ @Override
+ public void emit(StringBuilder sb)
+ {
+ // XXX HACK TEMP!
+ if (getComment().isConstructor())
+ return;
+
+ // Window has a global var Window that conflicts with the constructor.
+ if (getQualifiedName().equals(getClassReference().getQualifiedName()))
+ return;
+
+ if (getClassReference().hasSuperField(getQualifiedName()))
+ return;
+
+ emitComment(sb);
+
+ ExcludedMember excluded = isExcluded();
+ if (excluded != null)
+ {
+ excluded.print(sb);
+ return; // XXX (mschmalle) accessors are not treated right, need to exclude get/set
+ }
+
+ if (!getClassReference().isInterface() && !getComment().isOverride()
+ && !getClassReference().isPropertyInterfaceImplementation(getBaseName()))
+ {
+ emitVar(sb);
+ }
+ else
+ {
+ emitAccessor(sb);
+ }
+ }
+
+ private void emitAccessor(StringBuilder sb)
+ {
+ boolean isInterface = getClassReference().isInterface();
+
+ String staticValue = (isStatic) ? "static " : "";
+ String isPublic = isInterface ? "" : "public ";
+ String getBody = isInterface ? "" : "{ return null; }";
+ String setBody = isInterface ? "" : "{}";
+
+ String type = toTypeString();
+ if (type.contains("|") || type.contains("?"))
+ type = "*";
+
+ if (outputJS)
+ {
+ sb.append(getClassReference().getPackageName());
+ sb.append(".");
+ sb.append(getClassReference().getBaseName());
+ sb.append(".");
+ if (!isStatic)
+ sb.append("prototype.");
+ sb.append(getBaseName());
+ sb.append(";\n");
+ return;
+ }
+ // getter
+ sb.append(indent);
+ sb.append(isPublic);
+ sb.append(staticValue);
+ sb.append("function get ");
+ sb.append(getBaseName());
+ sb.append("():");
+ sb.append(type);
+ sb.append(getBody);
+ sb.append(";\n");
+
+ // setter
+ sb.append(indent);
+ sb.append(isPublic);
+ sb.append(staticValue);
+ sb.append("function set ");
+ sb.append(getBaseName());
+ sb.append("(value:");
+ sb.append(type);
+ sb.append("):void");
+ sb.append(setBody);
+ sb.append(";\n");
+ }
+
+ private void emitVar(StringBuilder sb)
+ {
+ String staticValue = (isStatic) ? "static " : "";
+ String constVarValue = (isConst) ? "const " : "var ";
+
+ String type = toTypeString();
+ if (type.contains("|") || type.contains("?"))
+ type = "*";
+
+ if (outputJS)
+ {
+ sb.append(getClassReference().getPackageName());
+ sb.append(".");
+ sb.append(getClassReference().getBaseName());
+ sb.append(".");
+ if (!isStatic)
+ sb.append("prototype.");
+ sb.append(getBaseName());
+ sb.append(";\n");
+ return;
+ }
+
+ sb.append(indent);
+ sb.append("public ");
+ sb.append(staticValue);
+ sb.append(constVarValue);
+ sb.append(getQualifiedName());
+ sb.append(":");
+ sb.append(type);
+ if (isConst)
+ {
+ emitConstValue(sb);
+ }
+ sb.append(";\n");
+ }
+
+ private void emitConstValue(StringBuilder sb)
+ {
+ sb.append(" = ");
+ sb.append(toConstValue(constantValueNode));
+ }
+
+ private String toConstValue(Node node)
+ {
+ if (toTypeString().equals("Number"))
+ return Integer.toString(getClassReference().getEnumConstant());
+ if (node.isString())
+ return "'" + node.getString() + "'";
+ return "undefined /* TODO type not set */";
+ }
+
+ public String toTypeString()
+ {
+ if (overrideStringType != null)
+ return overrideStringType;
- return JSTypeUtils.toFieldTypeString(this);
++ String typeString = JSTypeUtils.toFieldTypeString(this);
++ if (FunctionUtils.hasTemplate(this)
++ && FunctionUtils.containsTemplate(this, typeString))
++ {
++ return "Object";
++ }
++ return typeString;
+ }
+
+ @Override
+ protected void emitCommentBody(StringBuilder sb)
+ {
+ emitBlockDescription(sb);
+ emitType(sb);
+ emitSee(sb);
+ emitSeeSourceFileName(sb);
+ }
+
+ private void emitType(StringBuilder sb)
+ {
+ JSTypeExpression type = getComment().getType();
+ if (type != null)
+ {
+ if (outputJS)
+ {
+ sb.append(indent);
+ sb.append(" * @type ");
+ sb.append("{");
+ sb.append(mapBackToJS(getModel().evaluate(type).toAnnotationString()));
+ sb.append("} ");
+ sb.append("\n");
+ }
+ else
+ {
+ sb.append(indent);
+ sb.append(" * @see JSType - ");
+ sb.append("[");
+ sb.append(getModel().evaluate(type).toAnnotationString());
+ sb.append("] ");
+ String description = getComment().getReturnDescription();
+ if (description != null)
+ sb.append(description);
+ sb.append("\n");
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dd503343/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java
----------------------------------------------------------------------
diff --cc compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java
index 96aa9f2,0000000..6cfbadf
mode 100644,000000..100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/MethodReference.java
@@@ -1,316 -1,0 +1,347 @@@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.externals.reference;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.flex.compiler.clients.ExternCConfiguration.ExcludedMember;
+import org.apache.flex.compiler.internal.codegen.externals.utils.FunctionUtils;
+
+import com.google.common.collect.Lists;
+import com.google.javascript.rhino.JSDocInfo;
++import com.google.javascript.rhino.JSTypeExpression;
+import com.google.javascript.rhino.Node;
+import com.google.javascript.rhino.jstype.JSType;
+
+public class MethodReference extends MemberReference
+{
+
+ private boolean isStatic;
+ private MethodReference override;
+ private Node paramNode;
+
+ private List<ParameterReference> parameters;
+
+ private MethodReference getContext()
+ {
+ return override == null ? this : override;
+ }
+
+ public boolean isStatic()
+ {
+ return isStatic;
+ }
+
+ public void setStatic(boolean isStatic)
+ {
+ this.isStatic = isStatic;
+ }
+
+ public List<ParameterReference> getParameters()
+ {
+ return parameters;
+ }
+
+ public Set<String> getParameterNames()
+ {
+ return getComment().getParameterNames();
+ }
+
+ public String toReturnTypeAnnotationString()
+ {
+ JSType jsType = getModel().evaluate(getComment().getReturnType());
+ return jsType.toAnnotationString();
+ }
+
+ public MethodReference(ReferenceModel model, ClassReference classReference, Node node, String name,
+ JSDocInfo comment, boolean isStatic)
+ {
+ super(model, classReference, node, name, comment);
+ this.isStatic = isStatic;
+
+ if (node.isFunction())
+ {
+ this.paramNode = node.getChildAtIndex(1);
+ }
+ else if (node.getLastChild().isFunction())
+ {
+ this.paramNode = node.getLastChild().getChildAtIndex(1);
+ }
+
+ addParameterReferences();
+ }
+
+ private void addParameterReferences()
+ {
+
+ parameters = new ArrayList<ParameterReference>();
+
+ if (paramNode != null)
+ {
+
+ final boolean isDocumented = comment.getParameterCount() > 0;
+ List<String> parameterNames = null;
+
+ if (isDocumented)
+ {
+ parameterNames = Lists.newArrayList(comment.getParameterNames());
+ }
+
+ for (Node param : paramNode.children())
+ {
+ ParameterReference parameterReference;
+
+ if (isDocumented && parameterNames.contains(param.getString()))
+ {
+ final String qualifiedName = FunctionUtils.toParameterType(this, param.getString());
+ parameterReference = new ParameterReference(getModel(), param, qualifiedName);
+ }
+ else
+ {
+ parameterReference = new ParameterReference(getModel(), param);
+ }
+
+ parameters.add(parameterReference);
+ }
+ }
++ else if(comment.getParameterCount() > 0 || comment.getReturnType() != null)
++ {
++ for (int i = 0; i < comment.getParameterCount(); i++)
++ {
++ String parameterName = comment.getParameterNameAt(i);
++ String qualifiedName = FunctionUtils.toParameterType(this, parameterName);
++ ParameterReference parameterReference = new ParameterReference(getModel(), parameterName, qualifiedName);
++ parameters.add(parameterReference);
++ }
++ }
++ else
++ {
++ System.out.println(getQualifiedName() + " parameters not found! " + " " + comment.getParameterCount());
++ }
+ }
+
+ @Override
+ public void emit(StringBuilder sb)
+ {
+ String className = getClassReference().getBaseName();
+
+ // XXX HACK TEMP!
+ if (getComment().isConstructor() && !getBaseName().equals(className))
+ return;
+
+ if (isConstructor())
+ {
+ emitConstructor(sb);
+ return;
+ }
+
+ String qName = getQualifiedName();
+ // skip overrides since they have to have the same signature as the super method
+ if (getClassReference().hasSuperMethod(qName))
+ return;
+
+ emitComment(sb);
+
+ ExcludedMember excluded = isExcluded();
+ if (excluded != null)
+ {
+ excluded.print(sb);
+ }
+
+ emitCode(sb);
+
+ override = null;
+ }
+
+ public void emitCode(StringBuilder sb)
+ {
+ String staticValue = (isStatic) ? "static " : "";
+ if (getClassReference().isInterface())
+ staticValue = "";
+
+ String isOverride = "";
+
+ if (!getClassReference().isInterface())
+ {
+ MethodReference overrideFromInterface = getClassReference().getMethodOverrideFromInterface(this);
+ if (/*isOverride() && */overrideFromInterface != null)
+ {
+ override = overrideFromInterface;
+ }
+ }
+
+ String qName = getQualifiedName();
+
+ String publicModifier = "";
+ String braces = "";
+ String returns = "";
+
+ String returnString = transformReturnString();
+ if (!returnString.equals("void"))
+ {
+ if (returnString.equals("Number"))
+ returns = "return 0;";
+ else
+ returns = " return null;";
+ }
+
+ if (!getClassReference().isInterface())
+ {
+ publicModifier = "public ";
+ braces = " { " + returns + " }";
+ }
+
+ if (getClassReference().hasSuperMethod(qName))
+ {
+ isOverride = "override ";
+ }
+
+ if (outputJS)
+ {
+ sb.append(getClassReference().getPackageName());
+ sb.append(".");
+ sb.append(getClassReference().getBaseName());
+ sb.append(".");
+ if (isStatic)
+ sb.append("prototype.");
+ sb.append(qName);
+ sb.append(" = function ");
+ sb.append(toParameterString());
+ sb.append(braces);
+ sb.append("\n");
+ return;
+ }
+
+ sb.append(indent);
+ sb.append(publicModifier);
+ sb.append(isOverride);
+ sb.append(staticValue);
+ sb.append("function ");
+ sb.append(getQualifiedName());
+ sb.append(toParameterString());
+ sb.append(":");
+ sb.append(transformReturnString());
+ sb.append(braces);
+ sb.append("\n");
+ }
+
+ private void emitConstructor(StringBuilder sb)
+ {
+ if (!outputJS)
+ emitComment(sb);
+
+ if (outputJS)
+ {
+ sb.append(getClassReference().getPackageName());
+ sb.append(".");
+ sb.append(getBaseName());
+ sb.append(" = function ");
+ sb.append(toParameterString());
+ sb.append(" {}\n");
+ return;
+ }
+
+ sb.append(indent);
+ sb.append("public function ");
+ sb.append(getBaseName());
+ if (!getBaseName().equals("Object"))
+ {
+ sb.append(toParameterString());
+ sb.append(" {\n");
+ sb.append(indent);
+ emitSuperCall(sb);
+ sb.append(indent);
+ sb.append("}");
+ }
+ else
+ {
+ sb.append("() {}");
+ }
+
+ sb.append("\n");
+ }
+
+ private void emitSuperCall(StringBuilder sb)
+ {
+
+ sb.append(indent);
+ sb.append("super(");
+
+ ClassReference superClass = getClassReference().getSuperClass();
+ if (superClass != null && !superClass.getBaseName().equals("Object"))
+ {
+ MethodReference constructor = superClass.getConstructor();
+ Set<String> parameterNames = constructor.getParameterNames();
+ int len = parameterNames.size();
+ for (int i = 0; i < len; i++)
+ {
+ sb.append("null");
+ if (i < len - 1)
+ sb.append(", ");
+ }
+ }
+
+ sb.append(");\n");
+ }
+
+ public boolean isConstructor()
+ {
+ return getComment().isConstructor();
+ }
+
+ public String transformReturnString()
+ {
+ return FunctionUtils.toReturnString(getContext());
+ }
+
+ private String toParameterString()
+ {
- return FunctionUtils.toParameterString(getContext(), getContext().getComment(), paramNode, outputJS);
++ if (paramNode != null)
++ {
++ return FunctionUtils.toParameterString(getContext(), getContext().getComment(), paramNode, outputJS);
++ }
++ StringBuilder sb = new StringBuilder();
++ sb.append("(");
++ int len = comment.getParameterCount();
++ for (int i = 0; i < len; i++)
++ {
++ String parameterName = comment.getParameterNameAt(i);
++ JSTypeExpression parameterType = comment.getParameterType(i);
++ sb.append(FunctionUtils.toParameter(getContext(), comment, parameterName, parameterType, outputJS));
++ if (i < len - 1)
++ sb.append(", ");
++ }
++ sb.append(")");
++ return sb.toString();
+ }
+
+ public boolean isOverride()
+ {
+ return getComment().isOverride();
+ }
+
+ @Override
+ protected void emitCommentBody(StringBuilder sb)
+ {
+ emitFunctionCommentBody(sb);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dd503343/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/ParameterReference.java
----------------------------------------------------------------------
diff --cc compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/ParameterReference.java
index 4823873,0000000..30d7c15
mode 100644,000000..100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/ParameterReference.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/ParameterReference.java
@@@ -1,53 -1,0 +1,59 @@@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.externals.reference;
+
+import com.google.javascript.rhino.Node;
+
+/**
+ * @author: Frederic Thomas Date: 05/07/2015 Time: 19:34
+ */
+public class ParameterReference extends BaseReference
+{
+
+ private String name;
+
+ public ParameterReference(final ReferenceModel model, final Node node, final String qualifiedName)
+ {
+ super(model, node, qualifiedName, null);
+ name = node.getString();
+ }
+
++ public ParameterReference(final ReferenceModel model, final String name, final String qualifiedName)
++ {
++ super(model, null, qualifiedName, null);
++ this.name = name;
++ }
++
+ public ParameterReference(final ReferenceModel model, final Node parameterNode)
+ {
+ this(model, parameterNode, "Object");
+ }
+
+ @Override
+ public void emit(final StringBuilder sb)
+ {
+ // Emitted by the Method / Function reference.
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dd503343/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java
----------------------------------------------------------------------
diff --cc compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java
index 473e42c,0000000..5a9b658
mode 100644,000000..100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/utils/FunctionUtils.java
@@@ -1,232 -1,0 +1,254 @@@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.codegen.externals.utils;
+
+import org.apache.flex.compiler.internal.codegen.externals.reference.BaseReference;
+import org.apache.flex.compiler.internal.codegen.externals.reference.ClassReference;
++import org.apache.flex.compiler.internal.codegen.externals.reference.MemberReference;
+import org.apache.flex.compiler.internal.codegen.externals.reference.ReferenceModel;
+
+import com.google.common.base.Strings;
+import com.google.javascript.rhino.JSDocInfo;
+import com.google.javascript.rhino.JSTypeExpression;
+import com.google.javascript.rhino.Node;
+
+public class FunctionUtils
+{
+ /**
+ * Compute the type of a function or method parameter.
+ *
+ * @param reference The FunctionReference or MethodReference the parameter belongs to
+ * @param name The name of the parameter
+ * @return the type of a function or method parameter
+ */
+ public static String toParameterType(final BaseReference reference, final String name)
+ {
+
+ String parameterType;
+ if (FunctionUtils.hasTemplate(reference) && FunctionUtils.containsTemplate(reference, name))
+ {
+ parameterType = "Object";
+ }
+ else
+ {
+ parameterType = JSTypeUtils.toParamTypeString(reference, name);
+ }
+
+ return parameterType;
+ }
+
+ public static String toReturnString(BaseReference reference)
+ {
+ final StringBuilder sb = new StringBuilder();
+
+ String returnType;
+
+ if (hasTemplate(reference))
+ {
+ returnType = JSTypeUtils.toReturnTypeString(reference);
+ if (containsTemplate(reference, returnType))
+ returnType = "*";
+ else if (returnType.equals("RESULT"))
+ returnType = "Object";
+ }
+ else
+ {
+ returnType = JSTypeUtils.toReturnTypeString(reference);
+ }
+
+ sb.append(returnType);
+
+ return sb.toString();
+ }
+
+ public static String toParameterString(BaseReference reference, JSDocInfo comment, Node paramNode, boolean outputJS)
+ {
+ final StringBuilder sb = new StringBuilder();
+
+ sb.append("(");
+
+ if (paramNode != null)
+ {
+ int index = 0;
+ int len = comment.getParameterCount();
+ if (len == 0)
+ {
+ // Missing JSDocInf @param tags, so instead of using the @param tags
+ // we use the actual Node list from the AST
+ len = paramNode.getChildCount();
+ if (len > 0)
+ {
+ for (Node param : paramNode.children())
+ {
+ sb.append(param.getString());
+ if (!outputJS)
+ sb.append(":Object");
+ if (index < len - 1)
+ sb.append(", ");
+ index++;
+ }
+ }
+ }
+ else
+ {
+ for (String paramName : comment.getParameterNames())
+ {
+ sb.append(toParameter(reference, comment, paramName, comment.getParameterType(paramName), outputJS));
+
+ if (index < len - 1)
+ sb.append(", ");
+
+ index++;
+ }
+ }
+ }
+
+ sb.append(")");
+
+ return sb.toString();
+ }
+
+ /**
+ * Check we can import the given type into the given package.
+ *
+ * @param model The containing reference model
+ * @param node The containing node
+ * @param typeName The type we want check
+ * @param packageName The current package
+ * @return true if we can import the given type into the given package
+ */
+ public static boolean canBeImported(final ReferenceModel model, final Node node, final String typeName,
+ final String packageName)
+ {
+ boolean canImport = false;
+
+ if (model != null && node != null && !Strings.isNullOrEmpty(typeName))
+ {
+ final ClassReference reference = new ClassReference(null, node, typeName);
+
+ final int lastDotPosition = typeName.lastIndexOf(".");
+
+ // Can import when the type to import does not belong to the current package.
+ canImport = lastDotPosition > -1 && !typeName.substring(0, lastDotPosition).equals(packageName);
+
+ // And is not excluded.
+ canImport &= model.isExcludedClass(reference) == null;
+ }
+
+ return canImport;
+ }
+
- private static String toParameter(BaseReference reference, JSDocInfo comment, String paramName,
++ public static String toParameter(BaseReference reference, JSDocInfo comment, String paramName,
+ JSTypeExpression parameterType, boolean outputJS)
+ {
+ final StringBuilder sb = new StringBuilder();
+
+ String paramType;
+
+ if (parameterType == null)
+ {
+ System.out.println("no parameter type for " + paramName + " " + reference.getQualifiedName());
+ paramType = "Object";
+ if (outputJS)
+ sb.append(paramName);
+ }
+ else if (parameterType.isVarArgs())
+ {
+ if (outputJS)
+ sb.append("var_").append(paramName);
+ else
+ sb.append("...").append(paramName);
+ }
+ else
+ {
+ paramType = JSTypeUtils.toParamTypeString(reference, paramName);
+ if (hasTemplate(reference) && containsTemplate(reference, paramType))
+ {
+ paramType = "Object";
+ }
+
+ sb.append(paramName);
+ if (!outputJS)
+ {
+ sb.append(":");
+ sb.append(paramType);
+ if (parameterType.isOptionalArg())
+ {
+ sb.append(" = ");
+ sb.append(toDefaultParameterValue(paramType));
+ }
+ }
+ }
+
+ return sb.toString();
+ }
+
+ private static String toDefaultParameterValue(String paramType)
+ {
+ if (paramType.equals("Function"))
+ return "null";
+ else if (paramType.equals("Number"))
+ return "0";
+ else if (paramType.equals("String"))
+ return "''";
+ else if (paramType.equals("Boolean"))
+ return "false";
+ return "null";
+ }
+
+ public static boolean hasTemplate(BaseReference reference)
+ {
++ if(reference instanceof MemberReference)
++ {
++ MemberReference memberRef = (MemberReference) reference;
++ if(memberRef.getClassReference().getComment().getTemplateTypeNames().size() > 0)
++ {
++ return true;
++ }
++ }
+ return reference.getComment().getTemplateTypeNames().size() > 0;
+ }
+
+ public static boolean containsTemplate(BaseReference reference, String name)
+ {
- for (String template : reference.getComment().getTemplateTypeNames())
- {
- if (name.contains("<" + template + ">"))
- return true;
- if (name.equals(template))
- return true;
- }
- return false;
++ if(reference instanceof MemberReference)
++ {
++ MemberReference memberRef = (MemberReference) reference;
++ if(commentContainsTemplate(memberRef.getClassReference().getComment(), name))
++ {
++ return true;
++ }
++ }
++ return commentContainsTemplate(reference.getComment(), name);
++ }
++
++ private static boolean commentContainsTemplate(JSDocInfo comment, String name)
++ {
++ for (String template : comment.getTemplateTypeNames())
++ {
++ if (name.contains("<" + template + ">"))
++ return true;
++ if (name.equals(template))
++ return true;
++ }
++ return false;
+ }
+
+}