Showcase

On this page we would like to show you some of the things we have achieved in our term project.

Rename Local Variable

Preview

source:trunk/doc/screenshots/Rename_Local_Preview.png

Warning when renaming an argument

source:trunk/doc/screenshots/Rename_Argument.png

Rename Attribute

Preview

source:trunk/doc/screenshots/Rename_Attribute_Preview.png

Warning when object might belong to multiple types

source:trunk/doc/screenshots/Rename_Multitype_Preview.png

Rename Method Eclipse Preview

Preview

source:trunk/doc/screenshots/Rename_Method_Preview.png

Rename Method

class Knight(object):
    def print_stat(self):
        print "alive"

    def fight(self, other):
        print "fighting"
        self.print_stat()
        other.print_stat()

knight1 = Knight()
knight2 = Knight()

knight1.fight(knight2)

Renaming the print_stat to print_status would result in:

class Knight(object):
    def print_status(self):
        print "alive"

    def fight(self, other):
        print "fighting"
        self.print_status()
        other.print_status()

knight1 = Knight()
knight2 = Knight()

knight1.fight(knight2)

Rename Attribute in complex situations

Renaming an attribute is a common refactoring. Here's an example:

class Knight(object):
    def __init__(self, name):
        self.name = name

def create(klass, name):
    return klass(name)

robin = create(Knight, "Sir Robin")
print robin.name

Suppose we want to rename the name attribute in Knight to full_name. We can select name in __init__ or at the end in the print statement and run the refactoring, and the result is this:

class Knight(object):
    def __init__(self, name):
        self.full_name = name

def create(klass, name):
    return klass(name)

robin = create(Knight, "Sir Robin")
print robin.full_name

Handy :).