Author Topic: Search and replace text  -for classes, methods...  (Read 306 times)

Gehaschu

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Search and replace text  -for classes, methods...
« on: September 02, 2008, 07:30:47 pm »
Hi together,

I got a question on 'search and replace' functionality
In other programs - such as a word processor - there is the possibility to search a specific term and quickly replace the term with another one - the good old 'search and replace'.
Example: Look up the word 'foo' in the text and replace it with the term 'bar'.

I am now working with EA since a couple of months and it really helps to get quick results.
However I still haven't found such a search and replace functionality.

Each time one is working on a software architecture there comes the time when somebody is arguing with you about naming of classes, methods, attributes and so one. This is especially true when working on a architecture in early stages where the 'right names' for something still have to be found.

Whenever another engineer asks me to change the names of say a base class a bit then I have to change the names of subclasses accordingly by myself.

Example:
I have a base class names 'OldNameBase' and I have subclasses from that class named like
 
  • 'OldNameSpecializedClassA' and
  • 'OldNameSpecializedClassB'.  
 

So if I now have to rename OldNameBase for some reason to let's say 'SomeNewFancyNameBase' I have to rename OldNameSpecializedClassA and OldNameSpecializedClassB accordingly manually to something like 'SomeNewFancyNameSpecializedClassA' and so on.
 
A nice feature would be to select all the classes - or methods or whatever - in question and to do a 'search and replace' on them - like 'search for the term 'OldName' and replace it with SomeNewFancyName'.

The same feature would be also very nice for updating notes and stuff like that when the naming of related classes, methods... changes which the note relates to.

I searched the EA help files all over and I also searched the whole forum here but I couldn't find anything like an answer to my issue.

If there already is such a functionality please let me know how to access it.
If not I guess this might be a good reason for a feature request for upcoming versions of EA, don't you think ;).

Thank you in advance !

Cheers...

Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +0/-0
    • View Profile
Re: Search and replace text  -for classes, methods
« Reply #1 on: September 02, 2008, 08:18:48 pm »
For the time being you could work around the missing feature by exporting to xmi, replacing with any old text editor, and importing again. Provided your classes have no names figuring in xmi tags (like "packagedElement" a.s.o).

Gehaschu

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Search and replace text  -for classes, methods
« Reply #2 on: September 02, 2008, 11:09:24 pm »
Hi Frank,

thank you for your fast reply.
Your solution is interesting, I think I gonna give it a try the next time I have to rename a lot of classes.

Cheers...


Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +0/-0
    • View Profile
Re: Search and replace text  -for classes, methods
« Reply #3 on: September 03, 2008, 03:45:13 am »
Quote
Your solution is interesting

"Solution" is a bit strong really. It's just a workaround. Be sure to back up your eap file before you join the file fiddlers' club.

Another "solution", by the way, is fiddling with the database. Open the eap file with MS Access and run what they call "update queries" there.

Gehaschu

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Search and replace text  -for classes, methods
« Reply #4 on: September 08, 2008, 10:28:03 pm »
Hi Frank,

thanks for your replay anyway even if you think your solution is "just" a workaround - it can do the trick if someone has to change a lot of stuff. In this case a likely "dangerous" operation on the database can be taken into account.

However for things like renaming a few classes it would really nice to have an in-build functionality within EA for convenient access.

I know automation stuff like this can mess up a project file pretty much but a warning message like "do you really want to rename ?" might prevent unwanted things to happen.

If I have more time again I think I gonna post a feature request for this functionality.

Cheers...



RealAlex

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: Search and replace text  -for classes, methods
« Reply #5 on: September 25, 2008, 09:12:42 pm »
I've done a quite extensive use of automation as well as database access to change something in my repository, and it works great.

The problem with automation is that, if someone has locked some of the elements you want to change, it will raise an exception, so for that I would recomend an UPDATE against T_OBJECT filtering by OBJECT_NAME.

I've never had a problem with that, but it is wise to backup before.