Is there any ways to replace one class by another in Idea?

Greetings!
Guys, here is my problem: I have some class which is used in many places in my project. And I must replace this class with another from jar provided. Is there any ways to refactor this? I suppose this is a simple problem, but I dont know how to solve it.

Its not about replacing source code - what I want is to replace all class usages by class from my library and be able to completely remove my own class. Imagine I have created my own StringUtils and  have found out that there is a apache.common StringUtils library, and now I want to replace it everywhere in my code. And the signatures of class methods are not a problem: they coincide.

?

3 comments
Comment actions Permalink

On Fri, 28 Oct 2011 13:23:43 MSD, Dmitry Zhuravlev
<no_reply@jetbrains.com> wrote, quoted or indirectly quoted someone
who said :

>Its not about replacing source code - what I want is to replace all class usages by class from my library and be able to completely remove my own class. Imagine I have created my own StringUtils and  have found out that there is a apache.common StringUtils library, and now I want to replace it everywhere in my code. And the signatures of class methods are not a problem: they coincide.

Let's say I have classes A and B, I want to change all references of
class A to class B, but keep both classes.

One technique is to use replace in path, case sensitive and change all
the names, leaving A and B alone.  Hopefully your class names are
unique.

Another is:
1.  save a copy of class A.java and B.java outside of IntelliJ.
2. delete B.java
3. use refactor rename to rename class A to B and all references to A
to B.
4. copy your backup A.java and B.java back into IntelliJ.
5. synchronise so Intellij notices the new files.
--
Roedy Green Canadian Mind Products
http://mindprod.com
Capitalism has spurred the competition that makes CPUs faster and
faster each year, but the focus on money makes software manufacturers
do some peculiar things like deliberately leaving bugs and deficiencies
in the software so they can soak the customers for upgrades later.
Whether software is easy to use, or never loses data, when the company
has a near monopoly, is almost irrelevant to profits, and therefore
ignored. The manufacturer focuses on cheap gimicks like dancing paper
clips to dazzle naive first-time buyers. The needs of existing
experienced users are almost irrelevant. I see software rental as the
best remedy.

0
Comment actions Permalink

And why would you do so, with the really great structural search and replace at hand which can do the task a dozen times easier and safer?

0

Please sign in to leave a comment.