Skip to content

Commit

Permalink
Use shift class builder to build traits
Browse files Browse the repository at this point in the history
  • Loading branch information
jecisc committed Oct 13, 2023
1 parent af92da4 commit 60cd47f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/Hermes-Tests/HEInstallerSimpleTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ HEInstallerSimpleTest >> testUndeclared [

| exportedClass |
"If we run the test multiple times we need to do this to be sure #AnUndeclaredClass is not in the Undeclared dictionary anymore."
Undeclared removeUnreferencedKeys.
Smalltalk image cleanOutUndeclared.
[
UndefinedObject compile: 'xxx
^ AnUndeclaredClass'.
Expand Down
26 changes: 11 additions & 15 deletions src/Hermes/HEInstaller.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,19 @@ HEInstaller >> build: aHEClass [

{ #category : 'creating traits' }
HEInstaller >> buildTrait: aTraitDefinition [
| newTrait traitComposition traitClass|

(self existingTrait: aTraitDefinition) ifNotNil: [:x | ^ x ].

traitClass := Smalltalk globals at: #Trait ifAbsent: [ self error: 'Trait support is not installed' ].

traitComposition := self buildTraitCompositionFor: aTraitDefinition traitComposition.

newTrait := traitClass
named: aTraitDefinition traitName
uses: traitComposition
package: aTraitDefinition category
env: environment.

newTrait classTrait traitComposition: (self buildTraitCompositionFor: aTraitDefinition classTraitComposition).
(self existingTrait: aTraitDefinition) ifNotNil: [ :x | ^ x ].

self supportsTraits ifFalse: [ self error: 'Trait support is not installed' ].

^ newTrait
^ self class classInstaller make: [ :builder |
builder
beTrait;
name: aTraitDefinition traitName;
uses: (self buildTraitCompositionFor: aTraitDefinition traitComposition);
classTraitComposition: (self buildTraitCompositionFor: aTraitDefinition classTraitComposition);
package: aTraitDefinition category;
environment: environment ]
]

{ #category : 'creating traits' }
Expand Down

0 comments on commit 60cd47f

Please sign in to comment.