Skip to content

Commit

Permalink
fixed discovery of typed parameters
Browse files Browse the repository at this point in the history
fixed discovery of type checks
  • Loading branch information
AlexHaxe committed Dec 9, 2024
1 parent 2c0e1c2 commit 8de3607
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/refactor/discover/UsageCollector.hx
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,8 @@ class UsageCollector {
return null;
}
switch (nameToken.tok) {
case Const(CIdent("is")):
return null;
case Kwd(KwdNew) | Kwd(KwdThis) | Kwd(KwdNull) | Const(CIdent(_)):
default:
return null;
Expand All @@ -994,6 +996,8 @@ class UsageCollector {
}
for (child in parentPart.children) {
switch (child.tok) {
case Const(CIdent("is")):
return;
case Kwd(KwdNew) | Kwd(KwdThis) | Kwd(KwdNull) | Const(_):
pack.push(child.toString());
case Dot:
Expand Down Expand Up @@ -1108,8 +1112,12 @@ class UsageCollector {
makeIdentifier(context, child, TypedParameter, identifier);
case POpen:
readParameter(context, identifier, child, token.getPos().max);
case BrOpen:
readBlock(context, identifier, child);
case Binop(OpGt):
break;
case DblDot:
readTypeHint(context, identifier, child, TypeHint);
default:
}
}
Expand Down
3 changes: 3 additions & 0 deletions test/refactor/rename/RenameClassTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ class RenameClassTest extends RenameTestBase {
makeReplaceTestEdit("testcases/classes/pack/UseChild.hx", "ItemClass", 412, 422),
makeReplaceTestEdit("testcases/classes/pack/UseChild.hx", "ItemClass", 499, 509),
makeReplaceTestEdit("testcases/classes/pack/UseChild.hx", "ItemClass", 612, 622),
makeReplaceTestEdit("testcases/classes/pack/UseChild.hx", "ItemClass", 978, 988),
makeReplaceTestEdit("testcases/classes/pack/UseChild.hx", "ItemClass", 1039, 1049),
makeReplaceTestEdit("testcases/classes/pack/UseChild.hx", "ItemClass", 1081, 1091),
];
checkRename({fileName: "testcases/classes/ChildClass.hx", toName: "ItemClass", pos: 28}, edits, async);
}
Expand Down
10 changes: 10 additions & 0 deletions testcases/classes/pack/UseChild.hx
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,14 @@ class UseChild {
null;
}
}

function typeCheckChildClass(child:Any) {
if ((child is ChildClass)) {
trace("yes");
}
}
}

class TypedChild<T:ChildClass> {
var memebers:Array<{sprite:ChildClass, originalX:Float, originalY:Float}> = null;
}

0 comments on commit 8de3607

Please sign in to comment.