Title: Refactoring bug (build 615): renaming a boolean class attribute deleted getter method...

I don't know if this occurred prior to build 615 but that is where I have encountered it.
Using the renaming refactoring (Shift + F6) the following problem occurred:

My class had a boolean attribute with a standard getter and setter for it.
It also had a logic method with a similar name that read more like English "isSomething()" which used the boolean attribute for its logic.

Upon refactoring/renaming the boolean attribute I ended up with a class that still had a valid setter but no longer a getter method and my logic method had been converted to take the place of the getter method and all code references to the getter method were changed to point to the converted logic method.

Below is a simple "pseudo" code recreation (please forgive the abbreviated code layout) of what the class used to look like followed by what it looks like now:

/**
 * What the class used to look like
 */
class MyClass
{
    private boolean oldName;

    public boolean getOldName() { return oldName; }
    public void setOldName(boolean oldName) { this.oldName = oldName; }
    public boolean isSomethingOldNamed() { return oldName; }

    public void copyFrom(MyClass source)
    {
        // ...
        setOldName( source.getOldName() );
        // ...
    }
}


/**
 * What it looks like now
 */
class MyClass
{
    private boolean newName;

    public void setNewName(boolean newName) { this.newName = newName; }
    public boolean isNewName() { return newName; }

    public void copyFrom(MyClass source)
    {
        // ...
        setNewName( source.isNewName() );
        // ...
    }
}

As you can see from the example code I lost the getter method and IDEA changed my logic method's name and used it to take the getter method's place.


This communication is intended only for the use of the individual or entity to whom/which it is addressed, and information contained in this communication is privileged and confidential.  If the receiver of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited.  If you have received this communication in error, please notify the sender of this email (so that we may correct our internal records) and delete this communication without making a copy of it. 

Thank you.

Reply via email to