Skip to content

Commit

Permalink
Excludes from scope nodes tree packages without definedClasses
Browse files Browse the repository at this point in the history
  • Loading branch information
carolahp committed Oct 15, 2023
1 parent 05a4b47 commit ffc68a1
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions src/NewTools-Scopes-Browser/ScopeNodesPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ ScopeNodesPresenter >> addNode: aNode [
ScopeNodesPresenter >> allScopeNodeTreeRoots [

^ allScopeNodeTreeRoots ifNil: [
allScopeNodeTreeRoots := model allPackagesInEnvironment collect: [
:package | ScopePackageNode on: package ] ]
allScopeNodeTreeRoots := model allPackagesInEnvironment
reject: [ :package | package definedClasses isEmpty ]
thenCollect: [ :package | ScopePackageNode on: package ] ]
]

{ #category : 'announcements' }
Expand Down Expand Up @@ -253,21 +254,14 @@ ScopeNodesPresenter >> refresh [

{ #category : 'refreshing' }
ScopeNodesPresenter >> refreshCheckbox [
"select package nodes which have all of their classes selected"

"scopeNodesTree roots do: [ :packageNode |
packageNode = packageNode ifTrue: [
aPackageNode children size
== aPackageNode value definedClasses size
ifTrue: [ self addNode: aPackageNode ]
ifFalse: [ self removeNode: aPackageNode ] ] ]."

scopeNodesTree roots do: [ :packageNode |
(packageNode children allSatisfy: [ :classNode |
checkedScopeNodes anySatisfy: [ :checkedClassNode |
checkedClassNode = classNode ] ])
ifTrue: [ checkedScopeNodes add: packageNode ]
ifFalse: [ checkedScopeNodes remove: packageNode ifAbsent: [ ] ] ].

scopeNodesTree refresh
]

Expand Down Expand Up @@ -313,24 +307,23 @@ ScopeNodesPresenter >> scope: aRBEnvironment [
| packages |
scope := aRBEnvironment.
packages := scope packages.

scopeNodesTree roots do: [ :packageNode |
scopeNodesTree roots withIndexDo: [ :packageNode :index |
(packages anySatisfy: [ :package | packageNode value = package ])
ifTrue: [
| classNodes classes |

classNodes := packageNode children.
classes := scope classes.
"all packageNode children should be checked and including the packageNode"
"all packageNode children should be checked, including the packageNode"
(classNodes allSatisfy: [ :classNode |
classes anySatisfy: [ :cls | cls = classNode value ] ])
classes anySatisfy: [ :cls | cls name = classNode value name ] ])
ifTrue: [
checkedScopeNodes add: classNodes.
classNodes do: [ :clsNode | checkedScopeNodes add: clsNode ].
checkedScopeNodes add: packageNode ]
ifFalse: [ "only some packageNode children should be checked, and as result, the packageNode is not selected"
classNodes do: [ :classNode |
(classes includes: classNode value) ifTrue: [
checkedScopeNodes add: classNode ] ] ] ] ].

self refresh
checkedScopeNodes add: classNode ].
scopeNodesTree expandPath: { index } ] ] ] ].

self refreshCheckbox
]

0 comments on commit ffc68a1

Please sign in to comment.