Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduces Probes by enhancing existing SBWatch #122

Merged
merged 9 commits into from
Aug 20, 2023
9 changes: 9 additions & 0 deletions packages/Sandblocks-Babylonian/Collection.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Extension { #name : #Collection }

{ #category : #'*Sandblocks-Babylonian' }
Collection >> sbWatchValueMorphFor: traceValue [

^ (SBWatchValue newContainerMorphFor: traceValue)
addMorph: (SBStringMorph new contents: (self printStringLimitedTo: 1000));
yourself
]
9 changes: 9 additions & 0 deletions packages/Sandblocks-Babylonian/Color.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Extension { #name : #Color }

{ #category : #'*Sandblocks-Babylonian' }
Color >> sbWatchValueMorphFor: traceValue [

^ (SBWatchValue newContainerMorphFor: traceValue)
addMorph: self asMorph;
yourself
]
16 changes: 16 additions & 0 deletions packages/Sandblocks-Babylonian/Form.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Extension { #name : #Form }

{ #category : #'*Sandblocks-Babylonian' }
Form >> sbSnapshot [

^ self copy
]

{ #category : #'*Sandblocks-Babylonian' }
Form >> sbWatchValueMorphFor: traceValue [

^ (SBWatchValue newContainerMorphFor: traceValue)
addMorphBack: (SBIcon iconFor: traceValue watchedValueIdentityHash) asMorph;
addMorphBack: self asMorph;
yourself
]
10 changes: 10 additions & 0 deletions packages/Sandblocks-Babylonian/Morph.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Extension { #name : #Morph }

{ #category : #'*Sandblocks-Babylonian' }
Morph >> sbWatchValueMorphFor: traceValue [

^ (SBWatchValue newContainerMorphFor: traceValue)
addMorphBack: (SBIcon iconFor: traceValue watchedValueIdentityHash) asMorph;
addMorphBack: self asMorph;
yourself
]
9 changes: 9 additions & 0 deletions packages/Sandblocks-Babylonian/Number.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Extension { #name : #Number }

{ #category : #'*Sandblocks-Babylonian' }
Number >> sbWatchValueMorphFor: traceValue [

^ (SBWatchValue newContainerMorphFor: traceValue)
addMorphBack: (SBStringMorph new contents: self printString);
yourself
]
27 changes: 27 additions & 0 deletions packages/Sandblocks-Babylonian/Object.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Extension { #name : #Object }

{ #category : #'*Sandblocks-Babylonian' }
Object >> sbSnapshot [

"This is a copy of veryDeepCopy which skips fixDependents as it is currently of minor importance
and takes a lot of time."

| copier new |
copier := DeepCopier new: self initialDeepCopierSize.
new := self veryDeepCopyWith: copier.
copier mapUniClasses.
copier references associationsDo: [:assoc |
assoc value veryDeepFixupWith: copier].
^ new
]

{ #category : #'*Sandblocks-Babylonian' }
Object >> sbWatchValueMorphFor: traceValue [

"This has to return a container block"

^ (SBWatchValue newContainerMorphFor: traceValue)
addMorphBack: (SBIcon iconFor: traceValue watchedValueIdentityHash) asMorph;
addMorphBack: (SBStringMorph new contents: (' ' , self printString));
yourself
]
5 changes: 3 additions & 2 deletions packages/Sandblocks-Babylonian/SBExample.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ SBExample >> run [
currentProcess := nil.
processRunning := false.
Project current addDeferredUIMessage: [
returnValue reportValue: returned."contents: '-> ', returned printString".
returnValue reportValue: returned.
returnValue updateDisplay.
self sendFinishNotification]
] forkAt: Processor userBackgroundPriority
]
Expand Down Expand Up @@ -424,7 +425,7 @@ SBExample >> self: aBlock args: aCollectionBlock label: aString [
addMorphBack: aBlock;
addMorphBack: (SBStringMorph new contents: 'args:');
addMorphBack: aCollectionBlock;
addMorphBack: (returnValue := SBWatchView new);
addMorphBack: (returnValue := SBExampleWatchView new);
updateIcon
]

Expand Down
53 changes: 15 additions & 38 deletions packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st
Original file line number Diff line number Diff line change
@@ -1,52 +1,41 @@
"
A row in SBExampleWatches, containing the belonging example name and a view (display) of the evaluated expression values
"
Class {
#name : #SBExampleValueDisplay,
#superclass : #Morph,
#instVars : [
'display',
'label',
'statusLabel',
'hadValue',
'values'
'hadValue'
],
#category : #'Sandblocks-Babylonian'
}

{ #category : #'event handling' }
{ #category : #accessing }
SBExampleValueDisplay >> exampleFinished: anExample [

"display exampleFinished: anExample."
display exampleFinished: anExample.

statusLabel contents: (hadValue
ifTrue: ['']
ifFalse: ['- Not reached -'])
]

{ #category : #'event handling' }
{ #category : #accessing }
SBExampleValueDisplay >> exampleStarting: anExample [

display exampleStarting: anExample.
display noValue.

values := OrderedCollection new.

statusLabel contents: '...'.
hadValue := false.

self refreshWorld
]

{ #category : #'as yet unclassified' }
SBExampleValueDisplay >> filterForContextId: aNumber [

| frames |
frames := values select: [:probedValue |
probedValue frames anySatisfy: [:frame | frame contextIdentityHash = aNumber]].

self flag: #todo.
frames ifNotEmpty: [display reportValue: frames first value]
]

{ #category : #'as yet unclassified' }
{ #category : #initialization }
SBExampleValueDisplay >> initialize [

super initialize.
Expand All @@ -60,51 +49,39 @@ SBExampleValueDisplay >> initialize [
changeListDirection: #leftToRight;
addMorphBack: (label := SBStringMorph new);
addMorphBack: (statusLabel := SBStringMorph new contents: '');
addMorphBack: (display := SBWatch watchViewClass new)
addMorphBack: (display := SBExampleWatch watchViewClass saving: -1)
]

{ #category : #'as yet unclassified' }
{ #category : #accessing }
SBExampleValueDisplay >> label [

^ label contents
]

{ #category : #'as yet unclassified' }
{ #category : #accessing }
SBExampleValueDisplay >> label: aString [

label contents: aString
]

{ #category : #'as yet unclassified' }
{ #category : #layout }
SBExampleValueDisplay >> layoutCommands [

^ SBAlgebraCommand container
morph: self;
data: (self submorphs collect: #layoutCommands separatedBy: [SBAlgebraCommand gap])
]

{ #category : #'as yet unclassified' }
{ #category : #naming }
SBExampleValueDisplay >> name: aString [

label contents: aString
]

{ #category : #'as yet unclassified' }
SBExampleValueDisplay >> probedValues [

^ values
]

{ #category : #'as yet unclassified' }
{ #category : #'event handling' }
SBExampleValueDisplay >> reportValue: anObject name: aString [

display reportValue: anObject.
label contents: aString.
hadValue := true.

SBToggledCode comment: '' active: 0 do: {
[
values add: (SBProbedValue new
value: anObject
context: thisContext sender sender sender sender sender sender sender)]}
hadValue := true
]
Loading
Loading