From 8de3607c938e632d296ace6b522a563857b46eb6 Mon Sep 17 00:00:00 2001 From: AlexHaxe Date: Tue, 10 Dec 2024 00:43:34 +0100 Subject: [PATCH] fixed discovery of typed parameters fixed discovery of type checks --- src/refactor/discover/UsageCollector.hx | 8 ++++++++ test/refactor/rename/RenameClassTest.hx | 3 +++ testcases/classes/pack/UseChild.hx | 10 ++++++++++ 3 files changed, 21 insertions(+) diff --git a/src/refactor/discover/UsageCollector.hx b/src/refactor/discover/UsageCollector.hx index d0559f7..b822970 100644 --- a/src/refactor/discover/UsageCollector.hx +++ b/src/refactor/discover/UsageCollector.hx @@ -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; @@ -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: @@ -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: } } diff --git a/test/refactor/rename/RenameClassTest.hx b/test/refactor/rename/RenameClassTest.hx index ff2bbe9..f209a6e 100644 --- a/test/refactor/rename/RenameClassTest.hx +++ b/test/refactor/rename/RenameClassTest.hx @@ -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); } diff --git a/testcases/classes/pack/UseChild.hx b/testcases/classes/pack/UseChild.hx index ff4ccc0..16e7551 100644 --- a/testcases/classes/pack/UseChild.hx +++ b/testcases/classes/pack/UseChild.hx @@ -53,4 +53,14 @@ class UseChild { null; } } + + function typeCheckChildClass(child:Any) { + if ((child is ChildClass)) { + trace("yes"); + } + } +} + +class TypedChild { + var memebers:Array<{sprite:ChildClass, originalX:Float, originalY:Float}> = null; }