Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renaming public functions, sometimes misses #7

Open
dubspeed opened this issue Jul 30, 2024 · 1 comment
Open

Renaming public functions, sometimes misses #7

dubspeed opened this issue Jul 30, 2024 · 1 comment

Comments

@dubspeed
Copy link

👋 Hello, when renaming public functions, some obvious occurrences are missed.

Example:

  • Clone Haxe Flixel
  • Open flixel/math/FlxMatrix.hx, find the function rotateByPositive90
  • Search for rotateByPositive90 in the project and observe that it is used in total of 4 times by FlxFrame.hx,
  • Rename the function via "Rename symbol": observe only two of four items are renamed.

Note:
this might require to add the "flixel" folder to "haxe.renameSourceFolder" in some settings.json.

More examples in the same codebase:

  • FlxFrame.hx : paint() (flixel/graphics/frames/FlxFrame.hx)
  • FlxRandom.hx : int() (flixel/math/FlxRandom.hx) -> this one is more sophisticated example. The function is refered to as "FlxG.random.int()" in the code, the error message is: unable to determine type of "random" in /Users/michael/inno/flixel/flixel/animation/FlxAnimation.hx@4207 - however the type is pretty clearly set.
@AlexHaxe
Copy link
Member

AlexHaxe commented Sep 22, 2024

  • Rename the function via "Rename symbol": observe only two of four items are renamed.

I tried to reproduce your sample with up-to-date flixel sources and when correctly set up with language server I get 5 rename places, one in FlxMatrix and all four in FlxFrame. if language server is not working properly, I only get 3.
the problem is that rename relies on language server type resolution to figure out if an identifier needs to be renamed or if it's just an identical name from an unrelated type. if language server is unavailable or doesn't answer, then rename lib has some limited ways of figuring out types on its own, but it can't compete with the type info that Haxe compiler has (or should have).

for larger projects language server is not always the fastest and people love to complain about it, yet it still is the only way to get reliable type info on all affected locations for any rename operation.

your FlxRandom.int sample e.g. takes a very long time to complete, mainly because it finds all instances of Std.int and resolves each and every one of them with Haxe compiler. in the end it comes up with a list that looks complete (I haven't really checked it).
I'm pretty sure there's some room for improvements and optimisations, e.g. resolving Std.int just once and caching the result for all places where Std doesn't reference a different thing.

for successful renames you want to make sure your "haxe.renameSourceFolder" is set up correctly, Haxe languageserver is up and running without throwing errors, your sources are saved prior to rename operation and you want to make sure that Hover requests are fast (use Haxe ServerView to watch your timings).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants