flutter-intellij icon indicating copy to clipboard operation
flutter-intellij copied to clipboard

Rename/move directory won't change import

Open ph55 opened this issue 5 years ago • 54 comments

Manual search and replace currently required after renaming library directory. Please add support for automatic refactor of imports.

Version info
[✓] Flutter (Channel beta, v1.12.13+hotfix.6, on Mac OS X 10.15.2 19C57, locale en-IL)
    • Flutter version 1.12.13+hotfix.6 at /usr/local/lib/flutter
    • Framework revision 18cd7a3601 (5 weeks ago), 2019-12-11 06:35:39 -0800
    • Engine revision 2994f7e1e6
    • Dart version 2.7.0


[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/sasha/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = /Users/sasha/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/sasha/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3, Build version 11C29
    • CocoaPods version 1.8.4

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 42.1.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] IntelliJ IDEA Community Edition (version 2019.3.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 42.1.4
    • Dart plugin version 193.5731

[✓] VS Code (version 1.41.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.7.1

[✓] Connected device (3 available)
    • iPhone 11 Pro Max • D06766C9-E399-4AEF-B840-D9F00FF661EE • ios            • com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)
    • Chrome            • chrome                               • web-javascript • Google Chrome 79.0.3945.117
    • Web Server        • web-server                           • web-javascript • Flutter Tools

• No issues found!

ph55 avatar Jan 14 '20 18:01 ph55

Thanks for the report!

@scheglov do you know about this?

stevemessick avatar Jan 14 '20 23:01 stevemessick

@jwren worked on move / rename refactoring support in DAS.

scheglov avatar Jan 15 '20 04:01 scheglov

@ph55 which action/ entry point are you using to rename the directory in IntelliJ? Are all sources within a lib/?

jwren avatar Jan 15 '20 05:01 jwren

@jwren yes, all directories in lib. Only directories. Renaming files will change imports.

Here for example I change helper to helpers:

Screenshots

image

image

Same will happen for core or common folders (any nesting level)

ph55 avatar Jan 15 '20 11:01 ph55

I am experiencing this issue too. My current plugin version is v43.0.1.

wilburx9 avatar Feb 11 '20 08:02 wilburx9

I also still have this problem

WouterButhker avatar May 28 '20 12:05 WouterButhker

Is there a plugin for this perhaps?

jacobokoenig avatar Jun 16 '20 11:06 jacobokoenig

Still having this problem on v48

reinaldomoreira avatar Aug 04 '20 13:08 reinaldomoreira

Yes. I have the same issue.

CoderJava avatar Nov 18 '20 12:11 CoderJava

The file name changes, directory name changes, and the folder of the files are not auto imported/renamed.

I have a large architecture in-development so this consumes lots of time. Thanks.

yasinarik avatar Nov 19 '20 13:11 yasinarik

Also having this issue.

When refactoring our prototype codebase into something more scalable (code-wise), this becomes a big pain point. I have to manually go through about a hundred files, delete the broken imports, and then iteratively go through the now-unimported widgets and import them again.

Generally the Intellij plugin has been wonderful! This is the only major pain point I've come across.

harrisonturton avatar Mar 18 '21 03:03 harrisonturton

This is by far my largest pain point. Also performing a large refactor and I'm losing hours manually moving files.

Given that there are ~40 thumbs up, any chance a few of us could combine resources and sponsor someone to contribute a fix to this? Anyone interested?

venkatd avatar Mar 23 '21 03:03 venkatd

I'm also having this issue and it has been really frustrating. Some kind of update would be very much appreciated. I think this used to work once upon a time; I'd have expected regressions to be prioritised. It is a real sink of my time actually. As @venkatd above mentioned it is the 3rd most voted issue in this repository with 40thumbs and it has been live for very long and is also the most reasonable issue to be worked on. Rename functionality should surely be quick and easy fix?

Please can we have an update as to when we should expect this to be fixed? ...or even better get it fixed as soon as possible please?

Thank you

atreeon avatar Mar 23 '21 17:03 atreeon

The version 57.0.2 still had this issue, this issue happened over 1 years, and it seems to be basic function. Could you treat this issue as one of the top priority??

enginebai avatar Jun 24 '21 13:06 enginebai

@enginebai If it's a blocker, I'm sure the Flutter team would appreciate you submitting a PR to fix this.

In the meantime, a grep xyz | sed s/old/new/ may help you out.

harrisonturton avatar Jun 24 '21 22:06 harrisonturton

@stevemessick @helin24 @devoncarew I hope that you know about this problem. When do you plan to fix it please?

mjablecnik avatar Sep 11 '21 06:09 mjablecnik

Fyi @DanTup has been working on adding Analysis Server functionality to support this in IntelliJ and VSCode.

jacob314 avatar Sep 28 '21 19:09 jacob314

December 2021, and still having this issue. I'm on Android Studio Arctic Fox and flutter plugin version 62.0.1.

Is this also a problem in VSCode? Maybe I should move IDE if that's the case, it's really annoying.

lhengl avatar Dec 02 '21 07:12 lhengl

This also isn't currently supported in VS Code. It is something I have a basic working example for in the server, but it still needs some work (around performance, and how to ensure the request can be cancelled or timeout if it would take too long - for ex. if you tried to rename an enormous folder).

DanTup avatar Dec 02 '21 11:12 DanTup

Any updates maybe?

I just got a legacy code that needs a refactor. And it's a nightmare to fix every import manually :D

tieorange avatar Apr 08 '22 09:04 tieorange

Any updates on this? It's been two years already. It is super annoying when doing any refactoring. Thanks.

TadashiCZ avatar Apr 12 '22 07:04 TadashiCZ

we really need this feature. it's super annoying to refactor the project

paktalin avatar Apr 24 '22 10:04 paktalin

The server has support for renaming folders since https://github.com/dart-lang/sdk/commit/729b2e5d34bbca2a899ba12c7738cfa0bc3fa3b6, but it will require changes in IntelliJ/Android Studio to call the API for folders.

For VS Code, I'm waiting on a new version of the VS Code LSP Client (coming in the next few weeks, I believe) so that cancellations can be handled properly, before I enable it there.

DanTup avatar Apr 26 '22 14:04 DanTup

+1

OwlCodR avatar Apr 29 '22 20:04 OwlCodR

+1

AD1N1993 avatar May 11 '22 14:05 AD1N1993

Fyi @jwren. This is a good example of a case we should probably implement in the Dart IntelliJ plugin not the Flutter IntelliJ plugin.

jacob314 avatar May 11 '22 20:05 jacob314

@jacob314 agreed that would make more sense. If you close this, would you link to the issue in the Dart Plugin so we can know where to subscribe for updates?

Thank you for your work on the tools/framework!

CrossBread avatar May 11 '22 22:05 CrossBread

Fyi, there is also an issue tracking supporting this in VSCode. https://github.com/Dart-Code/Dart-Code/issues/2483

jacob314 avatar May 11 '22 23:05 jacob314

I solved this problem for myself by using the "Replace in Files" command

Screenshot 2022-05-18 at 14 36 30 Screenshot 2022-05-18 at 14 37 15

fedosovmu avatar May 18 '22 11:05 fedosovmu

I solved this problem for myself by using the "Replace in Files" command

Unless flutter command line / vscode ext implement something like "project move/rename/etc." This should be the way for our own src files.

On the other hand, most of the auto-get file(eg. .filecache, debug_*, etc) are using absolute path instead of relative to project root. Maybe that can be changed.

J-Siu avatar Jun 04 '22 11:06 J-Siu