Refactoring Support for Attributes in Delphi 2010

Author: Malcolm Groves. Link to original: http://www.malcolmgroves.com/blog/?p=554 (English).
Tags: Delphi, delphi2010, атрибуты, рефакторинг Submitted by r3code 03.02.2010. Public material.
Статья о программировании на языке Delphi. Рассказывается новых возможностях рефакторинга атрибутов в Delphi 2010. Опубликован http://habrahabr.ru/blogs/delphi/85503/

Translations of this material:

into Russian: Поддержка рефакторинга атрибутов в Delphi 2010. Translation complete.
Submitted for translation by r3code 03.02.2010 Published 1 year, 12 months ago.

Text

I mentioned earlier that a lot of work in this release had gone into smaller features and feature tweaks. One of the results is that the IDE keeps giving me pleasant surprises. I’ll try to do something without even really thinking about whether it should work or not, and find that it not only works, but that it goes a little further than I might have thought.

One example is around Refactoring support for Attributes. If you look at my first, simple example of Attributes, one of the many things wrong with it is that the Attribute name is terrible. Unless I never plan on writing more than one Attribute, MyAttribute is probably not the best choice.

No problem, Delphi has supported a rename refactoring for awhile now, I’ll just use that. Right-click on the identifier, select Refactoring | Rename, give it a great new name like, oh, NameAgeAttribute (much better ;-)) and press OK.

At this point I expected it to rename all the actual occurrences of the class name in code, but I half expected it to not deal with the actual [MyAttribute…] occurrences. I definitely didn’t expect it to handle the places where I’d left off the Attribute suffix.

Well, look at the screenshot below and you’ll see that I underestimated it greatly. As a refactoring should, it handled every one of my cases, and left my code in a state that compiles and runs exactly as it did before.

Nice one guys!