Skip to content

Commit

Permalink
fixes: pharo-project#7648 Class using complex slots should automatica…
Browse files Browse the repository at this point in the history
…lly be displayed using fluidclass definition.

- next step traits since they can also have complex slots
  • Loading branch information
Ducasse committed Nov 2, 2020
1 parent 58885d2 commit a30b452
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 11 deletions.
23 changes: 23 additions & 0 deletions src/Kernel-Tests/FluidClassDefinitionPrinterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@ FluidClassDefinitionPrinterTest >> testChronologyConstants [
package: ''Kernel'''
]

{ #category : #'tests - complex slots' }
FluidClassDefinitionPrinterTest >> testClassDefinitionWithComplexSlotShouldBeDisplay [

ClassDefinitionPrinter showFluidClassDefinition: false.
self assert: MockWithComplexSlot needsSlotClassDefinition.

self
assert: (self forClass: MockWithComplexSlot)
equals: 'Object << #MockWithComplexSlot
slots: { #aComplexSlot => PropertySlot };
tag: ''Fluid'';
package: ''Kernel-Tests'''
]

{ #category : #'tests - template' }
FluidClassDefinitionPrinterTest >> testCompactClassTemplate [

Expand All @@ -76,6 +90,15 @@ FluidClassDefinitionPrinterTest >> testCompactClassTemplate [
package: ''Kernel'''
]

{ #category : #'tests - complex slots' }
FluidClassDefinitionPrinterTest >> testDefinitionWithComplexSlot [

self assert: (self forClass: MockWithComplexSlot) equals: 'Object << #MockWithComplexSlot
slots: { #aComplexSlot => PropertySlot };
tag: ''Fluid'';
package: ''Kernel-Tests'''
]

{ #category : #'tests - expanded' }
FluidClassDefinitionPrinterTest >> testExpandedEmptyLayoutClass [

Expand Down
15 changes: 15 additions & 0 deletions src/Kernel-Tests/MockWithComplexSlot.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Class {
#name : #MockWithComplexSlot,
#superclass : #Object,
#instVars : [
'#aComplexSlot => PropertySlot'
],
#category : #'Kernel-Tests-Fluid'
}

{ #category : #initialization }
MockWithComplexSlot >> initialize [

self class initializeSlots: self.
super initialize.
]
16 changes: 5 additions & 11 deletions src/Kernel/OldPharoClassDefinitionPrinter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,41 @@ Class {
{ #category : #delegating }
OldPharoClassDefinitionPrinter >> classDefinitionString [

| poolString stream |
^ forClass needsSlotClassDefinition
ifTrue: [ (ClassDefinitionPrinter fluid for: forClass) classDefinitionString ]
ifFalse: [ | poolString stream |
poolString := forClass sharedPoolsString.
stream := (String new: 800) writeStream.
forClass superclass
ifNotNil: [ stream nextPutAll: forClass superclass name ]
ifNil: [ stream nextPutAll: 'ProtoObject' ].

stream
nextPutAll: forClass kindOfSubclass;
store: forClass name.

store: forClass name.
forClass hasTraitComposition ifTrue: [
stream
crtab;
nextPutAll: 'uses: ';
nextPutAll: forClass traitCompositionString ].

stream
crtab;
nextPutAll: 'instanceVariableNames: '''.
forClass instanceVariablesOn: stream.
stream nextPut: $'.
stream
crtab;
nextPutAll: 'classVariableNames: '''.
forClass classVariablesOn: stream.
stream nextPut: $'.

poolString = '' ifFalse: [
stream
crtab;
nextPutAll: 'poolDictionaries: ';
store: poolString ].

stream
crtab;
nextPutAll: 'package: ';
store: forClass category asString.

forClass superclass ifNil: [
stream
nextPutAll: '.';
Expand All @@ -56,8 +51,7 @@ OldPharoClassDefinitionPrinter >> classDefinitionString [
stream
space;
nextPutAll: 'superclass: nil' ].

^ stream contents
stream contents ]
]

{ #category : #template }
Expand Down

0 comments on commit a30b452

Please sign in to comment.