how to add a class via programatic refactoring

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

how to add a class via programatic refactoring

Tudor Girba-2
Hi,

I would like to create a class with instance variables and methods using RB, and preview the changes with the changes browser.

I know how to create AddClass, AddInstanceVariable, AddMethod refactorings individually and query for their changes. For example:

(RBAddClassRefactoring
                addClass: #SomeClass
                superclass: #Object
                subclasses: {}
                category: #Category) primitiveExecute; changes.

(RBAddInstanceVariableRefactoring
        variable: 'x'
        class: #SomeClass) primitiveExecute; changes

My question is: is it possible to create them all in one batch and preview their changes in one single window?

Cheers,
Doru


--
www.tudorgirba.com
www.feenk.com

"If you interrupt the barber while he is cutting your hair,
you will end up with a messy haircut."


Reply | Threaded
Open this post in threaded view
|

Re: how to add a class via programatic refactoring

stepharo
Probably now I can tell you that we lost some afternoons one trying the
get a tick list to have multiple renaming on instance
and we discovered that they were some problems in the models of RB. It
was totally strange.
Now a good cleaning of nautilus is still needed in this part of the code.

Stef


Le 7/2/16 22:24, Tudor Girba a écrit :

> Hi,
>
> I would like to create a class with instance variables and methods using RB, and preview the changes with the changes browser.
>
> I know how to create AddClass, AddInstanceVariable, AddMethod refactorings individually and query for their changes. For example:
>
> (RBAddClassRefactoring
> addClass: #SomeClass
> superclass: #Object
> subclasses: {}
> category: #Category) primitiveExecute; changes.
>
> (RBAddInstanceVariableRefactoring
> variable: 'x'
> class: #SomeClass) primitiveExecute; changes
>
> My question is: is it possible to create them all in one batch and preview their changes in one single window?
>
> Cheers,
> Doru
>
>
> --
> www.tudorgirba.com
> www.feenk.com
>
> "If you interrupt the barber while he is cutting your hair,
> you will end up with a messy haircut."
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: how to add a class via programatic refactoring

Nicolai Hess-3-2
In reply to this post by Tudor Girba-2
Not the best way maybe:

    | model refactoring1 refactoring2 browser |
    model := RBNamespace onEnvironment: RBBrowserEnvironment new.
    refactoring1 := RBAddClassRefactoring
        model: model
        addClass: #SomeClass
        superclass: #Object
        subclasses: {}
        category: #Category.
    refactoring1 primitiveExecute.
    refactoring2 := RBAddInstanceVariableRefactoring
        model: model
        variable: 'x'
        class: #SomeClass.
    refactoring2 primitiveExecute.
    browser := ChangesBrowser new.
    browser changesTree roots: (model changes whatToDisplayIn: browser).
    browser open



2016-02-07 22:24 GMT+01:00 Tudor Girba <[hidden email]>:
Hi,

I would like to create a class with instance variables and methods using RB, and preview the changes with the changes browser.

I know how to create AddClass, AddInstanceVariable, AddMethod refactorings individually and query for their changes. For example:

(RBAddClassRefactoring
                addClass: #SomeClass
                superclass: #Object
                subclasses: {}
                category: #Category) primitiveExecute; changes.

(RBAddInstanceVariableRefactoring
        variable: 'x'
        class: #SomeClass) primitiveExecute; changes

My question is: is it possible to create them all in one batch and preview their changes in one single window?

Cheers,
Doru


--
www.tudorgirba.com
www.feenk.com

"If you interrupt the barber while he is cutting your hair,
you will end up with a messy haircut."



Reply | Threaded
Open this post in threaded view
|

Re: how to add a class via programatic refactoring

Nicolai Hess-3-2


2016-02-08 10:57 GMT+01:00 Nicolai Hess <[hidden email]>:
Not the best way maybe:

    | model refactoring1 refactoring2 browser |
    model := RBNamespace onEnvironment: RBBrowserEnvironment new.
    refactoring1 := RBAddClassRefactoring
        model: model
        addClass: #SomeClass
        superclass: #Object
        subclasses: {}
        category: #Category.
    refactoring1 primitiveExecute.
    refactoring2 := RBAddInstanceVariableRefactoring
        model: model
        variable: 'x'
        class: #SomeClass.
    refactoring2 primitiveExecute.
    browser := ChangesBrowser new.
    browser changesTree roots: (model changes whatToDisplayIn: browser).
    browser open



By the way, refactoring browser is still broken in some places (don't remember the fogbugz issues, but one
is related with "tree-like" refactorings and one is related to rubrics diff view :(
 

2016-02-07 22:24 GMT+01:00 Tudor Girba <[hidden email]>:
Hi,

I would like to create a class with instance variables and methods using RB, and preview the changes with the changes browser.

I know how to create AddClass, AddInstanceVariable, AddMethod refactorings individually and query for their changes. For example:

(RBAddClassRefactoring
                addClass: #SomeClass
                superclass: #Object
                subclasses: {}
                category: #Category) primitiveExecute; changes.

(RBAddInstanceVariableRefactoring
        variable: 'x'
        class: #SomeClass) primitiveExecute; changes

My question is: is it possible to create them all in one batch and preview their changes in one single window?

Cheers,
Doru


--
www.tudorgirba.com
www.feenk.com

"If you interrupt the barber while he is cutting your hair,
you will end up with a messy haircut."




Reply | Threaded
Open this post in threaded view
|

Re: how to add a class via programatic refactoring

Tudor Girba-2
In reply to this post by Nicolai Hess-3-2
Great! Thanks a lot.

Doru


> On Feb 8, 2016, at 10:57 AM, Nicolai Hess <[hidden email]> wrote:
>
> Not the best way maybe:
>
>     | model refactoring1 refactoring2 browser |
>     model := RBNamespace onEnvironment: RBBrowserEnvironment new.
>     refactoring1 := RBAddClassRefactoring
>         model: model
>         addClass: #SomeClass
>         superclass: #Object
>         subclasses: {}
>         category: #Category.
>     refactoring1 primitiveExecute.
>     refactoring2 := RBAddInstanceVariableRefactoring
>         model: model
>         variable: 'x'
>         class: #SomeClass.
>     refactoring2 primitiveExecute.
>     browser := ChangesBrowser new.
>     browser changesTree roots: (model changes whatToDisplayIn: browser).
>     browser open
>
>
>
> 2016-02-07 22:24 GMT+01:00 Tudor Girba <[hidden email]>:
> Hi,
>
> I would like to create a class with instance variables and methods using RB, and preview the changes with the changes browser.
>
> I know how to create AddClass, AddInstanceVariable, AddMethod refactorings individually and query for their changes. For example:
>
> (RBAddClassRefactoring
>                 addClass: #SomeClass
>                 superclass: #Object
>                 subclasses: {}
>                 category: #Category) primitiveExecute; changes.
>
> (RBAddInstanceVariableRefactoring
>         variable: 'x'
>         class: #SomeClass) primitiveExecute; changes
>
> My question is: is it possible to create them all in one batch and preview their changes in one single window?
>
> Cheers,
> Doru
>
>
> --
> www.tudorgirba.com
> www.feenk.com
>
> "If you interrupt the barber while he is cutting your hair,
> you will end up with a messy haircut."
>
>
>

--
www.tudorgirba.com
www.feenk.com

"No matter how many recipes we know, we still value a chef."








Reply | Threaded
Open this post in threaded view
|

Re: how to add a class via programatic refactoring

Peter Uhnak
What's the practical difference between calling

```
(RBAddClassRefactoring
                addClass: #SomeClass
                superclass: #Object
                subclasses: {}
                category: #Category) primitiveExecute; changes.
```
and
```
Object subclass: #SomeClass
instanceVariableNames: ''
classVariableNames: ''
package: 'Category'
```

likewise for the attribute?

I am doing source code generation in one project and using the latter approach, so I am curious about the benefit of the first one.

Thanks,
Peter


On Mon, Feb 8, 2016 at 12:22 PM, Tudor Girba <[hidden email]> wrote:
Great! Thanks a lot.

Doru


> On Feb 8, 2016, at 10:57 AM, Nicolai Hess <[hidden email]> wrote:
>
> Not the best way maybe:
>
>     | model refactoring1 refactoring2 browser |
>     model := RBNamespace onEnvironment: RBBrowserEnvironment new.
>     refactoring1 := RBAddClassRefactoring
>         model: model
>         addClass: #SomeClass
>         superclass: #Object
>         subclasses: {}
>         category: #Category.
>     refactoring1 primitiveExecute.
>     refactoring2 := RBAddInstanceVariableRefactoring
>         model: model
>         variable: 'x'
>         class: #SomeClass.
>     refactoring2 primitiveExecute.
>     browser := ChangesBrowser new.
>     browser changesTree roots: (model changes whatToDisplayIn: browser).
>     browser open
>
>
>
> 2016-02-07 22:24 GMT+01:00 Tudor Girba <[hidden email]>:
> Hi,
>
> I would like to create a class with instance variables and methods using RB, and preview the changes with the changes browser.
>
> I know how to create AddClass, AddInstanceVariable, AddMethod refactorings individually and query for their changes. For example:
>
> (RBAddClassRefactoring
>                 addClass: #SomeClass
>                 superclass: #Object
>                 subclasses: {}
>                 category: #Category) primitiveExecute; changes.
>
> (RBAddInstanceVariableRefactoring
>         variable: 'x'
>         class: #SomeClass) primitiveExecute; changes
>
> My question is: is it possible to create them all in one batch and preview their changes in one single window?
>
> Cheers,
> Doru
>
>
> --
> www.tudorgirba.com
> www.feenk.com
>
> "If you interrupt the barber while he is cutting your hair,
> you will end up with a messy haircut."
>
>
>

--
www.tudorgirba.com
www.feenk.com

"No matter how many recipes we know, we still value a chef."









Reply | Threaded
Open this post in threaded view
|

Re: how to add a class via programatic refactoring

stepharo
It checks that the class does not already exist.
And check the preconditions.

Le 9/2/16 16:41, Peter Uhnák a écrit :
What's the practical difference between calling

```
(RBAddClassRefactoring
                addClass: #SomeClass
                superclass: #Object
                subclasses: {}
                category: #Category) primitiveExecute; changes.
```
and
```
Object subclass: #SomeClass
instanceVariableNames: ''
classVariableNames: ''
package: 'Category'
```

likewise for the attribute?

I am doing source code generation in one project and using the latter approach, so I am curious about the benefit of the first one.

Thanks,
Peter


On Mon, Feb 8, 2016 at 12:22 PM, Tudor Girba <[hidden email]> wrote:
Great! Thanks a lot.

Doru


> On Feb 8, 2016, at 10:57 AM, Nicolai Hess <[hidden email]> wrote:
>
> Not the best way maybe:
>
>     | model refactoring1 refactoring2 browser |
>     model := RBNamespace onEnvironment: RBBrowserEnvironment new.
>     refactoring1 := RBAddClassRefactoring
>         model: model
>         addClass: #SomeClass
>         superclass: #Object
>         subclasses: {}
>         category: #Category.
>     refactoring1 primitiveExecute.
>     refactoring2 := RBAddInstanceVariableRefactoring
>         model: model
>         variable: 'x'
>         class: #SomeClass.
>     refactoring2 primitiveExecute.
>     browser := ChangesBrowser new.
>     browser changesTree roots: (model changes whatToDisplayIn: browser).
>     browser open
>
>
>
> 2016-02-07 22:24 GMT+01:00 Tudor Girba <[hidden email]>:
> Hi,
>
> I would like to create a class with instance variables and methods using RB, and preview the changes with the changes browser.
>
> I know how to create AddClass, AddInstanceVariable, AddMethod refactorings individually and query for their changes. For example:
>
> (RBAddClassRefactoring
>                 addClass: #SomeClass
>                 superclass: #Object
>                 subclasses: {}
>                 category: #Category) primitiveExecute; changes.
>
> (RBAddInstanceVariableRefactoring
>         variable: 'x'
>         class: #SomeClass) primitiveExecute; changes
>
> My question is: is it possible to create them all in one batch and preview their changes in one single window?
>
> Cheers,
> Doru
>
>
> --
> www.tudorgirba.com
> www.feenk.com
>
> "If you interrupt the barber while he is cutting your hair,
> you will end up with a messy haircut."
>
>
>

--
www.tudorgirba.com
www.feenk.com

"No matter how many recipes we know, we still value a chef."










Reply | Threaded
Open this post in threaded view
|

Re: how to add a class via programatic refactoring

Tudor Girba-2
And you can see and reason about changes before applying it :)

For example, in the latest GTInspector (not yet in Pharo), you can preview changes right in the inspector:


Cheers,
Doru


On Feb 9, 2016, at 4:47 PM, stepharo <[hidden email]> wrote:

It checks that the class does not already exist. 
And check the preconditions. 

Le 9/2/16 16:41, Peter Uhnák a écrit :
What's the practical difference between calling

```
(RBAddClassRefactoring
                addClass: #SomeClass
                superclass: #Object
                subclasses: {}
                category: #Category) primitiveExecute; changes.
```
and
```
Object subclass: #SomeClass
instanceVariableNames: ''
classVariableNames: ''
package: 'Category'
```

likewise for the attribute?

I am doing source code generation in one project and using the latter approach, so I am curious about the benefit of the first one.

Thanks,
Peter


On Mon, Feb 8, 2016 at 12:22 PM, Tudor Girba <[hidden email]> wrote:
Great! Thanks a lot.

Doru


> On Feb 8, 2016, at 10:57 AM, Nicolai Hess <[hidden email]> wrote:
>
> Not the best way maybe:
>
>     | model refactoring1 refactoring2 browser |
>     model := RBNamespace onEnvironment: RBBrowserEnvironment new.
>     refactoring1 := RBAddClassRefactoring
>         model: model
>         addClass: #SomeClass
>         superclass: #Object
>         subclasses: {}
>         category: #Category.
>     refactoring1 primitiveExecute.
>     refactoring2 := RBAddInstanceVariableRefactoring
>         model: model
>         variable: 'x'
>         class: #SomeClass.
>     refactoring2 primitiveExecute.
>     browser := ChangesBrowser new.
>     browser changesTree roots: (model changes whatToDisplayIn: browser).
>     browser open
>
>
>
> 2016-02-07 22:24 GMT+01:00 Tudor Girba <[hidden email]>:
> Hi,
>
> I would like to create a class with instance variables and methods using RB, and preview the changes with the changes browser.
>
> I know how to create AddClass, AddInstanceVariable, AddMethod refactorings individually and query for their changes. For example:
>
> (RBAddClassRefactoring
>                 addClass: #SomeClass
>                 superclass: #Object
>                 subclasses: {}
>                 category: #Category) primitiveExecute; changes.
>
> (RBAddInstanceVariableRefactoring
>         variable: 'x'
>         class: #SomeClass) primitiveExecute; changes
>
> My question is: is it possible to create them all in one batch and preview their changes in one single window?
>
> Cheers,
> Doru
>
>
> --
> www.tudorgirba.com
> www.feenk.com
>
> "If you interrupt the barber while he is cutting your hair,
> you will end up with a messy haircut."
>
>
>

--
www.tudorgirba.com
www.feenk.com

"No matter how many recipes we know, we still value a chef."











--
www.tudorgirba.com
www.feenk.com

"There are no old things, there are only old ways of looking at them."




Reply | Threaded
Open this post in threaded view
|

Re: how to add a class via programatic refactoring

Sven Van Caekenberghe-2
Cool !

It keeps on coming, where will it end ;-)

> On 09 Feb 2016, at 22:01, Tudor Girba <[hidden email]> wrote:
>
> And you can see and reason about changes before applying it :)
>
> For example, in the latest GTInspector (not yet in Pharo), you can preview changes right in the inspector:
>
> <previewchanges.png>
>
> Cheers,
> Doru
>
>
>> On Feb 9, 2016, at 4:47 PM, stepharo <[hidden email]> wrote:
>>
>> It checks that the class does not already exist.
>> And check the preconditions.
>>
>> Le 9/2/16 16:41, Peter Uhnák a écrit :
>>> What's the practical difference between calling
>>>
>>> ```
>>> (RBAddClassRefactoring
>>>                 addClass: #SomeClass
>>>                 superclass: #Object
>>>                 subclasses: {}
>>>                 category: #Category) primitiveExecute; changes.
>>> ```
>>> and
>>> ```
>>> Object subclass: #SomeClass
>>> instanceVariableNames: ''
>>> classVariableNames: ''
>>> package: 'Category'
>>> ```
>>>
>>> likewise for the attribute?
>>>
>>> I am doing source code generation in one project and using the latter approach, so I am curious about the benefit of the first one.
>>>
>>> Thanks,
>>> Peter
>>>
>>>
>>> On Mon, Feb 8, 2016 at 12:22 PM, Tudor Girba <[hidden email]> wrote:
>>> Great! Thanks a lot.
>>>
>>> Doru
>>>
>>>
>>> > On Feb 8, 2016, at 10:57 AM, Nicolai Hess <[hidden email]> wrote:
>>> >
>>> > Not the best way maybe:
>>> >
>>> >     | model refactoring1 refactoring2 browser |
>>> >     model := RBNamespace onEnvironment: RBBrowserEnvironment new.
>>> >     refactoring1 := RBAddClassRefactoring
>>> >         model: model
>>> >         addClass: #SomeClass
>>> >         superclass: #Object
>>> >         subclasses: {}
>>> >         category: #Category.
>>> >     refactoring1 primitiveExecute.
>>> >     refactoring2 := RBAddInstanceVariableRefactoring
>>> >         model: model
>>> >         variable: 'x'
>>> >         class: #SomeClass.
>>> >     refactoring2 primitiveExecute.
>>> >     browser := ChangesBrowser new.
>>> >     browser changesTree roots: (model changes whatToDisplayIn: browser).
>>> >     browser open
>>> >
>>> >
>>> >
>>> > 2016-02-07 22:24 GMT+01:00 Tudor Girba <[hidden email]>:
>>> > Hi,
>>> >
>>> > I would like to create a class with instance variables and methods using RB, and preview the changes with the changes browser.
>>> >
>>> > I know how to create AddClass, AddInstanceVariable, AddMethod refactorings individually and query for their changes. For example:
>>> >
>>> > (RBAddClassRefactoring
>>> >                 addClass: #SomeClass
>>> >                 superclass: #Object
>>> >                 subclasses: {}
>>> >                 category: #Category) primitiveExecute; changes.
>>> >
>>> > (RBAddInstanceVariableRefactoring
>>> >         variable: 'x'
>>> >         class: #SomeClass) primitiveExecute; changes
>>> >
>>> > My question is: is it possible to create them all in one batch and preview their changes in one single window?
>>> >
>>> > Cheers,
>>> > Doru
>>> >
>>> >
>>> > --
>>> > www.tudorgirba.com
>>> > www.feenk.com
>>> >
>>> > "If you interrupt the barber while he is cutting your hair,
>>> > you will end up with a messy haircut."
>>> >
>>> >
>>> >
>>>
>>> --
>>> www.tudorgirba.com
>>> www.feenk.com
>>>
>>> "No matter how many recipes we know, we still value a chef."
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>
> --
> www.tudorgirba.com
> www.feenk.com
>
> "There are no old things, there are only old ways of looking at them."
>
>
>
>