Refactoring

Does Xojo have decent refactoring capabilities?

E.g. I can’t find a way to easily change a variable name other than going through all the code.

[quote=60028:@Marc van Breemen]Does Xojo have decent refactoring capabilities?

E.g. I can’t find a way to easily change a variable name other than going through all the code.[/quote]
Asked this question before. Did not get any decent answers.

Afaik, the best you can do is tick the ‘Whole word’ option and type in the variable name. You can probably use that RegEx stuff or write your own XojoScript but I have no experience with them.

For deprecating methods, properties, even whole objects, take a look at the attributes on the advanced tab in the inspector. You can add an attribute there with a name of Deprecated. If it has no value, Analyze Project will tell you that there is no replacement. If you specify a value (and it needs to be quoted), the value will be shown as the replacement for the item.

In the code editor, there is also a context menu which allows you to automatically convert a selection into a method, but it really only saves you a couple of steps.

I’m not seeking a way to deprecate anything, but simply renaming variables, classes etc.

Is my only option search & replace or is there a more safe way possible?

Yes. Use the “Whole Word” option and it really shouldn’t be that big a deal.

Ok, not perfect but I guess that’s all there is. You have to be sure the replaced text is unique.

You can do a search for the name and then manually go through and select the ones that should be replaced… hold the command key (on mac) and click to add individual lines to the selection and then “replace ###” rather than “All”.
Also if there are items like
myImage
myImageSize
myImageSizeMax

replace the longest one first and work down to the shortest

Also, keep in mind that the find panel has 3 scopes. Method, Object and Global which might make this easier on you.

I’m amazed to still be learning stuff all the time. Thanks Greg.

For what it’s worth, there’s a second attribute, Hidden which allows you to hide an item from Introspection and auto-complete. If you develop and distribute controls in Xojo this is a very handy way to keep users from discovering inner parts of your classes that you don’t want regular users to call (like if you needed a method so two classes could communicate with one another, which were not related otherwise). Just set the Name to Hidden with no value.

Both the Deprecated and Hidden attributes are also covered in User Guide Book 3: Framework, Chapter 10: Advanced Features, Section 9: Attributes.

Cool.

Guess, I better check out the user guide again. :slight_smile: