SystemOrganization addCategory: #'OB-Refactory'! !OBCodeBrowser methodsFor: '*ob-refactory' stamp: 'lr 2/5/2007 10:33'! cmdMethodRefactroing ^ OBMethodRefactoring allSubclasses! ! OBCommand subclass: #OBRefactoring instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'OB-Refactory'! OBRefactoring subclass: #OBMethodRefactoring instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'OB-Refactory'! OBMethodRefactoring subclass: #OBAddParameterMethodRefactroing instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'OB-Refactory'! !OBAddParameterMethodRefactroing methodsFor: 'accessing' stamp: 'lr 1/22/2007 09:04'! label ^ 'add parameter'! ! !OBAddParameterMethodRefactroing methodsFor: 'accessing' stamp: 'lr 1/22/2007 09:00'! refactoring | initializer newSelector initialAnswer | initialAnswer := target selector numArgs = 0 ifTrue: [ target selector , ':' ] ifFalse: [ target selector ]. newSelector := self request: 'Enter new selector:' initialAnswer: initialAnswer. newSelector isEmpty ifTrue: [ ^ nil ]. initializer := self request: 'Enter default value for parameter:' initialAnswer: 'nil'. initializer isEmpty ifTrue: [ ^ nil ]. ^ AddParameterRefactoring addParameterToMethod: target selector in: target theClass newSelector: newSelector asSymbol initializer: initializer! ! OBMethodRefactoring subclass: #OBInlineSelfSendsMethodRefactroing instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'OB-Refactory'! !OBInlineSelfSendsMethodRefactroing methodsFor: 'accessing' stamp: 'lr 1/22/2007 09:07'! label ^ 'inline self sends'! ! !OBInlineSelfSendsMethodRefactroing methodsFor: 'accessing' stamp: 'lr 1/22/2007 09:09'! refactoring ^ InlineAllSendersRefactoring sendersOf: target selector in: target theClass! ! !OBMethodRefactoring methodsFor: 'testing' stamp: 'lr 2/5/2007 10:33'! isActive ^ target hasSelector and: [ requestor isSelected: target ]! ! OBMethodRefactoring subclass: #OBPushDownMethodRefactroing instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'OB-Refactory'! !OBPushDownMethodRefactroing methodsFor: 'accessing' stamp: 'lr 1/22/2007 08:34'! label ^ 'push down'! ! !OBPushDownMethodRefactroing methodsFor: 'accessing' stamp: 'lr 1/22/2007 09:00'! refactoring ^ PushDownMethodRefactoring pushDown: (Array with: target selector) from: target theClass! ! OBMethodRefactoring subclass: #OBPushUpMethodRefactroing instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'OB-Refactory'! !OBPushUpMethodRefactroing methodsFor: 'accessing' stamp: 'lr 1/22/2007 08:34'! label ^ 'push up'! ! !OBPushUpMethodRefactroing methodsFor: 'accessing' stamp: 'lr 1/22/2007 09:00'! refactoring ^ PushUpMethodRefactoring pushUp: (Array with: target selector) from: target theClass! ! OBMethodRefactoring subclass: #OBRenameMethodRefactroing instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'OB-Refactory'! !OBRenameMethodRefactroing methodsFor: 'accessing' stamp: 'lr 1/22/2007 09:07'! label ^ 'rename method'! ! !OBRenameMethodRefactroing methodsFor: 'accessing' stamp: 'lr 1/22/2007 09:20'! refactoring | oldMethodName newMethodName oldArguments argumentPermutation | oldArguments := (RBParser parseMethod: (target theClass methodHeaderFor: target selector)) argumentNames. oldMethodName := RBMethodName selector: target selector arguments: oldArguments. (newMethodName := MethodNameEditor forMethodName: oldMethodName) ifNil: [ ^ nil ]. argumentPermutation := newMethodName arguments collect: [ :each | oldArguments indexOf: each ]. ^ RenameMethodRefactoring renameMethod: target selector in: target theClass to: newMethodName selector permutation: argumentPermutation! ! OBMethodRefactoring subclass: #OBSafeRemoveMethodRefactroing instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'OB-Refactory'! !OBSafeRemoveMethodRefactroing methodsFor: 'accessing' stamp: 'lr 1/22/2007 09:07'! label ^ 'safe remove'! ! !OBSafeRemoveMethodRefactroing methodsFor: 'accessing' stamp: 'lr 1/22/2007 09:10'! refactoring ^ RemoveMethodRefactoring removeMethods: (Array with: target selector) from: target theClass! ! !OBRefactoring methodsFor: 'utilities' stamp: 'lr 1/22/2007 08:49'! confirm: aString ^ OBConfirmationRequest prompt: aString confirm: 'Yes' cancel: 'No'! ! !OBRefactoring methodsFor: 'execution' stamp: 'lr 1/22/2007 08:59'! execute | refactoring | refactoring := self refactoring ifNil: [ ^ self ]. self handleError: [ refactoring execute ]! ! !OBRefactoring methodsFor: 'accessing' stamp: 'lr 1/22/2007 08:24'! group ^ #refactory! ! !OBRefactoring methodsFor: 'utilities' stamp: 'lr 1/22/2007 08:49'! handleError: aBlock ^ [ Cursor wait showWhile: aBlock ] on: Refactoring preconditionSignal do: [ :ex | ex isResumable ifTrue: [ (self confirm: (ex messageText last == $? ifTrue: [ ex messageText ] ifFalse: [ ex messageText , '\Do you want to proceed?' withCRs ])) ifTrue: [ ex resume ] ] ifFalse: [ ex parameter notNil ifTrue: [ (self confirm: ex messageText) ifTrue: [ ex parameter value ] ] ifFalse: [ self inform: ex messageText ] ]. ex return: nil ]! ! !OBRefactoring methodsFor: 'accessing' stamp: 'lr 1/22/2007 08:58'! refactoring self subclassResponsibility! ! !OBRefactoring methodsFor: 'utilities' stamp: 'lr 1/22/2007 09:18'! request: promptString initialAnswer: templateString ^ OBTextRequest prompt: promptString template: templateString! !