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.




Reply via email to