Skip to content

Commit

Permalink
Replacing method command refactorings with transformations from Refac…
Browse files Browse the repository at this point in the history
…toring2,
  • Loading branch information
miguelcamp committed Jun 27, 2022
1 parent 6f6066f commit dc42048
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 26 deletions.
Expand Up @@ -34,7 +34,7 @@ SycMoveMethodsToClassCommand >> defaultMenuItemName [
{ #category : #execution }
SycMoveMethodsToClassCommand >> execute [
methods
collect: [ :each | RBMoveMethodToClassRefactoring model: model method: each class: targetClass ]
collect: [ :each | RBMoveMethodToClassTransformation model: model method: each class: targetClass ]
thenDo: [ :each | each execute ].
methods do: [ :each | each origin organization removeEmptyCategories ].
]
Expand Down
Expand Up @@ -27,6 +27,6 @@ SycMoveMethodsToClassSideCommand >> defaultMenuItemName [
SycMoveMethodsToClassSideCommand >> execute [

methods
collect: [ :each | RBMoveMethodToClassRefactoring model: model method: each class: each origin classSide]
collect: [ :each | RBMoveMethodToClassSideTransformation model: model method: each class: each origin classSide]
thenDo: [ :each | each execute ]
]
Expand Up @@ -27,6 +27,6 @@ SycMoveMethodsToInstanceSideCommand >> defaultMenuItemName [
SycMoveMethodsToInstanceSideCommand >> execute [

methods
collect: [ :each | RBMoveMethodToClassRefactoring model: model method: each class: each origin instanceSide]
collect: [ :each | RBMoveMethodToClassTransformation model: model method: each class: each origin instanceSide]
thenDo: [ :each | each execute ]
]
Expand Up @@ -11,7 +11,7 @@ Class {
SycPushDownMethodCommand >> asRefactorings [
"Return push down method refactoring using method"
| refactoring |
refactoring := RBPushDownMethodRefactoring
refactoring := RBPushDownMethodTransformation
model: model
pushDown: (methods collect: [ :each | each selector ])
from: methods first origin.
Expand Down
Expand Up @@ -11,7 +11,7 @@ Class {
SycPushDownMethodInSomeClassesCommand >> asRefactorings [
"Return push down method refactoring using method"
| refactoring |
refactoring := RBPushDownMethodRefactoring
refactoring := RBPushDownMethodTransformation
model: model
pushDown: (methods collect: [ :each | each selector ])
from: methods first origin
Expand Down
Expand Up @@ -13,7 +13,7 @@ Class {
{ #category : #execution }
SycPushUpMethodCommand >> asRefactorings [
| refactoring |
refactoring := RBPullUpMethodRefactoring
refactoring := RBPullUpMethodTransformation
model: model
pullUp: (methods collect: [ :each | each selector ])
from: methods first origin.
Expand Down
Expand Up @@ -11,7 +11,7 @@ Class {
{ #category : #converting }
SycRemoveHierarchyMethodCommand >> asRefactorings [
| refactoring |
refactoring := RBRemoveHierarchyMethodRefactoring
refactoring := RBRemoveHierarchyMethodTransformation
removeMethods: (methods collect: [:each | each selector])
from: methods first origin.
^ OrderedCollection with: refactoring
Expand Down
Expand Up @@ -7,28 +7,16 @@ Class {
#category : #'SystemCommands-MethodCommands'
}

{ #category : #removing }
SycSilentlyRemoveMethodStrategy >> collectMethodTagsFrom: methods [
"It will return map class->tags where tags are related to given methods"
| result tags |
result := IdentityDictionary new.
methods do: [ :each |
tags := result at: each origin ifAbsentPut: [IdentitySet new].
tags addAll: each tags].
^result
]

{ #category : #removing }
SycSilentlyRemoveMethodStrategy >> removeMethods: methods [

| methodTags |
methodTags := self collectMethodTagsFrom: methods. "we will remove empty tags of removed methods".

methods do: [ :each | each removeFromSystem ].

methodTags keysAndValuesDo: [:class :tags | tags do: [ :eachTag |
(class methodsTaggedWith: eachTag)
ifEmpty: [class removeMethodTag: eachTag] ]]
| refactorings |
refactorings := OrderedCollection new.
refactorings := methods collect: [ :each |
RBRemoveMethodTransformation
selector: each selector
from: each methodClass ].
refactorings do: [ :each | each asRefactoring execute ]
]

{ #category : #removing }
Expand Down

0 comments on commit dc42048

Please sign in to comment.