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." |
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 |
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." > |
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 |
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." |
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 > |
Free forum by Nabble | Edit this page |