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?
This is usually first question when I try to introduce Haxe
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? . 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? 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
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
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!