Skip to content

Commit

Permalink
Fixes #513 rename class - lose superfluous dialog
Browse files Browse the repository at this point in the history
Removed dialog & and make sure methods are still shown after rename
  • Loading branch information
Eric Winger authored and Eric Winger committed Aug 29, 2019
1 parent 83e7e7d commit b642ca7
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 62 deletions.
94 changes: 38 additions & 56 deletions sources/JadeiteProjectBrowserTestCase.cls
Original file line number Diff line number Diff line change
Expand Up @@ -1341,18 +1341,14 @@ test_classRenameNoReferences
superclass: 'Object'
instVars: #('inst1')
package: 'RowanSample1-Tests'.
TestMessageBox enableJadeiteTestMessageBox.

[self projectsPresenter selectClassNamed: 'TestClass'.
TestMessageBox plannedResult: #ok. "expect dialog box saying class was renamed"
self projectsPresenter basicRenameClass: self projectsPresenter selectedClass to: 'RenamedClass'.
self assertIsNil: (self classListPresenter list
detect: [:classService | classService name asString = 'TestClass']
ifNone: []).
self assert: self classListPresenter selection name equals: 'RenamedClass']
ensure:
[TestMessageBox disableJadeiteTestMessageBox.
self projectsPresenter basicRemoveClass: self classListPresenter selection]!
ensure: [self projectsPresenter basicRemoveClass: self classListPresenter selection]!

test_classRenameNoReferencesHierarchy
self testsIssue: #issue439 withTitle: '`rename` class menu item would be useful'.
Expand All @@ -1362,20 +1358,16 @@ test_classRenameNoReferencesHierarchy
superclass: 'Object'
instVars: #('inst1')
package: 'RowanSample1-Tests'.
TestMessageBox enableJadeiteTestMessageBox.

[self projectsPresenter selectClassNamed: 'TestClass'.
self selectHierarchyTab.
self assert: self classHierarchyPresenter selection name equals: 'TestClass'.
TestMessageBox plannedResult: #ok. "expect dialog box saying class was renamed"
self projectsPresenter basicRenameClass: self projectsPresenter selectedClass to: 'RenamedClass'.
self assertIsNil: (self classListPresenter list
detect: [:classService | classService name asString = 'TestClass']
ifNone: []).
self assert: self classHierarchyPresenter selection name equals: 'RenamedClass']
ensure:
[TestMessageBox disableJadeiteTestMessageBox.
self projectsPresenter basicRemoveClass: self projectsPresenter selectedClass]!
ensure: [self projectsPresenter basicRemoveClass: self projectsPresenter selectedClass]!

test_classRenameResetsClassDefinition
self testsIssue: #issue439 withTitle: '`rename` class menu item would be useful'.
Expand All @@ -1385,16 +1377,33 @@ test_classRenameResetsClassDefinition
superclass: 'Object'
instVars: #('inst1')
package: 'RowanSample1-Tests'.
TestMessageBox enableJadeiteTestMessageBox.

[self projectsPresenter selectClassNamed: 'TestClass'.
TestMessageBox plannedResult: #ok. "expect dialog box saying class was renamed"
self projectsPresenter basicRenameClass: self projectsPresenter selectedClass to: 'RenamedClass'.
self assert: ('*Object rwSubclass: ''RenamedClass''*'
match: self projectsPresenter classDefinitionPresenter value)]
ensure:
[TestMessageBox disableJadeiteTestMessageBox.
self projectsPresenter basicRemoveClass: self classListPresenter selection]!
ensure: [self projectsPresenter basicRemoveClass: self classListPresenter selection]!

test_classRenameShowsMethods
"don't lose the method display on rename"
| methodList |
self testsIssue: #issue439 withTitle: '`rename` class menu item would be useful'.
self selectRowanSample1Test.
self
saveClass: 'TestClass'
superclass: 'Object'
instVars: #('inst1')
package: 'RowanSample1-Tests'.

[self projectsPresenter selectClassNamed: 'TestClass'.
methodList := self methodListPresenter list.
self projectsPresenter basicRenameClass: self projectsPresenter selectedClass to: 'RenamedClass'.
self assertIsNil: (self classListPresenter list
detect: [:classService | classService name asString = 'TestClass']
ifNone: []).
self assert: self classListPresenter selection name equals: 'RenamedClass'.
self assert: self methodListPresenter list equals: methodList.]
ensure: [self projectsPresenter basicRemoveClass: self classListPresenter selection]!

test_classRenameWithReferences
| list |
Expand Down Expand Up @@ -3731,16 +3740,12 @@ test_renameClassMethodListUpdates
self assert: methodListBrowser primaryPresenter methodListPresenter methodListPresenter list first
className
equals: 'RowanSample1Test'.
TestMessageBox enableJadeiteTestMessageBox.
TestMessageBox plannedResult: #ok.
self projectsPresenter basicRenameClass: self classListPresenter selection to: 'TestClassWasRenamed'.

[self assert: methodListBrowser primaryPresenter methodListPresenter methodListPresenter list size
self assert: methodListBrowser primaryPresenter methodListPresenter methodListPresenter list size
equals: 1.
self assert: methodListBrowser primaryPresenter methodListPresenter methodListPresenter list first
className
equals: 'TestClassWasRenamed']
ensure: [TestMessageBox disableJadeiteTestMessageBox]!
equals: 'TestClassWasRenamed'!

test_renameClassShowsAsDefiniedInPackage
self testsIssue: #issue439 withTitle: '`rename` class menu item would be useful'.
Expand All @@ -3759,23 +3764,19 @@ test_renameClassShowsAsDefiniedInPackage
self selectServiceNamed: 'RowanSample1-Extensions' in: self packageListPresenter.
self selectServiceNamed: 'TestClassWasRenamed' in: self classListPresenter.
self assert: self classListPresenter selection isExtension.
self selectHierarchyTab.
self selectHierarchyTab.
self assert: self classHierarchyPresenter selection isExtension.
self assert: self classHierarchyPresenter selection name equals: 'TestClassWasRenamed'.
self selectClassListTab.

[TestMessageBox plannedResult: #ok.
self projectsPresenter basicRenameClass: self classListPresenter selection
to: 'TestClassWasRenamedAgain']
ensure: [TestMessageBox disableJadeiteTestMessageBox].
to: 'TestClassWasRenamedAgain'.
JadeiteRenameClassMethodListBrowser allInstances do: [:browser | browser view close]. "referenced methods browser is opened"
self assert: self classListPresenter selection isExtension.
self assert: self classListPresenter selection name equals: 'TestClassWasRenamedAgain'.
self selectHierarchyTab.
self selectHierarchyTab.
self assert: self classHierarchyPresenter selection isExtension.
self assert: self classHierarchyPresenter selection name equals: 'TestClassWasRenamedAgain'.
self selectClassListTab.
!
self selectClassListTab!

test_renameClassSUnitBrowserUpdates
| sunitBrowser |
Expand All @@ -3788,10 +3789,7 @@ test_renameClassSUnitBrowserUpdates
self assert: sunitBrowser primaryPresenter classListPresenter list size equals: 1.
self assert: sunitBrowser primaryPresenter classListPresenter list first name
equals: 'RowanSample1Test'.
TestMessageBox enableJadeiteTestMessageBox.
[TestMessageBox plannedResult: #ok.
self projectsPresenter basicRenameClass: self classListPresenter selection to: 'TestClassWasRenamed']
ensure: [TestMessageBox disableJadeiteTestMessageBox].
self projectsPresenter basicRenameClass: self classListPresenter selection to: 'TestClassWasRenamed'.
self assert: sunitBrowser primaryPresenter classListPresenter list size equals: 1.
self assert: sunitBrowser primaryPresenter classListPresenter list first name
equals: 'TestClassWasRenamed']
Expand All @@ -3801,20 +3799,13 @@ test_renameClassSwitchToHierarchyOk
self testsIssue: #issue439 withTitle: '`rename` class menu item would be useful'.
self testsIssue: #issue465 withTitle: '(3.067) error after rename class in hierarchy view'.
self selectRowanSample1Class.
TestMessageBox enableJadeiteTestMessageBox.

[TestMessageBox plannedResult: #ok.
self projectsPresenter basicRenameClass: self classListPresenter selection to: 'TestClassWasRenamed']
ensure: [TestMessageBox disableJadeiteTestMessageBox].
self projectsPresenter basicRenameClass: self classListPresenter selection to: 'TestClassWasRenamed'.
JadeiteRenameClassMethodListBrowser allInstances do: [:browser | browser view close]. "referenced methods browser is opened"
self assert: self classListPresenter selection name equals: 'TestClassWasRenamed'.
self selectHierarchyTab.
self assert: self classHierarchyPresenter selection name equals: 'TestClassWasRenamed'.

[TestMessageBox plannedResult: #ok.
self projectsPresenter basicRenameClass: self classListPresenter selection
to: 'TestClassWasRenamedAgain']
ensure: [TestMessageBox disableJadeiteTestMessageBox].
to: 'TestClassWasRenamedAgain'.
JadeiteRenameClassMethodListBrowser allInstances do: [:browser | browser view close]. "referenced methods browser is opened"
self assert: self classHierarchyPresenter selection name equals: 'TestClassWasRenamedAgain'.
self selectClassListTab.
Expand All @@ -3829,17 +3820,11 @@ test_renameClassUpdatedInSecondBrowser
self selectServiceNamed: 'RowanSample1-Core' in: secondPresenter packageListPresenter.
self selectServiceNamed: self sampleClassName in: secondPresenter classListPresenter.
self assert: self classListPresenter selection name equals: 'RowanSample1'.
self assert: secondPresenter classListPresenter selection name equals: 'RowanSample1'.
TestMessageBox enableJadeiteTestMessageBox.

[TestMessageBox plannedResult: #ok.
self projectsPresenter basicRenameClass: self classListPresenter selection to: 'TestClassWasRenamed']
ensure: [TestMessageBox disableJadeiteTestMessageBox].
self assert: secondPresenter classListPresenter selection name equals: 'RowanSample1'.
self projectsPresenter basicRenameClass: self classListPresenter selection to: 'TestClassWasRenamed'.
JadeiteRenameClassMethodListBrowser allInstances do: [:browser | browser view close]. "referenced methods browser is opened"
self assert: self classListPresenter selection name equals: 'TestClassWasRenamed'.
self assert: secondPresenter classListPresenter selection name equals: 'TestClassWasRenamed'.

!
self assert: secondPresenter classListPresenter selection name equals: 'TestClassWasRenamed'!

test_renameClassUpdatedInSecondBrowserHierarchy
self testsIssue: #issue439 withTitle: '`rename` class menu item would be useful'.
Expand All @@ -3852,11 +3837,7 @@ test_renameClassUpdatedInSecondBrowserHierarchy
self selectHierarchyTabIn: secondPresenter.
self assert: self classListPresenter selection name equals: 'RowanSample1'.
self assert: secondPresenter classListPresenter selection name equals: 'RowanSample1'.
TestMessageBox enableJadeiteTestMessageBox.

[TestMessageBox plannedResult: #ok.
self projectsPresenter basicRenameClass: self classListPresenter selection to: 'TestClassWasRenamed']
ensure: [TestMessageBox disableJadeiteTestMessageBox].
self projectsPresenter basicRenameClass: self classListPresenter selection to: 'TestClassWasRenamed'.
JadeiteRenameClassMethodListBrowser allInstances do: [:browser | browser view close]. "referenced methods browser is opened"
self assert: self classListPresenter selection name equals: 'TestClassWasRenamed'.
self assert: secondPresenter classListPresenter selection name equals: 'TestClassWasRenamed'!
Expand Down Expand Up @@ -5385,6 +5366,7 @@ waitForPresenter: presenter
!JadeiteProjectBrowserTestCase categoriesFor: #test_classRenameNoReferences!public!test rename class!tests! !
!JadeiteProjectBrowserTestCase categoriesFor: #test_classRenameNoReferencesHierarchy!public!test rename class!tests! !
!JadeiteProjectBrowserTestCase categoriesFor: #test_classRenameResetsClassDefinition!public!test rename class!tests! !
!JadeiteProjectBrowserTestCase categoriesFor: #test_classRenameShowsMethods!public!test rename class!tests! !
!JadeiteProjectBrowserTestCase categoriesFor: #test_classRenameWithReferences!public!test rename class!tests! !
!JadeiteProjectBrowserTestCase categoriesFor: #test_classRenameWithReferencesFailingCompile!public!test rename class!tests! !
!JadeiteProjectBrowserTestCase categoriesFor: #test_classRenameWithReferencesHierarchy!public!test rename class!tests! !
Expand Down
15 changes: 9 additions & 6 deletions sources/JadeiteProjectsBrowserPresenter.cls
Original file line number Diff line number Diff line change
Expand Up @@ -190,21 +190,24 @@ basicRenameClass: classService to: newName
command: #renameClass:to:;
commandArgs: (Array with: classService name with: newName).
[serviceArray := self issueCommand: (Array with: classService)] on: GsCompileError
do: [:ex | ^MessageBox notify: 'Compilation error during rename class. Class may be referenced in its hierarchy"
do:
[:ex |
^MessageBox
notify: 'Compilation error during rename class. Class may be referenced in its hierarchy"
' , ex descriptiveText].
'
, ex descriptiveText].
self updateServices: packageListPresenter selections.
self refreshClassListOrHierarchy.
classListPresenter resetSelection.
self selectClassNamed: newName.
(serviceArray detect: [:service | service isAnsweringService]) answer isEmpty
ifTrue: [^MessageBox notify: 'No methods updated after renaming ' , oldName , ' to ' , newName].
(serviceArray detect: [:service | service isAnsweringService]) answer isEmpty ifTrue: [^self].
browser := JadeiteRenameClassMethodListBrowser showOnSession: gciSession.
browser primaryPresenter
findString: newName;
newClassName: newName.
answeringService := serviceArray detect: [:service | service isAnsweringService].
browser primaryPresenter methods: answeringService answer
selecting: answeringService answer first.
browser primaryPresenter methods: answeringService answer selecting: answeringService answer first.
browser updateCaption: 'Methods updated after renaming ' , oldName , ' to ' , newName.
^browser!

Expand Down

0 comments on commit b642ca7

Please sign in to comment.