Refactoring issues
When refactoring, only the source file is moved between packages. The following is not done:
1) In the source code, the package is not changed.
2) The class in the source code is not renamed. Given that Scala does not require the class to be in the same file, it would be nice if during factoring, the developer is asked whether he/she wishes to rename the class. In case, there's a companion object, a further question should therefore be asked of the user.
e.g.
packages
p1
Class1.scala
p2
Refactor Class1.scala and move to p2. The file is moved but in the source code, package is still p1.
Refactor Class1.scala and rename to Class2. Only filename has changed.
1) In the source code, the package is not changed.
2) The class in the source code is not renamed. Given that Scala does not require the class to be in the same file, it would be nice if during factoring, the developer is asked whether he/she wishes to rename the class. In case, there's a companion object, a further question should therefore be asked of the user.
e.g.
packages
p1
Class1.scala
p2
Refactor Class1.scala and move to p2. The file is moved but in the source code, package is still p1.
Refactor Class1.scala and rename to Class2. Only filename has changed.
Leave a comment
I agree this would be very nice to have. Moving this to 2.0
on 2011-05-18 16:56 *
By Mirko Stocker
I see several things we could do here, and I propose the following:
- When the user renames a file, and there's a top-level class in the file with the same name as file, then we ask to rename the class as well. Companion objects are always renamed too.
- When the user renames a class or object which is in a file with the same name, then we also rename the file.
- When the user renames a package, rename the package declaration and adapt all the imports.
on 2011-05-18 16:59 *
By Mirko Stocker
Sorry, clicked on Submit instead of Preview..
The first two of the above points shouldn't be too hard to implement, it's just a matter of hooking into the JDT (rename participants). The last point could be a little bit more work because the corresponding refactoring doesn't exist yet, so I'm not sure if I can deliver that for 2.0.
The first two of the above points shouldn't be too hard to implement, it's just a matter of hooking into the JDT (rename participants). The last point could be a little bit more work because the corresponding refactoring doesn't exist yet, so I'm not sure if I can deliver that for 2.0.
on 2011-05-24 17:43 *
By Mirko Stocker
Renaming should now behave as expected, when the file is renamed and there exists a top level class with that name, it is renamed too (if the user doesn't want that, he can deselect the change in the change preview).
I've created a new ticket for the package issues, #1000422.