I've never really learned the rewrite tool but while waiting for changes to 
propagate through P12, I thought maybe I could use it to safely patch changes 
until there are official updates (and it was a good chance to get more familiar 
with it).

I thought there was more documentation available for how it works (interested 
in any old articles - but the online help in P12 is ok - although it doesn't 
display in markdown - in fact give there is markdown support now - I am a bit 
confused what should appear more readable these days - and how to 
fix/contribute changes to help).

This aside - I wanted to patch the SystemWindow>>taskbarButtonMenu: (and add my 
fix to move tabs to any position).

I started writing the following search expression - the find the last call to 
#addToggle:... method call that has a literal referencing #canBeMovedRight - as 
I want to add my new menu item after it.

e.g.

moveSubmenu `@addToggle: `{ :node | node isLiteralNode and: [ node value = 
#canBeMovedToRight] } 

but I'm not sure my {} filter block is ever called, as the above matches both 
addToggle:... calls, and not the one I'm after? I don't understand this - any 
have ideas on the proper syntax for generic matching?

Anyway - I decided that in my case there is only one - so I can match it 
explicitly and so I  search on the full call:

and I entered this:
moveSubmenu 
   addToggle: 'Move right' translated 
   target: self 
   selector: #taskbarMoveRight 
   getStateSelector: nil 
   enablementSelector: #canBeMovedToRight.

Which matches exactly - then I want to replace the single statement with 2 
statements e.g.

moveSubmenu
   addToggle: 'Move right' translated
   target: self
   selector: #taskbarMoveRight
   getStateSelector: nil
   enablementSelector: #canBeMovedToRight.

moveSubmenu
   addToggle: 'Move to' translated
   target: self
   selector: #taskbarMoveTo
   getStateSelector: nil.


However this gives an error in the rewrite tool (actually it results in a zero 
change, that then gives an error for EpMonitor).

But my question is - why can't you rewrite a single statement to multiple ones? 
I have noticed that in this case I can cascade the message send - and this then 
rewrites properly - so it looks like it wants to replace a single node with a 
single node.

If I couldn't cascade - It seems I would have to rewrite with something like: [ 
"put multiple expressions here" ] value.

This seems an odd choice - but am I missing something obvious? 

Do you have to do what I'm proposing in 2 steps - rewrite to a block (or some 
equivalent) and then a 2nd rewrite to simplify the expression  (like a refactor 
step) - so its more provably correct?

I'm just curious on this - as it seemed time to learn this properly?

Tim

Reply via email to