rewrite tool

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

rewrite tool

Tudor Girba-3
Hi,

We are trying to figure out how to use the Rewrite Tool, but we are  
not up to the task. We want to transform the following code:
facade := ImporterFacade forVisualWorks.
facade inModel: model.
facade importingContext importMaximum.
facade importNameSpaceFromBinding: #{LAN}.

Into:
ImporterFacade importNameSpaceFromVWBinding: #{LAN} inModel: model.

Unfortunately, we did not even manage to write the query to find the  
above code. We tried the following query (keep in mind that we do not  
know the exact names of the variables):
`f := ImporterFacade forVisualWorks.
`f inModel: `m.
`f importingContext importMaximum.
`f importNameSpaceFromBinding: `n.

We would appreciate any help in this matter, either in the form of  
advices, or pointers to documentation.

Thanks in advance.

Cheers,
Tudor

--
Tudor Adrian Girba                      Software Composition Group
(www.iam.unibe.ch/~girba)        University of Bern, Switzerland

"Every thing should have the right to be different."

Reply | Threaded
Open this post in threaded view
|

Re: rewrite tool

John Brant
Tudor Girba wrote:

> We are trying to figure out how to use the Rewrite Tool, but we are  not
> up to the task. We want to transform the following code:
> facade := ImporterFacade forVisualWorks.
> facade inModel: model.
> facade importingContext importMaximum.
> facade importNameSpaceFromBinding: #{LAN}.
>
> Into:
> ImporterFacade importNameSpaceFromVWBinding: #{LAN} inModel: model.
>
> Unfortunately, we did not even manage to write the query to find the
> above code. We tried the following query (keep in mind that we do not
> know the exact names of the variables):
> `f := ImporterFacade forVisualWorks.
> `f inModel: `m.
> `f importingContext importMaximum.
> `f importNameSpaceFromBinding: `n.
>
> We would appreciate any help in this matter, either in the form of
> advices, or pointers to documentation.

When matching multiple statements, you need to specify a match for the
complete sequence node. Also, `var only matches variable nodes. To make
them match anything, you need to add "@" (e.g., `@var).

| `@temps |
``@.BeforeStatements.
`f := ImporterFacade forVisualWorks.
`f inModel: `@m.
`f importingContext importMaximum.
`f importNameSpaceFromBinding: `@n.
``@.AfterStatements

->

| `@temps |
``@.BeforeStatements.
ImporterFacade importNameSpaceFromVWBinding: `@n inModel: `@m.
``@.AfterStatements


John Brant

Reply | Threaded
Open this post in threaded view
|

Re: rewrite tool

stéphane ducasse-2
In reply to this post by Tudor Girba-3
Note that we read all the documentation available (the slides of  
presentations and tried all kinds of code
with @ and the rest such as `@.stat. :)). But we are stuck.

Stef


> Hi,
>
> We are trying to figure out how to use the Rewrite Tool, but we are  
> not up to the task. We want to transform the following code:
> facade := ImporterFacade forVisualWorks.
> facade inModel: model.
> facade importingContext importMaximum.
> facade importNameSpaceFromBinding: #{LAN}.
>
> Into:
> ImporterFacade importNameSpaceFromVWBinding: #{LAN} inModel: model.
>
> Unfortunately, we did not even manage to write the query to find  
> the above code. We tried the following query (keep in mind that we  
> do not know the exact names of the variables):
> `f := ImporterFacade forVisualWorks.
> `f inModel: `m.
> `f importingContext importMaximum.
> `f importNameSpaceFromBinding: `n.
>
> We would appreciate any help in this matter, either in the form of  
> advices, or pointers to documentation.
>
> Thanks in advance.
>
> Cheers,
> Tudor
>
> --
> Tudor Adrian Girba                      Software Composition Group
> (www.iam.unibe.ch/~girba)        University of Bern, Switzerland
>
> "Every thing should have the right to be different."
>

Reply | Threaded
Open this post in threaded view
|

Re: rewrite tool

Boris Popov-4
In reply to this post by Tudor Girba-3
Tudor Girba wrote:

> Hi,
>
> We are trying to figure out how to use the Rewrite Tool, but we are not
> up to the task. We want to transform the following code:
> facade := ImporterFacade forVisualWorks.
> facade inModel: model.
> facade importingContext importMaximum.
> facade importNameSpaceFromBinding: #{LAN}.
>
> Into:
> ImporterFacade importNameSpaceFromVWBinding: #{LAN} inModel: model.
>
> Unfortunately, we did not even manage to write the query to find the
> above code. We tried the following query (keep in mind that we do not
> know the exact names of the variables):
> `f := ImporterFacade forVisualWorks.
> `f inModel: `m.
> `f importingContext importMaximum.
> `f importNameSpaceFromBinding: `n.
>
> We would appreciate any help in this matter, either in the form of
> advices, or pointers to documentation.
>

If your method looked exactly like what you pasted here, that would work,

Test>>test
  facade := ImporterFacade forVisualWorks.
  facade inModel: model.
  facade importingContext importMaximum.
  facade importNameSpaceFromBinding: #{LAN}

Then you would search for,

`@f := ImporterFacade forVisualWorks.
`@f inModel: `@m.
`@f importingContext importMaximum.
`@f importNameSpaceFromBinding: `@n.

And replace with,

ImporterFacade importNameSpaceFromVWBinding: `@n inModel: `@m.

I suspect the reason it doesn't match for you is because you have other
stuff there as well, say temps and more code, for example

Test>>test

test
  | facade model |
  facade := ImporterFacade forVisualWorks.
  facade inModel: model.
  facade importingContext importMaximum.
  facade importNameSpaceFromBinding: #{LAN}

In which case your search wouldn't work, but this would,

| `@temps |
``@.statements1.
`@f := ImporterFacade forVisualWorks.
`@f inModel: `@m.
`@f importingContext importMaximum.
`@f importNameSpaceFromBinding: `@n.
``@.statements2

And you would replace that code with,

``@.statements1.
ImporterFacade importNameSpaceFromVWBinding: `@n inModel: `@m.
``@.statements2

Hope this helps,

Cheers!

-Boris

Reply | Threaded
Open this post in threaded view
|

Re: rewrite tool

Tudor Girba-3
Hi,

Indeed it worked. Thanks a lot for the input.

Cheers,
Tudor

On Feb 18, 2006, at 8:53 PM, Boris Popov wrote:

> Tudor Girba wrote:
>> Hi,
>> We are trying to figure out how to use the Rewrite Tool, but we  
>> are not up to the task. We want to transform the following code:
>> facade := ImporterFacade forVisualWorks.
>> facade inModel: model.
>> facade importingContext importMaximum.
>> facade importNameSpaceFromBinding: #{LAN}.
>> Into:
>> ImporterFacade importNameSpaceFromVWBinding: #{LAN} inModel: model.
>> Unfortunately, we did not even manage to write the query to find  
>> the above code. We tried the following query (keep in mind that we  
>> do not know the exact names of the variables):
>> `f := ImporterFacade forVisualWorks.
>> `f inModel: `m.
>> `f importingContext importMaximum.
>> `f importNameSpaceFromBinding: `n.
>> We would appreciate any help in this matter, either in the form of  
>> advices, or pointers to documentation.
>
> If your method looked exactly like what you pasted here, that would  
> work,
>
> Test>>test
>  facade := ImporterFacade forVisualWorks.
>  facade inModel: model.
>  facade importingContext importMaximum.
>  facade importNameSpaceFromBinding: #{LAN}
>
> Then you would search for,
>
> `@f := ImporterFacade forVisualWorks.
> `@f inModel: `@m.
> `@f importingContext importMaximum.
> `@f importNameSpaceFromBinding: `@n.
>
> And replace with,
>
> ImporterFacade importNameSpaceFromVWBinding: `@n inModel: `@m.
>
> I suspect the reason it doesn't match for you is because you have  
> other stuff there as well, say temps and more code, for example
>
> Test>>test
>
> test
>  | facade model |
>  facade := ImporterFacade forVisualWorks.
>  facade inModel: model.
>  facade importingContext importMaximum.
>  facade importNameSpaceFromBinding: #{LAN}
>
> In which case your search wouldn't work, but this would,
>
> | `@temps |
> ``@.statements1.
> `@f := ImporterFacade forVisualWorks.
> `@f inModel: `@m.
> `@f importingContext importMaximum.
> `@f importNameSpaceFromBinding: `@n.
> ``@.statements2
>
> And you would replace that code with,
>
> ``@.statements1.
> ImporterFacade importNameSpaceFromVWBinding: `@n inModel: `@m.
> ``@.statements2
>
> Hope this helps,
>
> Cheers!
>
> -Boris
>

--
Tudor Adrian Girba                      Software Composition Group
(www.iam.unibe.ch/~girba)        University of Bern, Switzerland

"What we can governs what we wish."

Reply | Threaded
Open this post in threaded view
|

Re: rewrite tool

stéphane ducasse-2
In reply to this post by John Brant
Thanks john, I read the tutorials but apparently I always got  
something wrong in my expression.

Stef

On 18 févr. 06, at 18:14, John Brant wrote:

> Tudor Girba wrote:
>
>> We are trying to figure out how to use the Rewrite Tool, but we  
>> are  not
>> up to the task. We want to transform the following code:
>> facade := ImporterFacade forVisualWorks.
>> facade inModel: model.
>> facade importingContext importMaximum.
>> facade importNameSpaceFromBinding: #{LAN}.
>>
>> Into:
>> ImporterFacade importNameSpaceFromVWBinding: #{LAN} inModel: model.
>>
>> Unfortunately, we did not even manage to write the query to find the
>> above code. We tried the following query (keep in mind that we do not
>> know the exact names of the variables):
>> `f := ImporterFacade forVisualWorks.
>> `f inModel: `m.
>> `f importingContext importMaximum.
>> `f importNameSpaceFromBinding: `n.
>>
>> We would appreciate any help in this matter, either in the form of
>> advices, or pointers to documentation.
>
> When matching multiple statements, you need to specify a match for the
> complete sequence node. Also, `var only matches variable nodes. To  
> make
> them match anything, you need to add "@" (e.g., `@var).
>
> | `@temps |
> ``@.BeforeStatements.
> `f := ImporterFacade forVisualWorks.
> `f inModel: `@m.
> `f importingContext importMaximum.
> `f importNameSpaceFromBinding: `@n.
> ``@.AfterStatements
>
> ->
>
> | `@temps |
> ``@.BeforeStatements.
> ImporterFacade importNameSpaceFromVWBinding: `@n inModel: `@m.
> ``@.AfterStatements
>
>
> John Brant
>