Skip to content

Commit

Permalink
fixed detection of type check in array comprehension (#136)
Browse files Browse the repository at this point in the history
* fixed detection of type check in array comprehension
  • Loading branch information
AlexHaxe authored Dec 17, 2018
1 parent 8d15a9a commit 1a1069b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## dev branch / next version (1.x.x)

- Fixed `TokenTreeCheckUtils.getColonType` detection of type check in array comprehension [#136](https://github.com/HaxeCheckstyle/tokentree/issues/136)

## version 1.0.14 (2018-12-05)

- Fixed properties in anon types [#130](https://github.com/HaxeCheckstyle/tokentree/issues/130)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
[![Build Status](https://travis-ci.org/HaxeCheckstyle/tokentree.svg)](https://travis-ci.org/HaxeCheckstyle/tokentree)
[![codecov](https://codecov.io/gh/HaxeCheckstyle/tokentree/branch/master/graph/badge.svg)](https://codecov.io/gh/HaxeCheckstyle/tokentree)

TokenTree library used by haxe-checkstyle. TokenTree is an alternative to AST.
TokenTree library used by haxe-checkstyle, haxe-formatter and haxe-languageserver is an alternative to AST.
2 changes: 1 addition & 1 deletion src/tokentree/utils/TokenTreeCheckUtils.hx
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ class TokenTreeCheckUtils {
case PARAMETER: return TYPE_HINT;
case CALL: return UNKNOWN;
case CONDITION: return UNKNOWN;
case FORLOOP: return UNKNOWN;
case FORLOOP: return TYPE_CHECK;
case EXPRESSION: return TYPE_CHECK;
}
default:
Expand Down
3 changes: 1 addition & 2 deletions test/TokenTestMain.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import byte.ByteData;
import sys.io.File;
// import sys.io.File;
import haxeparser.HaxeLexer;
import haxeparser.Data.Token;
import tokentree.TokenTree;
Expand All @@ -19,7 +19,6 @@ class TokenTestMain {

public static function main() {
// var code = File.getContent("../../haxe-languageserver/cases/foldingRange/Input.hx");

var code = TOKENTREE_BUILDER_TEST;
var tokens:Array<Token> = [];
var bytes:ByteData = ByteData.ofString(code);
Expand Down
9 changes: 8 additions & 1 deletion test/tokentree/utils/TokenTreeCheckUtilsTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class TokenTreeCheckUtilsTest {
public function testMixedColonTypes() {
var root:TokenTree = assertCodeParses(TokenTreeCheckUtilsTests.MIXED_COLON_TYPES);
var allBr:Array<TokenTree> = root.filter([DblDot], ALL);
Assert.areEqual(45, allBr.length);
Assert.areEqual(46, allBr.length);
var index:Int = 0;
Assert.areEqual(ColonType.OBJECT_LITERAL, TokenTreeCheckUtils.getColonType(allBr[index++]));
Assert.areEqual(ColonType.TYPE_CHECK, TokenTreeCheckUtils.getColonType(allBr[index++]));
Expand Down Expand Up @@ -190,6 +190,9 @@ class TokenTreeCheckUtilsTest {
Assert.areEqual(ColonType.TYPE_HINT, TokenTreeCheckUtils.getColonType(allBr[index++]));
Assert.areEqual(ColonType.TYPE_HINT, TokenTreeCheckUtils.getColonType(allBr[index++]));

// [for (i in 0...1) ("" : String).length];
Assert.areEqual(ColonType.TYPE_CHECK, TokenTreeCheckUtils.getColonType(allBr[index++]));

// typedef Middleware = {
Assert.areEqual(ColonType.TYPE_HINT, TokenTreeCheckUtils.getColonType(allBr[index++]));
Assert.areEqual(ColonType.TYPE_HINT, TokenTreeCheckUtils.getColonType(allBr[index++]));
Expand Down Expand Up @@ -429,6 +432,10 @@ abstract TokenTreeCheckUtilsTests(String) to String {
@:overload(function<T>(key:String, defaultValue:T):T {})
@:overload(function<T>(key:String):T {})
function get<T>(key:String):Null<T>;
function test() {
[for (i in 0...1) ('' : String).length];
}
}
typedef Middleware = {
Expand Down

0 comments on commit 1a1069b

Please sign in to comment.