Skip to content

Commit

Permalink
fixed array type parameter (#201)
Browse files Browse the repository at this point in the history
* fixed array type parameter
  • Loading branch information
AlexHaxe authored Nov 4, 2020
1 parent 6ad98e9 commit 9f630d5
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

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

## version 1.0.31 (2020-11-04)

- Fixed type parameter with array ([#201](https://github.com/HaxeCheckstyle/tokentree/issues/201))

## version 1.0.30 (2020-11-02)

- Fixed arrow functions ([#200](https://github.com/HaxeCheckstyle/tokentree/issues/200))
Expand Down
4 changes: 2 additions & 2 deletions haxelib.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"contributors": [
"AlexHaxe"
],
"releasenote": "fixed type parameter and dollar handling - see CHANGELOG for details",
"version": "1.0.30",
"releasenote": "fixed type parameter handling - see CHANGELOG for details",
"version": "1.0.31",
"url": "https://github.com/HaxeCheckstyle/tokentree",
"dependencies": {}
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tokentree",
"version": "1.0.30",
"version": "1.0.31",
"description": "TokenTree library used by haxe-checkstyle, haxe-formatter and haxe-languageserver",
"repository": {
"type": "git",
Expand Down
9 changes: 8 additions & 1 deletion src/tokentree/TokenStream.hx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class TokenStream {
}
var depth:Int = 1;
var brDepth:Int = 0;
var bkDepth:Int = 0;
var pDepth:Int = 0;
while (true) {
token = tokens[index++];
Expand All @@ -165,8 +166,14 @@ class TokenStream {
return false;
}
brDepth--;
case BkOpen:
bkDepth++;
case BkClose:
if (bkDepth <= 0) {
return false;
}
bkDepth--;
case Const(_):
// case Kwd(_):
case Dollar(_):
case Binop(OpLt):
depth++;
Expand Down
2 changes: 1 addition & 1 deletion src/tokentree/walk/WalkStatement.hx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class WalkStatement {
while (true) {
switch (ltParent.tok) {
case Root: break;
case Dot | DblDot | Comma | Arrow | POpen | Const(_) | Dollar(_) | Binop(OpGt): ltParent = ltParent.parent;
case Dot | DblDot | Comma | Arrow | POpen | Const(_) | Dollar(_) | BkOpen | BrOpen | Binop(OpGt): ltParent = ltParent.parent;
case Binop(OpLt): return;
default: break;
}
Expand Down
4 changes: 2 additions & 2 deletions test/tokentree/TestTokenTreeBuilder.hx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package tokentree;

import byte.ByteData;
import haxeparser.HaxeLexer;
import haxeparser.Data.Token;
import tokentree.walk.WalkFile;
import haxeparser.HaxeLexer;
import tokentree.TokenTreeBuilder.TokenTreeEntryPoint;
import tokentree.walk.WalkFile;

class TestTokenTreeBuilder extends TokenTreeBuilder {
public static function parseCode(code:String):TestTokenTreeBuilder {
Expand Down
4 changes: 4 additions & 0 deletions test/tokentree/TokenTreeBuilderParsingTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class TokenTreeBuilderParsingTest implements ITest {
assertCodeParses(CALLBACK_TYPE_PARAM);
assertCodeParses(MAP_INIT_WITH_COMMENT);
assertCodeParses(DOLLAR_CHAIN);
assertCodeParses(TYPE_PARAM_WITH_ARRAY);
}

public function assertCodeParses(code:String, ?pos:PosInfos) {
Expand Down Expand Up @@ -1668,4 +1669,7 @@ import #if haxe4 js.lib.Promise #else js.Promise #end as JsPromise;
});
}
}";

var TYPE_PARAM_WITH_ARRAY = "
private typedef Init = haxe.macro.MacroType<[cdb.Module.build('data.cdb')]>;";
}
7 changes: 6 additions & 1 deletion test/tokentree/utils/TokenTreeCheckUtilsTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ class TokenTreeCheckUtilsTest implements ITest {
default: GoDeeper;
}
});
Assert.equals(1, allBr.length);
Assert.equals(5, allBr.length);
var index:Int = 0;
// abstract SymbolStack(Array<{level:SymbolLevel, symbol:DocumentSymbol}>) {}
Assert.isTrue(TokenTreeCheckUtils.isTypeParameter(allBr[index++]));
Expand Down Expand Up @@ -925,6 +925,11 @@ abstract TokenTreeCheckUtilsTests(String) to String {

var MIXED_TYPE_PARAMETER = "
abstract SymbolStack(Array<{level:SymbolLevel, symbol:DocumentSymbol}>) {}
private typedef Init = haxe.macro.MacroType<[cdb.Module.build('data.cdb')]>;
abstract SymbolStack(haxe.macro.MacroType<[cdb.Module.build('data.cdb')]>) {}
function main(){
var obj:Null<{field:Null<String>}> = null;
}
";

var MIXED_OP_SUB = "
Expand Down

0 comments on commit 9f630d5

Please sign in to comment.