Skip to content

Commit

Permalink
finally remove AbstractTool
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusDenker committed May 12, 2023
1 parent 9fae377 commit 9b9acb2
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 242 deletions.
41 changes: 39 additions & 2 deletions src/Manifest-Core/TheManifestBuilder.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ My name is strange but this is to avoid to match with a Manifest class which is
"
Class {
#name : #TheManifestBuilder,
#superclass : #AbstractTool,
#superclass : #Model,
#instVars : [
'manifestClass'
],
Expand Down Expand Up @@ -524,6 +524,36 @@ TheManifestBuilder >> removeAllToDo: fp of: ruleId version: versionId [
self removeAllItem: fp selector: selector
]

{ #category : #class }
TheManifestBuilder >> removeClasses: aCollection [
"Remove the selected classes from the system. Check that the user really wants to do this, since it is not reversible. Answer true if removal actually happened."

| classNames classesToRemove result |
aCollection isEmptyOrNil
ifTrue: [ ^ false ].
classesToRemove := aCollection collect: [:each | each instanceSide].
classNames := (classesToRemove collect: [:each | each name]) joinUsing: ', '.
(result := self confirm: (self removeClassesMessageFor: classNames))
ifTrue: [
classesToRemove
do: [ :classToRemove |
classToRemove subclasses notEmpty
ifTrue: [
(self confirm: (self removedClassHasSubclassesMessageFor: classToRemove name))
ifTrue: [ classToRemove removeFromSystem ] ]
ifFalse: [ classToRemove removeFromSystem ] ] ].
^ result
]

{ #category : #class }
TheManifestBuilder >> removeClassesMessageFor: classNames [
^ 'Are you certain that you
want to REMOVE the classes ' , classNames
,
'
from the system?'
]

{ #category : #'adding-removing' }
TheManifestBuilder >> removeFalsePositive: fp of: ruleId version: versionId [

Expand All @@ -541,7 +571,7 @@ TheManifestBuilder >> removeItem: fp selector: selector [
TheManifestBuilder >> removeManifestOf: aItem [

(self manifestOf: aItem) ifNotNil: [ :myManifest |
self removeClass: myManifest ]
SystemNavigation new removeClass: myManifest ]
]

{ #category : #private }
Expand Down Expand Up @@ -582,6 +612,13 @@ TheManifestBuilder >> removeToDo: fp of: ruleId version: versionId [
self removeItem: fp selector: selector
]

{ #category : #class }
TheManifestBuilder >> removedClassHasSubclassesMessageFor: className [

^ className, ' has subclasses.
Do you really want to REMOVE it from the system ?'
]

{ #category : #'adding-removing' }
TheManifestBuilder >> resetFalsePositiveOf: ruleId version: versionId [

Expand Down
28 changes: 0 additions & 28 deletions src/Refactoring-Changes/AbstractTool.extension.st

This file was deleted.

27 changes: 27 additions & 0 deletions src/Refactoring-Changes/RBRefactoryChangeManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ RBRefactoryChangeManager class >> instance [
^ Instance ifNil: [ Instance := self basicNew initialize ]
]

{ #category : #'world menu' }
RBRefactoryChangeManager class >> menuCommandOn: aBuilder [
<worldMenu>
(aBuilder item: #'Undo last refactoring')
action: [self undoLastRefactoring];
parent: #Refactoring;
help: 'Undo last refactoring';
order: 10;
iconName: #smallUndo
]

{ #category : #'instance creation' }
RBRefactoryChangeManager class >> new [

Expand All @@ -73,6 +84,22 @@ RBRefactoryChangeManager class >> resetCounter [
Counter := nil
]

{ #category : #menu }
RBRefactoryChangeManager class >> undoLastRefactoring [
| manager |
manager := RBRefactoryChangeManager instance.
manager undoPointers ifNotEmpty: [
[ |limit list|
list := OrderedCollection new.
limit := manager lastUndoPointer .
1 to: limit do:[ :i | list add: manager undoChange ].
list do: [ :e | e execute ]
] asJob
title: 'Refactoring';
run]
ifEmpty: [ self inform: 'There aren''t refactorings to undo.' ]
]

{ #category : #'class initialization' }
RBRefactoryChangeManager class >> undoSize [

Expand Down
50 changes: 50 additions & 0 deletions src/System-Support/SystemNavigation.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,53 @@ SystemNavigation new browseAllSelect:
found]
"
]

{ #category : #removing }
SystemNavigation >> removeClass: aClass [
"Remove the selected class from the system, at interactive user request. Make certain the user really wants to do this, since it is not reversible. Answer true if removal actually happened."

| message className classToRemove result |
aClass ifNil: [ ^ false ].
classToRemove := aClass instanceSide.
className := classToRemove name.
message := self removeClassMessageFor: className.
(result := self confirm: message)
ifTrue: [
classToRemove subclasses notEmpty
ifTrue: [
(self confirm: 'class has subclasses: ' , message)
ifFalse: [ ^ false ] ].
classToRemove removeFromSystem ].
^ result
]

{ #category : #removing }
SystemNavigation >> removeClassMessageFor: className [
^ 'Are you certain that you
want to REMOVE the class ' , className
,
'
from the system?'
]

{ #category : #removing }
SystemNavigation >> removeMethod: aMethod inClass: aClass [
"If a message is selected, create a Confirmer so the user can verify that
the currently selected message should be removed from the system. If
so, remove it. "
| messageName confirmation |

aMethod ifNil: [^ false].
messageName := aMethod selector.
confirmation := self confirmRemovalOf: messageName on: aClass.
confirmation = 3
ifTrue: [^ false].
(aClass includesLocalSelector: messageName)
ifTrue: [ aClass removeSelector: messageName ].

"In case organization not cached"
confirmation = 2
ifTrue: [self browseAllSendersOf: messageName].

^ true
]
Loading

0 comments on commit 9b9acb2

Please sign in to comment.