-
-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8901 from gcorriga/2586-Deleting-a-class-with-ref…
…erences-gives-extra-Do-you-want-to-delete-anyway-msg 2586 deleting a class with references gives extra do you want to delete anyway msg
- Loading branch information
Showing
29 changed files
with
661 additions
and
112 deletions.
There are no files selected for viewing
This file contains 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 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
5 changes: 5 additions & 0 deletions
5
src/Calypso-NavigationModel-Tests/ClyQueryResultTest.class.st
This file contains 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,5 @@ | ||
Class { | ||
#name : #ClyQueryResultTest, | ||
#superclass : #TestCase, | ||
#category : #'Calypso-NavigationModel-Tests-Result' | ||
} |
This file contains 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 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 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
26 changes: 26 additions & 0 deletions
26
src/Calypso-SystemQueries-Tests/ClyClassExternalReferencesQueryTest.class.st
This file contains 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,26 @@ | ||
Class { | ||
#name : #ClyClassExternalReferencesQueryTest, | ||
#superclass : #ClyMethodQueryTestCase, | ||
#category : #'Calypso-SystemQueries-Tests-Queries' | ||
} | ||
|
||
{ #category : #running } | ||
ClyClassExternalReferencesQueryTest >> createQuery [ | ||
^ ClyClassExternalReferencesQuery | ||
to: self referencedClass | ||
from: (ClyClassScope of: Object in: environment) | ||
] | ||
|
||
{ #category : #running } | ||
ClyClassExternalReferencesQueryTest >> referencedClass [ | ||
"Use an explicit reference instead of 'self class'" | ||
^ClyClassExternalReferencesQueryTest | ||
] | ||
|
||
{ #category : #tests } | ||
ClyClassExternalReferencesQueryTest >> testFromSystemScope [ | ||
|
||
self queryFromScope: ClySystemEnvironmentScope of: ClySystemEnvironment currentImage. | ||
"Expect the query to be empty even though the class references itself in #referencedClass" | ||
self assert: resultItems isEmpty | ||
] |
14 changes: 14 additions & 0 deletions
14
src/Calypso-SystemQueries/ClyClassExternalReferencesQuery.class.st
This file contains 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,14 @@ | ||
Class { | ||
#name : #ClyClassExternalReferencesQuery, | ||
#superclass : #ClyClassReferencesQuery, | ||
#category : #'Calypso-SystemQueries-Queries' | ||
} | ||
|
||
{ #category : #execution } | ||
ClyClassExternalReferencesQuery >> buildResult: aQueryResult [ | ||
| toExclude | | ||
|
||
super buildResult: aQueryResult. | ||
toExclude := self variableQuery resultItems flatCollect: [ :each | { each . each classSide } ]. | ||
aQueryResult items removeAllSuchThat: [ :each | toExclude includes: each origin ] | ||
] |
This file contains 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 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
18 changes: 18 additions & 0 deletions
18
...so-SystemTools-QueryBrowser-Tests/ClyNotRemoveAndShowReferencesClassStrategyTest.class.st
This file contains 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,18 @@ | ||
" | ||
A ClyNotRemoveAndShowReferencesClassStrategyTest is a test class for testing the behavior of ClyNotRemoveAndShowReferencesClassStrategy | ||
" | ||
Class { | ||
#name : #ClyNotRemoveAndShowReferencesClassStrategyTest, | ||
#superclass : #TestCase, | ||
#category : #'Calypso-SystemTools-QueryBrowser-Tests-Commands-Classes' | ||
} | ||
|
||
{ #category : #tests } | ||
ClyNotRemoveAndShowReferencesClassStrategyTest >> testExecutingCommand [ | ||
| browser command strategy | | ||
browser := MockClyBrowser new. | ||
strategy := ClyNotRemoveAndShowReferencesClassStrategy newForBrowser: browser. | ||
command := SycRemoveClassCommand for: { SycRemoveClassCommand }. | ||
strategy execute: command. | ||
self assert: browser hasSpawnedQueryBrowser | ||
] |
18 changes: 18 additions & 0 deletions
18
...so-SystemTools-QueryBrowser-Tests/ClyNotRemoveAndShowSubclassesClassStrategyTest.class.st
This file contains 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,18 @@ | ||
" | ||
A ClyNotRemoveAndShowSubclassesClassStrategyTest is a test class for testing the behavior of ClyNotRemoveAndShowSubclassesClassStrategy | ||
" | ||
Class { | ||
#name : #ClyNotRemoveAndShowSubclassesClassStrategyTest, | ||
#superclass : #TestCase, | ||
#category : #'Calypso-SystemTools-QueryBrowser-Tests-Commands-Classes' | ||
} | ||
|
||
{ #category : #tests } | ||
ClyNotRemoveAndShowSubclassesClassStrategyTest >> testExecutingCommand [ | ||
| browser command strategy | | ||
browser := MockClyBrowser new. | ||
strategy := ClyNotRemoveAndShowSubclassesClassStrategy newForBrowser: browser. | ||
command := SycRemoveClassCommand for: { ClyInteractiveRemoveClassStrategy }. | ||
strategy execute: command. | ||
self assert: (browser hasSpawnedQueryBrowserOn: ClyInteractiveRemoveClassStrategy allSubclasses) | ||
] |
18 changes: 18 additions & 0 deletions
18
...Calypso-SystemTools-QueryBrowser-Tests/ClyNotRemoveAndShowUsersClassStrategyTest.class.st
This file contains 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,18 @@ | ||
" | ||
A ClyNotRemoveAndShowUsersClassStrategyTest is a test class for testing the behavior of ClyNotRemoveAndShowUsersClassStrategy | ||
" | ||
Class { | ||
#name : #ClyNotRemoveAndShowUsersClassStrategyTest, | ||
#superclass : #TestCase, | ||
#category : #'Calypso-SystemTools-QueryBrowser-Tests-Commands-Classes' | ||
} | ||
|
||
{ #category : #tests } | ||
ClyNotRemoveAndShowUsersClassStrategyTest >> testExecutingCommand [ | ||
| browser command strategy | | ||
browser := MockClyBrowser new. | ||
strategy := ClyNotRemoveAndShowUsersClassStrategy newForBrowser: browser. | ||
command := SycRemoveClassCommand for: { TRBProgramNodeVisitor }. | ||
strategy execute: command. | ||
self assert: (browser hasSpawnedQueryBrowserOn: TRBProgramNodeVisitor users) | ||
] |
34 changes: 34 additions & 0 deletions
34
src/Calypso-SystemTools-QueryBrowser-Tests/MockClyBrowser.class.st
This file contains 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,34 @@ | ||
Class { | ||
#name : #MockClyBrowser, | ||
#superclass : #Object, | ||
#instVars : [ | ||
'hasSpawned', | ||
'elements' | ||
], | ||
#category : #'Calypso-SystemTools-QueryBrowser-Tests-Commands-Classes' | ||
} | ||
|
||
{ #category : #testing } | ||
MockClyBrowser >> hasSpawnedQueryBrowser [ | ||
|
||
^hasSpawned | ||
] | ||
|
||
{ #category : #testing } | ||
MockClyBrowser >> hasSpawnedQueryBrowserOn: aCollection [ | ||
|
||
^hasSpawned and: [ elements resultItems asArray = aCollection asArray ] | ||
] | ||
|
||
{ #category : #initialization } | ||
MockClyBrowser >> initialize [ | ||
|
||
hasSpawned := false | ||
] | ||
|
||
{ #category : #mocking } | ||
MockClyBrowser >> spawnQueryBrowserOn: aCollection [ | ||
|
||
hasSpawned := true. | ||
elements := aCollection | ||
] |
37 changes: 37 additions & 0 deletions
37
src/Calypso-SystemTools-QueryBrowser/ClyInteractiveRemoveClassStrategy.class.st
This file contains 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,37 @@ | ||
" | ||
I am the abstract strategy to be used in those cases where a class can't be removed. | ||
My concrete subclasses allow the users to browse the references, subclasses, or users preventing the removal of the class. | ||
" | ||
Class { | ||
#name : #ClyInteractiveRemoveClassStrategy, | ||
#superclass : #SycRemoveClassStrategy, | ||
#instVars : [ | ||
'browser' | ||
], | ||
#category : #'Calypso-SystemTools-QueryBrowser-Commands-Classes' | ||
} | ||
|
||
{ #category : #testing } | ||
ClyInteractiveRemoveClassStrategy class >> isAbstract [ | ||
^self == ClyInteractiveRemoveClassStrategy | ||
] | ||
|
||
{ #category : #'instance creation' } | ||
ClyInteractiveRemoveClassStrategy class >> newForBrowser: aBrowser [ | ||
|
||
^self new | ||
browser: aBrowser | ||
] | ||
|
||
{ #category : #accessing } | ||
ClyInteractiveRemoveClassStrategy >> browser [ | ||
|
||
^ browser | ||
] | ||
|
||
{ #category : #accessing } | ||
ClyInteractiveRemoveClassStrategy >> browser: anObject [ | ||
|
||
browser := anObject | ||
] |
31 changes: 31 additions & 0 deletions
31
src/Calypso-SystemTools-QueryBrowser/ClyNotRemoveAndShowReferencesClassStrategy.class.st
This file contains 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,31 @@ | ||
" | ||
I am the strategy to be used when a class can't be removed due to the presence of references. | ||
I allow the user to browse those references. | ||
" | ||
Class { | ||
#name : #ClyNotRemoveAndShowReferencesClassStrategy, | ||
#superclass : #ClyInteractiveRemoveClassStrategy, | ||
#category : #'Calypso-SystemTools-QueryBrowser-Commands-Classes' | ||
} | ||
|
||
{ #category : #testing } | ||
ClyNotRemoveAndShowReferencesClassStrategy class >> canExecuteWithReferences: hasReferences subclasses: hasSubclasses users: hasUsers [ | ||
^hasReferences | ||
] | ||
|
||
{ #category : #execution } | ||
ClyNotRemoveAndShowReferencesClassStrategy >> execute: aSycRemoveClassCommand [ | ||
|
||
(ClyShowClassRefCommand forClasses: (aSycRemoveClassCommand classes flatCollect: [ :each | { each. each class } ]) by: browser) execute | ||
] | ||
|
||
{ #category : #execution } | ||
ClyNotRemoveAndShowReferencesClassStrategy >> orderForBrowser [ | ||
^5 | ||
] | ||
|
||
{ #category : #execution } | ||
ClyNotRemoveAndShowReferencesClassStrategy >> userRequestString [ | ||
^'Don''t remove, but show me those references' | ||
] |
Oops, something went wrong.