You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2016/04/06 17:02:21 UTC
[12/50] git commit: [flex-falcon] [refs/heads/master] - compiler: the
for keyword is allowed after var, function, get, set, or a member expression,
like other keywords
compiler: the for keyword is allowed after var, function, get, set, or a member expression, like other keywords
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/b0670265
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/b0670265
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/b0670265
Branch: refs/heads/master
Commit: b0670265ae4652c8a71fff3926dcfbf0c1c2a589
Parents: 212af3e
Author: Josh Tynjala <jo...@apache.org>
Authored: Sun Feb 21 11:57:17 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Sun Feb 21 11:57:17 2016 -0700
----------------------------------------------------------------------
.../feature-tests/as/ASKeywordTests.java | 26 ++++++++++++++++++++
.../parsing/as/StreamingASTokenizer.java | 13 ++++++++++
2 files changed, 39 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b0670265/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 c1a5fb4..1602b3c 100644
--- a/compiler.tests/feature-tests/as/ASKeywordTests.java
+++ b/compiler.tests/feature-tests/as/ASKeywordTests.java
@@ -114,6 +114,32 @@ public class ASKeywordTests extends ASFeatureTestsBase
}
@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
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b0670265/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 f06f68e..61b6e26 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
@@ -978,6 +978,19 @@ public class StreamingASTokenizer implements ASTokenTypes, IASTokenizer, Closeab
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