I need to rename a class in MavensMate. I ended up creating a new class and copying the code. Is there another way?
Yes there is a way. While inside sublime:
- Edit the class name you wanted to edit
- Save it locally
- Compile the file you just saved
- At the menu bar, click Mavensmate > Project > Clean project (please see image below)
After the cleaning process, you'll see that the old class file is still open in sublime, the class name already changed but the filename is still the same, and is not saved. This is normal don't worry. Just discard this file. After discarding, search for the newly created file (one way to do this is to press CTRL+P, then type the new class name. It should be there and you should be able to choose it), choose it, and the new newly renamed class should open up. After the class opened up, you will see that its file name is the same as the class name.
If you're still having doubts if the class really got renamed, log in to your SFDC environment and search in Objects > Apex Classes. You'll find out that the old name is not there anymore, but the new name is.
I found out that after step 4, you have to add a few more steps. Take note that the steps below, I believe, applies to those Mavensmate users of version >= 7.0.2, and the new mavensmate app version >= 0.0.10.
- Click Mavensmate > Project > Edit Project...
- After the mavensmate app opens, go to the Project Metadata tab
- Search for a class with a name that's same with the name you used in your renaming awhile ago.
- Tick its checkbox
- Click the blue Update Project button at the top right area.
Sadly, there isn't really. The only alternative is renaming classes/triggers by going into Salesforce, but this isn't any more convenient than creating a new class and deleting the old one. https://developer.salesforce.com/page/Miscellaneous