-
-
Notifications
You must be signed in to change notification settings - Fork 399
[Refactorings] Implement Driver for PushDownSharedVariable #18600
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
Open
carolahp
wants to merge
11
commits into
pharo-project:Pharo14
Choose a base branch
from
carolahp:feat/push-down-shared-variable-driver
base: Pharo14
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+425
−91
Open
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b06815d
feat: Implement Driver for PushDownSharedVariable
carolahp e85c36f
Merge branch 'Pharo14' into feat/push-down-shared-variable-driver
carolahp 4a58dec
fix: testNoEquivalentSuperclassMethods for release
carolahp 7209fab
Merge e85c36f8fe4cf397d1683a2de814dac83990182d
carolahp 6f60877
feat: NegationCondition>>not returns its condition, preventing multip…
carolahp 5e51896
Merge branch 'Pharo14' into feat/push-down-shared-variable-driver
carolahp 5cbc3a7
fix: Failing tests for pullUpMethod transformations
carolahp bec9614
fix: Remove redundant method
carolahp 2e8bf7d
Merge branch 'Pharo14' into feat/push-down-shared-variable-driver
carolahp e14d836
Merge branch 'Pharo14' into feat/push-down-shared-variable-driver
carolahp e2861b4
Merge branch 'Pharo14' into feat/push-down-shared-variable-driver
carolahp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
src/Calypso-SystemTools-FullBrowser/SycPushDownVariableCommand2.extension.st
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| Extension { #name : 'SycPushDownVariableCommand2' } | ||
|
|
||
| { #category : '*Calypso-SystemTools-FullBrowser' } | ||
| SycPushDownVariableCommand2 class >> fullBrowserMenuActivation [ | ||
| <classAnnotation> | ||
|
|
||
| ^CmdContextMenuActivation byRootGroupItemOrder: 2002 for: ClyFullBrowserVariableContext | ||
| ] |
29 changes: 29 additions & 0 deletions
29
src/Refactoring-Core/ReClassesHaveAnySubclassCondition.class.st
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| Class { | ||
| #name : 'ReClassesHaveAnySubclassCondition', | ||
| #superclass : 'ReClassesCondition', | ||
| #category : 'Refactoring-Core-Conditions', | ||
| #package : 'Refactoring-Core', | ||
| #tag : 'Conditions' | ||
| } | ||
|
|
||
| { #category : 'testing' } | ||
| ReClassesHaveAnySubclassCondition >> hasSubclasses: aClass [ | ||
|
|
||
| ^ aClass subclasses isNotEmpty | ||
| ] | ||
|
|
||
| { #category : 'displaying' } | ||
| ReClassesHaveAnySubclassCondition >> violationMessageOn: aStream [ | ||
|
|
||
| self violators do: [ :violator | | ||
| aStream | ||
| nextPutAll: violator name; | ||
| nextPutAll: ' has no subclasses.'; | ||
| space ] | ||
| ] | ||
|
|
||
| { #category : 'accessing' } | ||
| ReClassesHaveAnySubclassCondition >> violators [ | ||
|
|
||
| ^ violators ifNil: [ violators := classes reject: [ :aClass | self hasSubclasses: aClass ] ] | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/Refactoring-Core/RePushDownSharedVariableRefactoring.class.st
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| " | ||
| I am a refactoring for moving a class variable down to my subclasses. | ||
|
|
||
| My precondition verifies that the moved variable is not referenced in the methods of the original class. | ||
| " | ||
| Class { | ||
| #name : 'RePushDownSharedVariableRefactoring', | ||
| #superclass : 'RBVariableRefactoring', | ||
| #category : 'Refactoring-Core-Refactorings', | ||
| #package : 'Refactoring-Core', | ||
| #tag : 'Refactorings' | ||
| } | ||
|
|
||
| { #category : 'preconditions' } | ||
| RePushDownSharedVariableRefactoring >> applicabilityPreconditions [ | ||
|
|
||
| ^ { | ||
| (RBCondition definesClassVariable: variableName in: class). | ||
| (ReClassesHaveAnySubclassCondition new classes: { class }) } | ||
| ] | ||
|
|
||
| { #category : 'preconditions' } | ||
| RePushDownSharedVariableRefactoring >> breakingChangePreconditions [ | ||
|
|
||
| ^ { self preconditionHasNoReferences } | ||
| ] | ||
|
|
||
| { #category : 'preconditions' } | ||
| RePushDownSharedVariableRefactoring >> findDestinationClasses [ | ||
|
|
||
| | classes | | ||
| classes := class allSubclasses reject: [ :each | | ||
| (each whichSelectorsReferToClassVariable: variableName) isEmpty | ||
| and: [ (each classSide whichSelectorsReferToClassVariable: variableName) isEmpty ] ]. | ||
| ^ classes | ||
| ] | ||
|
|
||
| { #category : 'preconditions' } | ||
| RePushDownSharedVariableRefactoring >> preconditionHasNoReferences [ | ||
|
|
||
| ^ (ReSharedVariableHasReferencesInDefiningClass new class: class referencesToSharedVariable: variableName) not | ||
| ] | ||
|
|
||
| { #category : 'preconditions' } | ||
| RePushDownSharedVariableRefactoring >> preconditions [ | ||
|
|
||
| ^ self applicabilityPreconditions & self breakingChangePreconditions | ||
| ] | ||
|
|
||
| { #category : 'transforming' } | ||
| RePushDownSharedVariableRefactoring >> privateTransform [ | ||
|
|
||
| | destinationClasses | | ||
|
|
||
| class removeClassVariable: variableName. | ||
| destinationClasses := self findDestinationClasses. | ||
| destinationClasses ifEmpty: [ ^ self ]. | ||
| destinationClasses do: [ :aClass | aClass addClassVariable: variableName ] | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/Refactoring-Core/ReSharedVariableHasReferencesInDefiningClass.class.st
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| " | ||
| I check if a Shared Variable is referenced from methods in the class that defines it. | ||
| " | ||
| Class { | ||
| #name : 'ReSharedVariableHasReferencesInDefiningClass', | ||
| #superclass : 'ReVariableCondition', | ||
| #category : 'Refactoring-Core-Conditions', | ||
| #package : 'Refactoring-Core', | ||
| #tag : 'Conditions' | ||
| } | ||
|
|
||
| { #category : 'checking' } | ||
| ReSharedVariableHasReferencesInDefiningClass >> check [ | ||
|
|
||
| ^ self violators isNotEmpty | ||
| ] | ||
|
|
||
| { #category : 'initialization' } | ||
| ReSharedVariableHasReferencesInDefiningClass >> class: definingClass referencesToSharedVariable: aSharedVarName [ | ||
| aClass := definingClass. | ||
| variable := aSharedVarName | ||
| ] | ||
|
|
||
| { #category : 'accessing' } | ||
| ReSharedVariableHasReferencesInDefiningClass >> violatorCandidates [ | ||
|
|
||
| ^ aClass selectors, aClass classSide selectors | ||
| ] | ||
|
|
||
| { #category : 'accessing' } | ||
| ReSharedVariableHasReferencesInDefiningClass >> violators [ | ||
| | res | | ||
| violators ifNotNil: [ ^ violators ]. | ||
| violators := OrderedCollection new. | ||
| res := aClass whichMethodsReferToSharedVariable: variable. | ||
| res isNotEmpty | ||
| ifTrue: [ violators addAll: res ]. | ||
| res := (aClass classSide whichMethodsReferToSharedVariable: variable). | ||
| res isNotEmpty | ||
| ifTrue: [ violators addAll: res ]. | ||
| ^ violators | ||
| ] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be needed anymore, and should not be used anywhere. I think this will also fail if it is called because both calls return lists and we try to & them. I should probably do a cleanup and remove preconditions soon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I deleted it