Refactoring for vxcode

Hi,
just curious what is status for refactoring tool like move file / move field, rename e.c in vscode.
As I get this question quite often from people that try to use Haxe.

Is it just lack of implementation in vxcode plugin or there are something missing in Haxe compiler it self? :slight_smile:

This is usually first question when I try to introduce Haxe :smiley:

Thank you

1 Like

As most features in vshaxe are powered by the compiler’s display API, rename would have to be implemented that way as well, yes.

I agree that this is a very important feature, but I don’t think we have any concrete timeline for it.

2 Likes

Thank you @Gama11 for very quick answer :slight_smile:

Is it clear what should be done on Haxe / vxcode side and are there GitHub issues in place or nothing concrete yet ?

If tickets would be there more people could help on this.

Thank you for your great job on vxhaxe, it really feels good to work with already :slight_smile:

1 Like

We have Rename Symbol method · Issue #188 · vshaxe/vshaxe · GitHub, but no issue on the compiler side yet I think.

Why the extension is limited to only features that are supported by the compiler
 IMHO there are things that should be implement in the extension because it’s correct to insert them into the compiler
 WDYT?

Not every vshaxe feature uses the compiler. But for some features like completion or rename, you would actually end up having to essentially reimplement large parts of the compiler. And not only that, it’s really hard to maintain and keep up to date (see also: HaxeDevelop and the IntelliJ plugin, which tend to lag behind in terms of support for latest Haxe features).

There are two experimental features called “Extract type” and “Extract function” in Haxe languageserver, hidden behind -debug. Both work to some extend.

I think “Extract type” works in most cases - however it doesn’t update imports for any file outside the one you extract a type from. And extracted type’s file just copies all imports from original file, which is probably too much and requires a manual “Organize imports” to correct.

“Extract function” works in some cases, it can find some parameters and their type hints, but it’s far from perfect, e.g. if your code is inside a for or a switch expression it won’t add parameters for captured or loop variables. Also there is no UI to input a name for your extracted function, so it’s always called newFunction, requiring a manual rename. And it doesn’t look for other places with similar or identical snippets, so it will only operate on the bit of code you selected when activating “Extract function”.

I haven’t looked at both for some time, if you’re feeling adventurous you can compile languageserver with -debug and test them for yourself.

@Gama11 could this help you? :slight_smile: . If not, you mentioned @Simn as somebody that could help with this. Could I like
 um
 bribe you two guys with a luxurious dinner to get this working? Say, 100 Euro / head working on getting this done? :smiley: Seriously, I’m looking to move THREE MAJOR projects onto this technology and such a commitment and achievement would convince my “benefactors” (read “employers”) to invest in this :slight_smile:

1 Like

In other words, bribes don’t work :smiley:

Or maybe they prefer different way of bribe :slight_smile:

@Gama11 Hi, just curious if there are any changes on this side ? :slight_smile: is it still haxe compiler side that need to be implemented or its more on vshaxe ?

1 Like

Yeah, lack of renaming for most symbols (last I checked, we can only rename local variables) is probably the feature that I miss the most.

I wish I could offer more, but I’d be happy to send $100 to one of the compiler developers to help fund the work to add support for renaming any symbol (including classes, interfaces, member fields and methods, etc).

Ok, so that’s 100 from @joshtynjala , 100 from me. Who else pitches in?

Anyway, until we get decent refactoring support in VS Code, I am using BOTH VS Code AND
IntelliJ :smiley:

In IntelliJ, @ebishton 's excellent plugin gives me superb refactoring capabilities, while in VS Code I got full my live-reload setup + debugging of my JS target.

It sucks having to use 2 IDEs, but I do this for Haxe and for the ecosystem. I poured all my free time in the past almost 4 years into a massive Haxe project that will soon reach the light of day. I know that this project will help Haxe grow. And I sure hope other projects give this ecosystem a bit more oomph!

1 Like

I haven’t worked on it for some time, and it’s still incomplete: https://github.com/HaxeCheckstyle/haxe-rename/discussions/1

1 Like