I wanna rename match test file name after rename lib file, my question is: how to invoke a input dialog and get its value? what is the class name of rename action
You should use com.intellij.refactoring.rename.naming.AutomaticRenamerFactory instead which will automatically provide those renaming targets during the actual rename operation.
I'm aimed to refactory ruby test file after rename ruby lib file, This is my example:
# lib/ex.rb # spec/lib/ex_spec.rb
I hope when i rename lib/ex.rb to lib/ex2.rb, the spec/lib/ex_spec.rb will auto become spec/lib/ex2_spec.rb
So this is my thinking:
If I can get the value what I type in rename dialog, I can handle this value in code and then I find public RenameElementAction#getHandler, I hope find a way to custom the handler.
my question is:
How to get rename dialog value? How to customize getHandler in sub class of RenameElementAction I can undo refactoring with hitting ctrl+z, If I implement above, how to undo it?
And sorry, I'm not so understand How to use AutomaticRenamerFactory to implement them, can you explain it detail according my example.
Please try to understand existing code, e.g. com.intellij.lang.properties.refactoring.rename.ResourceBundleRenamerFactory is a very basic sample on how to use it.
"undo" support will be available automatically, as well as "preview changes"
I still has question, following is my code, if i rename ex.rb, it will change ex_test.rb, but when i hit ctrl+z to undo refactoring, ex_test.rb doesn't recovery and is changed forever. My question is how to recovery ex_test.rb
What is this: new File("/home/roroco/Dropbox/try/plugin/rb/spec/lib/ex_test.rb").write(new Date().toString())
IDE cannot know about such modifications and undo them. You must simply override #suggestNameForElement to provide new "automatic" filename and return false from allowChangeSuggestedName() to disallow manual editing.
Finally, I implement all feature what I need, but i find it will jump a new dialog, can you tell me how to use RenamePsiElementProcessor instead of AutomaticRenamerFactory
You should use com.intellij.refactoring.rename.naming.AutomaticRenamerFactory instead which will automatically provide those renaming targets
during the actual rename operation.
I'm aimed to refactory ruby test file after rename ruby lib file, This is my example:
# lib/ex.rb
# spec/lib/ex_spec.rb
I hope when i rename lib/ex.rb to lib/ex2.rb, the spec/lib/ex_spec.rb will auto become spec/lib/ex2_spec.rb
So this is my thinking:
If I can get the value what I type in rename dialog, I can handle this value in code
and then I find public RenameElementAction#getHandler, I hope find a way to custom the handler.
my question is:
How to get rename dialog value?
How to customize getHandler in sub class of RenameElementAction
I can undo refactoring with hitting ctrl+z, If I implement above, how to undo it?
And sorry, I'm not so understand How to use AutomaticRenamerFactory to implement them, can you explain it detail according my example.
Please try to understand existing code, e.g. com.intellij.lang.properties.refactoring.rename.ResourceBundleRenamerFactory
is a very basic sample on how to use it.
"undo" support will be available automatically, as well as "preview changes"
I still has question, following is my code, if i rename ex.rb, it will change ex_test.rb, but when i hit ctrl+z to undo refactoring, ex_test.rb doesn't recovery and is changed forever. My question is how to recovery ex_test.rb
// Renamer.groovy
// RenamerFactory
What is this: new File("/home/roroco/Dropbox/try/plugin/rb/spec/lib/ex_test.rb").write(new Date().toString())
IDE cannot know about such modifications and undo them. You must simply override #suggestNameForElement to provide new "automatic" filename and return false from allowChangeSuggestedName() to disallow manual editing.
Finally, I implement all feature what I need, but i find it will jump a new dialog, can you tell me how to use RenamePsiElementProcessor instead of AutomaticRenamerFactory
Finally, I find following code can fix my question:
// plugin.xml
// /home/roroco/Dropbox/try/idea-plugin/try/src/main/groovy/ro/tryApi/spec/RenameProcessor.groovy
// It's just a try code