Skip to content

Commit

Permalink
Intermediate implementation of adding package
Browse files Browse the repository at this point in the history
  • Loading branch information
carolahp committed Oct 29, 2023
1 parent 886c47a commit 87aa7bb
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 62 deletions.
2 changes: 1 addition & 1 deletion src/NewTools-Scopes-Browser/ScopeClassNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Class {
{ #category : 'accessing' }
ScopeClassNode >> children [

^ children ifNil: [children := #( )]
^ #( )
]

{ #category : 'testing' }
Expand Down
3 changes: 1 addition & 2 deletions src/NewTools-Scopes-Browser/ScopeNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Class {
#name : 'ScopeNode',
#superclass : 'Object',
#instVars : [
'value',
'children'
'value'
],
#category : 'NewTools-Scopes-Browser-Nodes',
#package : 'NewTools-Scopes-Browser',
Expand Down
14 changes: 6 additions & 8 deletions src/NewTools-Scopes-Browser/ScopePackageNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ Class {
{ #category : 'accessing' }
ScopePackageNode >> children [

^ children ifNil: [
children := value definedClasses asOrderedCollection collect: [
:classOrTrait |
classOrTrait isClassOrTrait ifFalse: [
self error: 'child must be a or a trait' ].
classOrTrait isTrait
ifTrue: [ ScopeTraitNode on: classOrTrait ]
ifFalse: [ ScopeClassNode on: classOrTrait ] ] ]
^ value definedClasses asOrderedCollection collect: [ :classOrTrait |
classOrTrait isClassOrTrait ifFalse: [
self error: 'child must be a class or a trait' ].
classOrTrait isTrait
ifTrue: [ ScopeTraitNode on: classOrTrait ]
ifFalse: [ ScopeClassNode on: classOrTrait ] ]
]

{ #category : 'accessing' }
Expand Down
72 changes: 21 additions & 51 deletions src/NewTools-Scopes-Browser/ScopeScopeNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ I am a model for having scopes in the ScopeTreePresenter
Class {
#name : 'ScopeScopeNode',
#superclass : 'ScopeNode',
#instVars : [
'classes',
'packages'
],
#category : 'NewTools-Scopes-Browser-Nodes',
#package : 'NewTools-Scopes-Browser',
#tag : 'Nodes'
Expand All @@ -16,56 +12,30 @@ Class {
{ #category : 'accessing' }
ScopeScopeNode >> children [

| className class package orphanClasses fullPackages envClasses chldrn packageEnvironments classesEnvironments |

children ifNotNil: [ ^ children ].

self value isCompositeEnvironment ifTrue: [
chldrn := Set new.
envClasses := self classes reject: [:c | c isMeta ].

"packages whose classes were all selected"
fullPackages := ScopesManager fullPackagesFrom: envClasses.
"classes whose package hasn't all of its classes selected"

orphanClasses := ScopesManager
orphanClassesIn: envClasses
havingFullPackages: fullPackages.

packageEnvironments := fullPackages collect: [ :thePackage |
ScopePackageNode on: thePackage ].
classesEnvironments := orphanClasses collect: [ :theClass |
theClass isTrait
ifTrue: [ ScopeTraitNode on: theClass ]
ifFalse: [ ScopeClassNode on: theClass ] ].
packageEnvironments do: [ :env | chldrn add: env ].
classesEnvironments do: [ :env | chldrn add: env ].
^ children := chldrn ].

^ children := self value basisObjects collect: [ :stringOrPackage |
stringOrPackage isString
ifTrue: [
className := stringOrPackage.
class := self systemDictionary
at: className
ifAbsent: [ nil ].
class isTrait
ifTrue: [ ScopeTraitNode on: class ]
ifFalse: [ ScopeClassNode on: class ] ]
ifFalse: [
stringOrPackage isClassOrTrait
ifTrue: [ ScopeClassNode on: stringOrPackage ]
ifFalse: [
self assert: (stringOrPackage isKindOf: RPackage).
package := stringOrPackage.
ScopePackageNode on: package ] ] ].

| fullPackages orphanClasses packageChildren classChildren clss |
clss := self value classes.
self halt.
fullPackages := ScopesManager fullPackagesFrom: clss.
orphanClasses := ScopesManager
orphanClassesIn: clss
havingFullPackages: fullPackages.

packageChildren := fullPackages collect: [ :package |
ScopePackageNode on: package ].
classChildren := orphanClasses collect: [ :class |
class isTrait
ifTrue: [ ScopeTraitNode on: class ]
ifFalse: [ ScopeClassNode on: class ] ].

^ packageChildren
addAll: classChildren;
yourself
]

{ #category : 'accessing' }
ScopeScopeNode >> classes [

^ classes ifNil: [ classes := value classes ]
^ value classes
]

{ #category : 'testing' }
Expand All @@ -85,8 +55,8 @@ ScopeScopeNode >> packageNode [

{ #category : 'accessing' }
ScopeScopeNode >> packages [

^ packages ifNil: [ packages := value packages ]
self halt.
^ value packages
]

{ #category : 'accessing' }
Expand Down
6 changes: 6 additions & 0 deletions src/NewTools-Scopes/RBCompositeEnvironment.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ RBCompositeEnvironment >> addClass: aClass [
self otherEnvironment addClass: aClass
]

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

{ #category : '*NewTools-Scopes' }
RBCompositeEnvironment >> removeClass: aClass [
self environment removeClass: aClass.
Expand Down

0 comments on commit 87aa7bb

Please sign in to comment.