Skip to content

Commit

Permalink
Implements currentQueryScope variable to store the last selected scop…
Browse files Browse the repository at this point in the history
…e in Calypso Query Browser
  • Loading branch information
carolahp committed Nov 9, 2023
1 parent 1c7ec48 commit b9b73bd
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/NewTools-Scopes-Editor/ScopesPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ ScopesPresenter >> argumentsListMenu [
anItem
name: 'AND';
visibleIf: [ scopesTree selectedItem isScopeNode ];
action: [ self andWithScope: scopesTree selectedItem ] ];
action: [ self andWithScope: scopesTree selectedItem ] ]";
addItem: [ :anItem |
anItem
name: 'NOT';
visibleIf: [ scopesTree selectedItem isScopeNode ];
action: [ self notWithScope: scopesTree selectedItem ] ] ]
action: [ self notWithScope: scopesTree selectedItem ] ] "]
]

{ #category : 'menu commands' }
Expand Down
25 changes: 22 additions & 3 deletions src/NewTools-Scopes-Tests/ScopesManagesOperationsTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,26 @@ Class {
}

{ #category : 'tests' }
ScopesManagesOperationsTest >> testAddClassAndFillPackageInOrEnvironment [
ScopesManagesOperationsTest >> testAddClassToOrEnvironment [

| packageEnvB classEnv orEnv |

"empty class environment"

classEnv := RBBrowserEnvironment new forClasses: { }.
packageEnvB := RBBrowserEnvironment new forPackages: { ScClassB1 package }.

orEnv := RBOrEnvironment onEnvironment: classEnv or: packageEnvB.

orEnv addClass: ScClassA1.
orEnv addClass: ScClassA1 class.

self assert: orEnv allClasses equals: { ScClassA1 . ScClassB1 }.
self assert: orEnv packages equals: { ScClassA1 package . ScClassB1 package }
]

{ #category : 'tests' }
ScopesManagesOperationsTest >> testAddClassToOrEnvironmentMakingAPackageFull [

| packageEnv classEnvA1 orEnv |

Expand All @@ -26,7 +45,7 @@ ScopesManagesOperationsTest >> testAddClassAndFillPackageInOrEnvironment [
]

{ #category : 'tests' }
ScopesManagesOperationsTest >> testRemoveClassInClassEnvironmentFromOrEnvironment [
ScopesManagesOperationsTest >> testRemoveClassFromOrEnvironment [

| classEnvA1 packageEnvB orEnv |

Expand All @@ -41,7 +60,7 @@ ScopesManagesOperationsTest >> testRemoveClassInClassEnvironmentFromOrEnvironmen
]

{ #category : 'tests' }
ScopesManagesOperationsTest >> testRemoveClassInPackageEnvironmentFromOrEnvironment [
ScopesManagesOperationsTest >> testRemoveClassFromOrEnvironmentBreakingFullPackage [

| packageEnvA classEnv orEnv |

Expand Down
11 changes: 6 additions & 5 deletions src/NewTools-Scopes/RBCompositeEnvironment.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ RBCompositeEnvironment >> addClass: aClass [
packaEnv := (envs select: [ :env | env isPackageEnvironment ]) anyOne.

"Get the classes in the same package as aClass (siblings)"
siblings := classEnv allClasses select: [ :class |
siblings := classEnv classes select: [ :class |
class package = aClass package ].
"If the package is now full, then add the package and remove the siblings"
(siblings asSet add: aClass; yourself) size = aClass package definedClasses size ifTrue: [
(siblings asSet add: aClass; yourself) size = (aClass package definedClasses size * 2) ifTrue: [
siblings do: [ :each | classEnv removeClass: each ].
packaEnv addPackage: aClass package.
^ self ].
Expand All @@ -30,9 +30,10 @@ RBCompositeEnvironment >> addClass: aClass [
]

{ #category : '*NewTools-Scopes' }
RBCompositeEnvironment >> addPackage: aPackageName [
self environment addPackage: aPackageName.
self otherEnvironment addPackage: aPackageName
RBCompositeEnvironment >> addPackage: aPackage [

self environment addPackage: aPackage.
self otherEnvironment addPackage: aPackage
]

{ #category : '*NewTools-Scopes' }
Expand Down
28 changes: 26 additions & 2 deletions src/NewTools-Scopes/ScopesManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Class {
'scopes',
'environment',
'announcer',
'defaultScope'
'defaultScope',
'currentQueryScope'
],
#classVars : [
'singleInstance'
Expand All @@ -29,6 +30,16 @@ ScopesManager class >> availableScopes [
^ self scopes
]

{ #category : 'as yet unclassified' }
ScopesManager class >> currentQueryScope [
^ self singleInstance currentQueryScope
]

{ #category : 'accessing' }
ScopesManager class >> currentQueryScope: aScope [
self singleInstance currentQueryScope: aScope
]

{ #category : 'accessing' }
ScopesManager class >> defaultScopeLabel [

Expand Down Expand Up @@ -177,6 +188,19 @@ ScopesManager >> announcer [
^ announcer ifNil: [ announcer := Announcer new ]
]

{ #category : 'accessing' }
ScopesManager >> currentQueryScope [
^ currentQueryScope
]

{ #category : 'accessing' }
ScopesManager >> currentQueryScope: aScope [

(scopes includes: aScope)
ifTrue: [ currentQueryScope := aScope ]
ifFalse: [ currentQueryScope := nil ]
]

{ #category : 'api' }
ScopesManager >> defaultScope [

Expand Down Expand Up @@ -219,7 +243,7 @@ ScopesManager >> editScope: aScope withNodes: aCollection [
addedClasses do: [ :aClass | aScope addClass: aClass ].
removedClasses do: [ :aClass | aScope removeClass: aClass ].

addedPackages do: [ :aPackage | aScope addPackage: aPackage name ].
addedPackages do: [ :aPackage | aScope addPackage: aPackage ].
removedPackages do: [ :aPackage |
aScope removePackage: aPackage name ].

Expand Down

0 comments on commit b9b73bd

Please sign in to comment.