Skip to content

Commit

Permalink
Merge pull request #8207 from Lin777/FixPushUpIssue
Browse files Browse the repository at this point in the history
RB - Fix push up sharedPools issue
  • Loading branch information
Ducasse committed Jan 1, 2021
2 parents 3e55a3d + 924d0fd commit 806f778
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/Kernel/Class.class.st
Expand Up @@ -155,6 +155,16 @@ Class >> addSharedPool: aSharedPool [
ifFalse: [self sharedPools add: aSharedPool]
]

{ #category : #'pool variables' }
Class >> addSharedPoolNamed: aSharedPoolName [

|poolClass|
poolClass := aSharedPoolName asClassIfAbsent: [nil].
poolClass isPool
ifTrue: [ self addSharedPool: poolClass ]
ifFalse: [ self error: 'The specified class is not pool.' ]
]

{ #category : #'accessing class hierarchy' }
Class >> addSubclass: aSubclass [
"Make the argument, aSubclass, be one of the subclasses of the receiver.
Expand Down
2 changes: 1 addition & 1 deletion src/Refactoring-Changes/RBAddPoolVariableChange.class.st
Expand Up @@ -27,5 +27,5 @@ RBAddPoolVariableChange >> changeString [

{ #category : #private }
RBAddPoolVariableChange >> changeSymbol [
^ #addSharedPool:
^ #addSharedPoolNamed:
]
28 changes: 28 additions & 0 deletions src/Refactoring-Tests-Core/RBPullUpMethodTest.class.st
Expand Up @@ -16,6 +16,17 @@ RBPullUpMethodTest >> addClassHierarchy [
defineClass: 'Subclass subclass: #Foo2 instanceVariableNames: '''' classVariableNames: '''' poolDictionaries: '''' category: #''Refactory-Test data'''.
]

{ #category : #tests }
RBPullUpMethodTest >> addClassHierarchyForPools [
model
defineClass: 'SharedPool subclass: #TotoSharedPool instanceVariableNames: '''' classVariableNames: ''SP'' poolDictionaries: '''' category: #''Refactory-Test data'''.
model
defineClass: 'Object subclass: #TotoSuperclass instanceVariableNames: '''' classVariableNames: '''' poolDictionaries: '''' category: #''Refactory-Test data'''.
model
defineClass: 'TotoSuperclass subclass: #Toto instanceVariableNames: '''' classVariableNames: '''' poolDictionaries: '''' category: #''Refactory-Test data'''.
(model classNamed: #Toto) compile: 'poolReference ^ SP' classified: #(#accessing).
]

{ #category : #tests }
RBPullUpMethodTest >> testPullUpAndCopyDown [
| class |
Expand Down Expand Up @@ -86,6 +97,23 @@ RBPullUpMethodTest >> testPullUpMethodWithCopyOverriddenMethodsDown [
self deny: ((refactoring model classNamed: #RBCompositeLintRuleTestData) directlyDefinesMethod: #isComposite)
]

{ #category : #tests }
RBPullUpMethodTest >> testPullUpMethodWithSharedPool [
| class superClass |

self addClassHierarchyForPools.
class := model classNamed: #Toto.
superClass := model classNamed: #TotoSuperclass.
self executeRefactoring: (RBPullUpMethodRefactoring
model: model
pullUp: #(#poolReference)
from: class
to: superClass ).
self assert: (superClass parseTreeFor: #poolReference)
equals: (self parseMethod: 'poolReference ^ SP').
self deny: (class directlyDefinesMethod: #poolReference).
]

{ #category : #'failure tests' }
RBPullUpMethodTest >> testPullUpReferencesInstVar [
self shouldFail: (RBPullUpMethodRefactoring
Expand Down

0 comments on commit 806f778

Please sign in to comment.