-
Notifications
You must be signed in to change notification settings - Fork 316
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
Change file name when change class name #3354
Comments
I think it's a fair request. There are two places it could be implemented:
I think the second one makes most sense (cc @bwilkerson for his opinion) since other LSP clients would also benefit. In either case, I think there needs to be a setting to control this (for ex. a nullable boolean, where null means prompt the user, and true/false would just always do that - the prompt could include options for "this time only"/"always"/"never" which would set the option accordingly). We can prompt the user from the server using LSP's |
I also think the second approach is better. From what I understand the extension is manage the saving and the passing of the parameters for the handler, so the dart code doesn't need to save the "user preferences". Am I right? Also, I fork the dart SDK repo to make the changes and basically I finish writing the code but I haven't tested it yet. I am not sure how do I test if what I did is working. I tried to build the analysis_server project, but it depends on those projects: analysis_server -> analyzer_plugin -> analyzer_utilities -> analyzer And I can't build analyzer_utilities:
Also can you take a look at my code and check if what I did it fine? I am not sure if the file paths will be working and the way I got them and not sure about the return of |
That's a good question. It's correct that the server cannot modify the settings itself. In the extension (pre-LSP) this would be quite simple, but there's not a good way to do this with LSP. Implementing a custom message would work for VS Code, but not other editors so I'm not sure that's worth doing. So for now, probably it would be better for the prompt to just ask if you want to rename the file with only options for Yes/No and the user would have to change the setting themselves (this could be mentioned in the prompt).
Sure - it would be better to open a review to make it easier to comment (it'll need reviewing by a Googler there to merge anyway), but I've had a quick look through and made a few comments below.
If anything isn't clear or you have any more questions, let me know! |
@jacobggman is this something you're still looking at (or planning to)? There's no rush to do so, but I'm happy to take a look instead if that suits you better. Thanks! |
Hi! I have been a little bit busy lately. I will try to finish this issue until next week. Thanks! |
@DanTup I not finish yet this issue, but I want to open a review. But when I am typing |
@jacobggman The "git cl" command comes from https://github.com/dart-lang/sdk/wiki/Building It includes a binary |
I open a review of this issue, so now hopefully now it's will be easier for you to review my code. I update the code, but I still not write tests because I did not understand this part completely:
I did not manage to understand what is |
Sorry for the delay!
I think in your original code you were directly calling the I'm not certain if this would trigger VS Code to fire the onWillRename event, so we might need to do both - it would require some testing. If you haven't already set it up, you should be able to test in VS Code using the local analyzer by setting the "dart.analyzerPath": "/Users/danny/Dev/dart-sdk/sdk/pkg/analysis_server/bin/server.dart", |
Hi. I am a little busy lately and I don't have enough time to finish this issue, if you want, you can take from where I stop. Thanks you for your time! |
… LSP Fixes Dart-Code/Dart-Code#3354. Change-Id: I2a11a54e0a2c35d525ee08e0849e35c421f6e195 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212291 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]>
This works is complete but requires two things to use it:
It's off by default but can be turned on with the If you want to try it before them, you can manually add the setting to your VS Code settings (ignore that VS Code says it doesn't exist): "dart.renameFilesWithClasses": "prompt" And use a bleeding edge SDK build (not recommended for general dev, stick to stable!): |
Thanks! |
Every time that I want to refactor a name of a class in my code I need to change the class name and also change the file name. I think this is a waste of time to change the name of the same thing twice, this is an another step to make refactor harder. For example, I have a class that have the name of
NodeKey
and I want to change the class name toFileKey
I need to change the class name and the file name fromnode_key.dart
tofile_key.dart
.I thing that this process need to be automated and it will same time for many users and make refactoring easier. On
Change Symble
that change class name the extension will check if the file name have the same name as the changed class name (taking into consideration the name conventions of UpperCamelCase for class names and lowercase_with_underscores for file names) and if they have the same name change also the file name to the new name (with the name conventions).Alternative solutions are: use existing extensions that does it, if you know any, or this is already possible in this extension and I don't know about it or make a new extension that does it.
I will be happy to implement this if it is possible :) If possible you know any file/files you think that I need to change to make this feature?
The text was updated successfully, but these errors were encountered: