Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add Override method transformation #15225

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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