Skip to content

Commit

Permalink
Removes scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
carolahp committed Oct 9, 2023
1 parent b11e24e commit 13f3514
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 6 deletions.
17 changes: 14 additions & 3 deletions src/NewTools-Scopes-Browser/ScopeNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Class {
}

{ #category : 'instance creation' }
ScopeNode class >> on: aPackageOrClass [
ScopeNode class >> on: aRBEnvironment [

self class == ScopeNode ifTrue: [
self error: 'I am ab abstract class' ].
self error: 'I am an abstract class' ].

^ self new
value: aPackageOrClass;
value: aRBEnvironment;
yourself
]

Expand All @@ -36,6 +36,12 @@ ScopeNode >> = anotherNode [
and: [ self label = anotherNode label ]
]

{ #category : 'accessing' }
ScopeNode >> == anotherNode [

^ self = anotherNode
]

{ #category : 'accessing' }
ScopeNode >> basicEqualsTo: aNode [

Expand All @@ -62,6 +68,11 @@ ScopeNode >> isPackageNode [
^ false
]

{ #category : 'testing' }
ScopeNode >> isScopeNode [
^ false
]

{ #category : 'accessing' }
ScopeNode >> label [
^ self value name
Expand Down
5 changes: 5 additions & 0 deletions src/NewTools-Scopes-Browser/ScopePackageNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ ScopePackageNode >> isPackageNode [
^ true
]

{ #category : 'testing' }
ScopePackageNode >> isScopeNode [
^ false
]

{ #category : 'accessing' }
ScopePackageNode >> scopesIconName [
^ #package
Expand Down
22 changes: 20 additions & 2 deletions src/NewTools-Scopes-Browser/ScopeScopeNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,21 @@ Class {
{ #category : 'accessing' }
ScopeScopeNode >> children [

^ self value basisObjects collect: [ :package |
ScopePackageNode on: package ]
| className class package |
^ self value basisObjects collect: [ :stringOrPackage |
stringOrPackage isString
ifTrue: [
className := stringOrPackage.
class := self systemDictionary at: className ifAbsent: [ nil ].
ScopeClassNode on: class ]
ifFalse: [
package := stringOrPackage.
ScopePackageNode on: package ] ]
]

{ #category : 'testing' }
ScopeScopeNode >> isScopeNode [
^ true
]

{ #category : 'accessing' }
Expand All @@ -25,3 +38,8 @@ ScopeScopeNode >> label [
ScopeScopeNode >> scopesIconName [
^ #references
]

{ #category : 'accessing' }
ScopeScopeNode >> systemDictionary [
^ Smalltalk globals
]
12 changes: 12 additions & 0 deletions src/NewTools-Scopes-Browser/ScopesPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ ScopesPresenter class >> title [
ScopesPresenter >> addScopeToTree: aRBEnvironment [

model addScope: aRBEnvironment.
scopesTree updateRootsKeepingSelection:
(model scopes collect: [ :scope |self halt. ScopeScopeNode on: scope ])
asOrderedCollection
]

{ #category : 'deletion' }
ScopesPresenter >> deleteSelectedScope [

scopesTree selectedItems
select: [ :item | item isScopeNode ]
thenDo: [ :item | model removeScope: item ].
scopesTree updateRootsKeepingSelection:
(model scopes collect: [ :scope | ScopeScopeNode on: scope ])
asOrderedCollection
Expand Down Expand Up @@ -83,6 +94,7 @@ ScopesPresenter >> initializeScopesTree [
beMultipleSelection;
roots:
(model scopes collect: [ :package |
self halt.
ScopeScopeNode on: package ]) asOrderedCollection sorted;
beResizable;
activateOnDoubleClick;
Expand Down
10 changes: 9 additions & 1 deletion src/NewTools-Scopes/ScopesManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,20 @@ ScopesManager >> newScopeFrom: aSetOfNodes [

]

{ #category : 'removing' }
ScopesManager >> removeScope: aRBEnvironment [
| removed |
removed := scopes select: [ :scope | scope label = aRBEnvironment label ].
removed do: [ :scope | scopes remove: scope ]
]

{ #category : 'initialization' }
ScopesManager >> reset [

environment := nil.
scopes := nil.
self announcer subscriptions reset
self announcer subscriptions reset.
self resetNewScope
]

{ #category : 'accessing' }
Expand Down

0 comments on commit 13f3514

Please sign in to comment.