Skip to content

Commit

Permalink
Fix last broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
jecisc committed Oct 12, 2023
1 parent cf81567 commit 30362c9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 55 deletions.
9 changes: 4 additions & 5 deletions src/Hermes-Tests/HEInstallWholePackageTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ HEInstallWholePackageTest >> changeClassesNames: aPackage [
aPackage traits
do: [ :e |
e instVarNamed: #category put: #'Hermes-Tests-External-Package2'.
e instVarNamed: #traitName put: (e className , '2') asSymbol.
e instVarNamed: #traitName put: (e traitName , '2') asSymbol.
self updateMethodLiterals: e methods.
self updateMethodLiterals: e classSideMethods ].

Expand All @@ -41,10 +41,9 @@ HEInstallWholePackageTest >> setUp [

{ #category : 'initialization' }
HEInstallWholePackageTest >> tearDown [
| aPackage |
aPackage := RPackageOrganizer default packageNamed:#'Hermes-Tests-External-Package2' ifAbsent: nil.
aPackage ifNotNil: #removeFromSystem.
super tearDown.

(RPackageOrganizer default packageNamed: #'Hermes-Tests-External-Package2' ifAbsent: nil) ifNotNil: #removeFromSystem.
super tearDown
]

{ #category : 'tests' }
Expand Down
74 changes: 24 additions & 50 deletions src/Hermes/HEInstaller.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -25,59 +25,37 @@ Class {
#superclass : 'Object',
#instVars : [
'environment',
'originalUndeclareds',
'hasTraits'
'originalUndeclareds'
],
#category : 'Hermes-ClassInstaller',
#package : 'Hermes',
#tag : 'ClassInstaller'
}

{ #category : 'converting' }
HEInstaller >> asClassVariables: aString [
| trimmed |
trimmed := aString trimBoth.

trimmed isEmpty
ifTrue: [ ^ #() ].

^ (trimmed substrings: ' ') collect: [:x | x asSymbol => ClassVariable]
]

{ #category : 'converting' }
HEInstaller >> asSlots: aString [
| trimmed |
trimmed := aString trimBoth.

trimmed isEmpty
ifTrue: [ ^ #() ].

^ (trimmed splitOn: ' ') collect: [ :e | e asSymbol asSlot ] as: Array
]

{ #category : 'creating classes' }
HEInstaller >> build: aHEClass [
| newClass superclass layoutType |

| newClass superclass layoutType |
(self existingClass: aHEClass) ifNotNil: [ :x | ^ x ].

superclass := self classNamed: aHEClass superclass.
layoutType := self classNamed: aHEClass layoutClass.

newClass := self class classInstaller make: [ :builder |
builder name: aHEClass className;
superclass: superclass;
layoutClass: layoutType;
slots: (self asSlots: aHEClass instanceVariables);
sharedVariables: (self asClassVariables:aHEClass classVariables);
sharedPools: aHEClass sharedPools;
category: aHEClass category;
classSlots: (self asSlots: aHEClass classInstancevariables) ].

self processTraitsFrom: aHEClass in: newClass.

^newClass.

builder
name: aHEClass className;
superclass: superclass;
layoutClass: layoutType;
slots: aHEClass instanceVariables asSlotCollection;
sharedVariablesFromString: aHEClass classVariables;
sharedPools: aHEClass sharedPools;
category: aHEClass category;
classSlots: aHEClass classInstancevariables asSlotCollection.
self supportsTraits ifTrue: [
builder
traitComposition: (self buildTraitCompositionFor: aHEClass traitComposition);
classTraitComposition: (self buildTraitCompositionFor: aHEClass classTraitComposition) ] ].
^ newClass
]

{ #category : 'creating traits' }
Expand Down Expand Up @@ -183,9 +161,9 @@ HEInstaller >> existingTrait: aHETrait [

{ #category : 'initialization' }
HEInstaller >> initialize [

environment := self class environment.
originalUndeclareds := Undeclared copy.
hasTraits := Smalltalk globals hasClassNamed: #Trait.
originalUndeclareds := Undeclared copy
]

{ #category : 'installing methods' }
Expand Down Expand Up @@ -231,16 +209,6 @@ HEInstaller >> messageMethod: aHEMethod alreadyExistsIn: aClass [
^ 'The method ' , aHEMethod name asString , ' already exists in class ' , aClass name asString
]

{ #category : 'creating classes' }
HEInstaller >> processTraitsFrom: aHEClass in: newClass [

hasTraits ifFalse: [ ^ self ].

newClass setTraitComposition: (self buildTraitCompositionFor: aHEClass traitComposition).
newClass class setTraitComposition: (self buildTraitCompositionFor: aHEClass classTraitComposition).

]

{ #category : 'installing methods' }
HEInstaller >> rebuildMethod: aMethod into: aClass [
| newMethod literalSpace extendedEnvironment |
Expand Down Expand Up @@ -286,6 +254,12 @@ HEInstaller >> shouldBuildMethod: aHEMethod in: aClass [
ifAbsent: [ ^ true ]
]

{ #category : 'testing' }
HEInstaller >> supportsTraits [

^ Smalltalk globals hasClassNamed: #Trait
]

{ #category : 'reporting undeclared' }
HEInstaller >> validateNoNewUndeclared [
self reportNewUndeclareds: self createdUndeclared.
Expand Down
9 changes: 9 additions & 0 deletions src/Hermes/HETrait.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ HETrait >> name [
^ self traitName
]

{ #category : 'printing' }
HETrait >> printOn: aStream [

aStream
nextPutAll: 'HETrait ( ';
print: traitName;
nextPutAll: ' )'
]

{ #category : 'accessing' }
HETrait >> traitName [
^ traitName
Expand Down

0 comments on commit 30362c9

Please sign in to comment.