Rewrite rule help wanted

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Rewrite rule help wanted

Mathieu van Echtelt-3
Hi all,

I've some difficulties using the rewrite tool (part of the refactoring browser).
could somebody help me transforming the following line:

self contract.

with these two lines:

party := self partyOfType: PartyX withName: 'testName'.
contract := self contractForParty: party.

where,
party and contract are temp variables and should be declared.
Most methods which have to be transformed will have some temp variables already.
PartyX is a class name.
"self contract" is mostly the first statement within method, but not always.

Thanks in advance.

Mathieu

Reply | Threaded
Open this post in threaded view
|

Re: Rewrite rule help wanted

a3aan
Dear Matthieu,

   if you do

FIND
| `@temps |
``@.statsBefore.
self contract.
``@.statsAfter.

REPLACE
| `@temps party contract |
``@.statsBefore.
party := self partyOfType: PartyX withName: 'testName'.
contract := self contractForParty: party.
``@.statsAfter.

then the only problem is that methods which already have temps 'contract'
or 'party' will get duplicates which will cause compiler errors.  This
could be avoided by programmatic rewritting using the

   `{:dict | some code }

construct but it is tricky to fit that into temporaries instead of into
code.  We will try and say more tomorrow.

   Yours faithfully
      Niall Ross
      Adriaan van Os


> Hi all,
>
> I've some difficulties using the rewrite tool (part of the refactoring
browser).

> could somebody help me transforming the following line:
>
> self contract.
>
> with these two lines:
>
> party := self partyOfType: PartyX withName: 'testName'.
> contract := self contractForParty: party.
>
> where,
> party and contract are temp variables and should be declared.
> Most methods which have to be transformed will have some temp variables
already.
> PartyX is a class name.
> "self contract" is mostly the first statement within method, but not
always.
>
> Thanks in advance.
>
> Mathieu
>


--
http://www.a3aan.st



--
http://www.a3aan.st