Create BaselineOf from ConfigurationOf
I got tired of manually converting Configs into Baselines, so I wrote a little script. You pass it the selector of a #baselineXyz: method, and it converts it (i.e. changes the pragma, removes the blessing and repo, etc) Hopefully you will find it useful. Cross posting to Metcello list... ConfigurationOf>>#createBaselineFrom: selector | projectName baselineName baseline methodTree commonBlockBody repoSetter | "Create new class" projectName := self name allButFirst: self superclass name size. baselineName := 'BaselineOf', projectName. baseline := BaselineOf subclass: baselineName asSymbol instanceVariableNames: '' classVariableNames: '' category: baselineName. "Convert baseline##: method" methodTree := (self methodNamed: selector) parseTree. methodTree selector: #baseline:. methodTree pragmas at: 1 put: (RBPragmaNode selector: #baseline arguments: #()). commonBlockBody := methodTree statements first arguments last body. repoSetter := commonBlockBody statements detect: [ :e | e selector = #repository: ]. commonBlockBody removeNode: repoSetter. "Compile baseline method" baseline compile: methodTree newSource classified: 'baseline' ----- Cheers, Sean -- View this message in context: http://forum.world.st/Create-BaselineOf-from-ConfigurationOf-tp4893076.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
Nice. I will give it a try On Apr 30, 2016 19:03, "Sean P. DeNigris" <sean@clipperadams.com> wrote:
I got tired of manually converting Configs into Baselines, so I wrote a little script. You pass it the selector of a #baselineXyz: method, and it converts it (i.e. changes the pragma, removes the blessing and repo, etc) Hopefully you will find it useful. Cross posting to Metcello list...
ConfigurationOf>>#createBaselineFrom: selector
| projectName baselineName baseline methodTree commonBlockBody repoSetter |
"Create new class" projectName := self name allButFirst: self superclass name size. baselineName := 'BaselineOf', projectName. baseline := BaselineOf subclass: baselineName asSymbol instanceVariableNames: '' classVariableNames: '' category: baselineName.
"Convert baseline##: method" methodTree := (self methodNamed: selector) parseTree. methodTree selector: #baseline:. methodTree pragmas at: 1 put: (RBPragmaNode selector: #baseline arguments: #()). commonBlockBody := methodTree statements first arguments last body. repoSetter := commonBlockBody statements detect: [ :e | e selector = #repository: ]. commonBlockBody removeNode: repoSetter.
"Compile baseline method" baseline compile: methodTree newSource classified: 'baseline'
----- Cheers, Sean -- View this message in context: http://forum.world.st/Create-BaselineOf-from-ConfigurationOf-tp4893076.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
Le 30/04/2016 23:28, Sean P. DeNigris a écrit :
I got tired of manually converting Configs into Baselines, so I wrote a little script. You pass it the selector of a #baselineXyz: method, and it converts it (i.e. changes the pragma, removes the blessing and repo, etc) Hopefully you will find it useful. Cross posting to Metcello list...
ConfigurationOf>>#createBaselineFrom: selector
| projectName baselineName baseline methodTree commonBlockBody repoSetter |
"Create new class" projectName := self name allButFirst: self superclass name size. baselineName := 'BaselineOf', projectName. baseline := BaselineOf subclass: baselineName asSymbol instanceVariableNames: '' classVariableNames: '' category: baselineName.
"Convert baseline##: method" methodTree := (self methodNamed: selector) parseTree.
Oh, that's why you were asking for #ast versus #parseTree. Thierry
methodTree selector: #baseline:. methodTree pragmas at: 1 put: (RBPragmaNode selector: #baseline arguments: #()). commonBlockBody := methodTree statements first arguments last body. repoSetter := commonBlockBody statements detect: [ :e | e selector = #repository: ]. commonBlockBody removeNode: repoSetter.
"Compile baseline method" baseline compile: methodTree newSource classified: 'baseline'
----- Cheers, Sean -- View this message in context: http://forum.world.st/Create-BaselineOf-from-ConfigurationOf-tp4893076.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
Thierry Goubier wrote
Oh, that's why you were asking for #ast versus #parseTree.
You caught me! ----- Cheers, Sean -- View this message in context: http://forum.world.st/Create-BaselineOf-from-ConfigurationOf-tp4893076p48931... Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
participants (3)
-
Gabriel Cotelli -
Sean P. DeNigris -
Thierry Goubier