Skip to main content

Renaming a Class

Renaming a Class

Studio does not provide a direct way to rename a class. To rename a class, you can take either of the following approaches:

  • Create a copy of the class and delete the original.

    To copy a class:

    1. Select Tools > Copy Class...

    2. For Copy Class Definition From, select the original class. This value is initialized with the name of the class that you are currently viewing.

    3. For To, specify a new full class name.

    4. Optionally select Replace instances of Class Name. This replaces instances of the class name within code in the copied class. It does not affect other classes, and it does not affect comments.

    5. Select OK.

  • Export the class from Studio, edit the XML file, reimport it, and then delete the original class.

    To export and import, adapt the technique in “Moving Code from One Database to Another.”

    The XML structure of the exported file is not documented, but it is fairly easy to identify what must be changed. The class name is near the top of the file:

    <Class name="MyPackage.MyClass">
    

    The class definition might include additional references to the class name, which you would also change.

In either case, you should also do the following:

FeedbackOpens in a new tab