Skip to content

Commit

Permalink
Merge pull request #15225 from balsa-sarenac/feat/add-override-method
Browse files Browse the repository at this point in the history
Feat: Add Override method transformation
  • Loading branch information
Ducasse committed Nov 4, 2023
2 parents 64ab2a4 + 955cc99 commit e42eeea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/Refactoring-Core/RBAddOverrideMethodTransformation.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"
I am a subclass of Add Method Refactoring that loosens preconditions.
Add Method has the breaking change that methods should not be defined in the target class or its superclasses.
Add Override Method allows Refactoring to create a method in a class that can override a superclass method, but it does not allow overwrite of a method that is directly defined in that class.
"
Class {
#name : 'RBAddOverrideMethodTransformation',
#superclass : 'RBAddMethodRefactoring',
#category : 'Refactoring-Core-Refactorings',
#package : 'Refactoring-Core',
#tag : 'Refactorings'
}

{ #category : 'preconditions' }
RBAddOverrideMethodTransformation >> preconditions [

^ (RBCondition definesSelector: transformation selector in: class) not
]
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ RBAddVariableAccessorTransformation >> defineSetterMethod [
| sourceCode |
sourceCode := '<1s> anObject<r><r><t><2s> := anObject'.
setterMethod := self safeMethodNameFor: self definingClass basedOn: variableName asString , ':'.
(RBAddMethodTransformation
(RBAddMethodTransformation
model: self model
sourceCode: (sourceCode expandMacrosWith: setterMethod with: variableName)
in: self definingClass
Expand Down

0 comments on commit e42eeea

Please sign in to comment.