Skip to content

Commit

Permalink
warn non-packaged class removal
Browse files Browse the repository at this point in the history
If an attempt is made to remove a non-packaged class, give the user and extra warning that this action will not be tracked by Rowan.
  • Loading branch information
Eric Winger authored and Eric Winger committed Sep 13, 2021
1 parent c4fd7e1 commit a5906e9
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 46 deletions.
31 changes: 28 additions & 3 deletions sources/JadeiteBrowserPresenter.cls
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ basicRemoveClass: theClassService
| service parentNode |
self isHierarchyTabSelected
ifTrue: [parentNode := classHierarchyPresenter model parentNodeOf: theClassService].
service := self isNoneProjectSelected
ifTrue: [dictionaryPresenter selection]
ifFalse: [packageListPresenter selection].
service := self selectedDictionaryOrPackage.
service
command: #removeClass:;
commandArgs: (Array with: theClassService).
Expand Down Expand Up @@ -1483,6 +1481,26 @@ removeAppropriateTab
removeLoadSpecTab]
ifFalse: [self removeGlobalsTab]!
removeClass
| classService answeringService classReferenceBrowser queryService |
classService := self selectedClass ifNil: [^self].
answeringService := RowanAnsweringService new.
answeringService
command: #classHasSubclasses:;
commandArgs: (Array with: classService oop).
self issueCommand: answeringService.
answeringService answer ifTrue: [^MessageBox notify: 'Cannot remove class with subclasses'].
(self selectedDictionaryOrPackage confirmClassRemoval: classService) ifFalse: [^self].
queryService := JadePresenter basicBrowseClassReferences: classService name session: self gciSession.
queryService hasResults
ifTrue: [classReferenceBrowser := self browseClassReferences: classService name].
self basicRemoveClass: classService.
queryService hasResults
ifTrue:
[MessageBox notify: classService name
, ' was removed. You will need to remove references to the class or your code may not load in the future.'].
^classReferenceBrowser!
removeDictionaries
| dictionaryNames |
dictionaryPresenter selections isEmpty ifTrue: [^self].
Expand Down Expand Up @@ -1559,6 +1577,11 @@ selectDictionaryNamed: dictionaryName
selectedDictionaryNames
^dictionaryPresenter selections collect: [:dictionaryService | dictionaryService name]!
selectedDictionaryOrPackage
^self isNoneProjectSelected
ifTrue: [dictionaryPresenter selection]
ifFalse: [packageListPresenter selection]!
selectedGlobalName: selection
| string rs |
rs := ReadStream on: (selection at: 1).
Expand Down Expand Up @@ -2110,6 +2133,7 @@ writeProject
!JadeiteBrowserPresenter categoriesFor: #registerPresentersForUpdates!public!register presenters! !
!JadeiteBrowserPresenter categoriesFor: #reloadV2Project!menu handlers!public! !
!JadeiteBrowserPresenter categoriesFor: #removeAppropriateTab!private!tabs! !
!JadeiteBrowserPresenter categoriesFor: #removeClass!menu handlers!public! !
!JadeiteBrowserPresenter categoriesFor: #removeDictionaries!menu handlers!public! !
!JadeiteBrowserPresenter categoriesFor: #removeGlobal!menu handlers!public! !
!JadeiteBrowserPresenter categoriesFor: #removeGlobalsTab!private!tabs! !
Expand All @@ -2122,6 +2146,7 @@ writeProject
!JadeiteBrowserPresenter categoriesFor: #search!accessing!public! !
!JadeiteBrowserPresenter categoriesFor: #selectDictionaryNamed:!public!selection! !
!JadeiteBrowserPresenter categoriesFor: #selectedDictionaryNames!public!selection! !
!JadeiteBrowserPresenter categoriesFor: #selectedDictionaryOrPackage!private!selection! !
!JadeiteBrowserPresenter categoriesFor: #selectedGlobalName:!menu handlers support!private! !
!JadeiteBrowserPresenter categoriesFor: #selectedPackageNames!public!selection! !
!JadeiteBrowserPresenter categoriesFor: #selectedPackageServices!public!selection! !
Expand Down
43 changes: 0 additions & 43 deletions sources/JadeiteProjectsBrowserPresenter.cls
Original file line number Diff line number Diff line change
Expand Up @@ -135,27 +135,6 @@ basicProjectTabLabel
label := packageListPresenter selection name.
^self selectedClass ifNil: [label] ifNotNil: [self selectedClass name]!

basicRemoveClass: selection
| packageService parentNode |
self isHierarchyTabSelected
ifTrue: [parentNode := classHierarchyPresenter model parentNodeOf: selection].
packageService := packageListPresenter selection.
packageService
command: #removeClass:;
commandArgs: (Array with: selection).
self issueCommand: packageService.
classListPresenter model: classListPresenter model. "force a gui update"
self isHierarchyTabSelected
ifTrue:
[classHierarchyPresenter model: classHierarchyPresenter model.
classHierarchyPresenter selection: (classHierarchyPresenter model asBag
detect: [:classService | classService name = parentNode object name])].
self selectedClass
ifNil: [self resetClassTemplate "just emptied the last class in the package"]
ifNotNil:
[classDefinitionPresenter value: self selectedClass template.
self resetClassDefinitionPane]!

basicRemoveMethodCategories
| service |
service := self selectedClass
Expand Down Expand Up @@ -1166,26 +1145,6 @@ registerPresentersForUpdates
releasedReferencedServices: selectionChangingEvent
selectionChangingEvent window presenter selectionOrNil ifNotNil: [:service | service postUpdate]!
removeClass
| classService answeringService classReferenceBrowser queryService |
classService := self selectedClass ifNil: [^self].
answeringService := RowanAnsweringService new.
answeringService
command: #classHasSubclasses:;
commandArgs: (Array with: classService oop).
self issueCommand: answeringService.
answeringService answer ifTrue: [^MessageBox notify: 'Cannot remove class with subclasses'].
(MessageBox confirm: 'Really delete class ' , classService name , '?') ifFalse: [^self].
queryService := JadePresenter basicBrowseClassReferences: classService name session: self gciSession.
queryService hasResults
ifTrue: [classReferenceBrowser := self browseClassReferences: classService name].
self basicRemoveClass: classService.
queryService hasResults
ifTrue:
[MessageBox notify: classService name
, ' was removed. You will need to remove references to the class or your code may not load in the future.'].
^classReferenceBrowser!
removeMethodCategories
| selections |
selections := categoryListPresenter selections.
Expand Down Expand Up @@ -1754,7 +1713,6 @@ updateSUnitTab: service
!JadeiteProjectsBrowserPresenter categoriesFor: #basicAddMethodCategory:!menu handlers support!private! !
!JadeiteProjectsBrowserPresenter categoriesFor: #basicOnDropClassList:!drag & drop!public! !
!JadeiteProjectsBrowserPresenter categoriesFor: #basicProjectTabLabel!displaying!private! !
!JadeiteProjectsBrowserPresenter categoriesFor: #basicRemoveClass:!menu handlers support!private! !
!JadeiteProjectsBrowserPresenter categoriesFor: #basicRemoveMethodCategories!menu handlers support!private! !
!JadeiteProjectsBrowserPresenter categoriesFor: #basicRemoveMethods!menu handlers support!private! !
!JadeiteProjectsBrowserPresenter categoriesFor: #basicRenameCategoryFrom:to:!menu handlers!public! !
Expand Down Expand Up @@ -1844,7 +1802,6 @@ updateSUnitTab: service
!JadeiteProjectsBrowserPresenter categoriesFor: #registerClassData!public!updating! !
!JadeiteProjectsBrowserPresenter categoriesFor: #registerPresentersForUpdates!event handlers!initialize/release!private!register presenters! !
!JadeiteProjectsBrowserPresenter categoriesFor: #releasedReferencedServices:!event handlers!public! !
!JadeiteProjectsBrowserPresenter categoriesFor: #removeClass!menu handlers!public! !
!JadeiteProjectsBrowserPresenter categoriesFor: #removeMethodCategories!menu handlers!public! !
!JadeiteProjectsBrowserPresenter categoriesFor: #removeMethods:!private!services! !
!JadeiteProjectsBrowserPresenter categoriesFor: #removeMethodSelector:!private!services! !
Expand Down
15 changes: 15 additions & 0 deletions sources/RowanDictionaryService.cls
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@ classHierarchyUpdate: presenter browser: browser
browser: browser
hierarchyServices: hierarchyServices!

confirmClassRemoval: classService
| messageStream |
messageStream := WriteStream on: String new.
messageStream
nextPutAll: 'Really delete class ';
nextPutAll: classService name;
nextPut: $?.
classService packageName = RowanService notRowanizedPackageName
ifTrue:
[messageStream
cr;
nextPutAll: 'Note that removal of unpackaged classes will not be tracked by Rowan'].
^MessageBox confirm: messageStream contents!

defaultTemplate
^defaultTemplate!

Expand Down Expand Up @@ -140,6 +154,7 @@ sortAspect
!RowanDictionaryService categoriesFor: #classes:!accessing!public! !
!RowanDictionaryService categoriesFor: #classesUpdate:browser:!public!updating! !
!RowanDictionaryService categoriesFor: #classHierarchyUpdate:browser:!public!updating! !
!RowanDictionaryService categoriesFor: #confirmClassRemoval:!accessing!public! !
!RowanDictionaryService categoriesFor: #defaultTemplate!accessing!private! !
!RowanDictionaryService categoriesFor: #defaultTemplate:!accessing!private! !
!RowanDictionaryService categoriesFor: #displayName!displaying!public! !
Expand Down
4 changes: 4 additions & 0 deletions sources/RowanPackageService.cls
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ condenseExtensions: presenter
dictionary removeAllKeys: rejections.
^dictionary!

confirmClassRemoval: classService
^MessageBox confirm: 'Really delete class ' , classService name , '?'!

defaultTemplate
^defaultTemplate!

Expand Down Expand Up @@ -219,6 +222,7 @@ updateList: presenter whilePreservingSelections: updates browser: browser
!RowanPackageService categoriesFor: #classesUpdate:browser:!public!updating! !
!RowanPackageService categoriesFor: #classHierarchyUpdate:browser:!public!updating! !
!RowanPackageService categoriesFor: #condenseExtensions:!private!updating! !
!RowanPackageService categoriesFor: #confirmClassRemoval:!accessing!public! !
!RowanPackageService categoriesFor: #defaultTemplate!accessing!private! !
!RowanPackageService categoriesFor: #defaultTemplate:!accessing!private! !
!RowanPackageService categoriesFor: #displayName!displaying!public! !
Expand Down

0 comments on commit a5906e9

Please sign in to comment.