From 99fc942b3da1db2318d1896256c7bc1192f08014 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Tue, 23 Apr 2024 14:43:02 +0200 Subject: [PATCH 1/4] Some refactorings, error fixing --- .../Sandblocks-Babylonian/SBMultiverse.class.st | 2 +- packages/Sandblocks-Core/Collection.extension.st | 4 ++-- .../SBStGrammarHandler.class.st | 16 ---------------- packages/Sandblocks-Smalltalk/SBVariant.class.st | 2 +- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/packages/Sandblocks-Babylonian/SBMultiverse.class.st b/packages/Sandblocks-Babylonian/SBMultiverse.class.st index fbd8ca28..84efba0e 100644 --- a/packages/Sandblocks-Babylonian/SBMultiverse.class.st +++ b/packages/Sandblocks-Babylonian/SBMultiverse.class.st @@ -119,7 +119,7 @@ SBMultiverse >> cleanUp [ (watches select: [:anOpenWatch | anOpenWatch containingArtefact isNil]) copy do: #delete. watches select: #isInEditor thenDo: [:aWatch | aWatch exampleToDisplay values do: #updateDisplay]. allMethodBlocksContainingWatches do: [:aMethodBlock | - (aMethodBlock valueOfProperty: #originals) do: [:aWatch| aWatch ignoreReports: true]]. + (aMethodBlock valueOfProperty: #originals) do: [:aWatch| aWatch ignoreReports: false]]. ] { #category : #collecting } diff --git a/packages/Sandblocks-Core/Collection.extension.st b/packages/Sandblocks-Core/Collection.extension.st index 17df9063..af15603e 100644 --- a/packages/Sandblocks-Core/Collection.extension.st +++ b/packages/Sandblocks-Core/Collection.extension.st @@ -5,7 +5,7 @@ Collection >> asBarChart: converter [ converter - if: [self isString not and: [self isDictionary not and: [self allSatisfy: SBBarChart supportedInterface]]] + if: [self isString not and: [self allSatisfy: SBBarChart supportedInterface]] do: [SBBarChart newWithValues: self] ] @@ -23,7 +23,7 @@ Collection >> asLineChart: converter [ converter - if: [self isString not and: [self isDictionary not and: [self allSatisfy: SBLineChart supportedInterface]]] + if: [self isString not and: [self allSatisfy: SBLineChart supportedInterface]] do: [SBLineChart newWithValues: self] ] diff --git a/packages/Sandblocks-Smalltalk/SBStGrammarHandler.class.st b/packages/Sandblocks-Smalltalk/SBStGrammarHandler.class.st index b95a9e50..0366eee1 100644 --- a/packages/Sandblocks-Smalltalk/SBStGrammarHandler.class.st +++ b/packages/Sandblocks-Smalltalk/SBStGrammarHandler.class.st @@ -462,22 +462,6 @@ SBStGrammarHandler >> useThirdArgument [ self useArgument: 3 ] -{ #category : #'action helpers' } -SBStGrammarHandler >> variantNameFor: aCollectionOfBlocks in: aParentBlock [ - - aParentBlock sandblockEditor = aParentBlock ifTrue: [^ aCollectionOfBlocks printString]. - - aParentBlock isTopLevel ifTrue: [^ aParentBlock printString]. - - aParentBlock isMessageSend ifTrue: [^ aCollectionOfBlocks first submorphBefore printString]. - (aParentBlock isAssignment and: [aParentBlock receiver isVariant not]) ifTrue: [^ aParentBlock receiver sourceString, ' := ']. - - aCollectionOfBlocks size = 1 ifTrue: [^ aCollectionOfBlocks first sourceString]. - - ^ '{1}' format: {(aCollectionOfBlocks collect: [:aBlock | aBlock sourceString]) - fold: [:a :b | a, ', ', Character cr, b ]} -] - { #category : #'action helpers' } SBStGrammarHandler >> variantNameFor: aCollectionOfBlocks in: aParentBlock preceedingBlock: aNeighbor [ diff --git a/packages/Sandblocks-Smalltalk/SBVariant.class.st b/packages/Sandblocks-Smalltalk/SBVariant.class.st index 9d247b1b..73b9a694 100644 --- a/packages/Sandblocks-Smalltalk/SBVariant.class.st +++ b/packages/Sandblocks-Smalltalk/SBVariant.class.st @@ -90,7 +90,7 @@ SBVariant class >> named: aString associations: aCollectionOfAssociations active requestor := thisContext sender receiver. "The requesting object does not require dynamic update behavior in which it needs to know a certain alternative" - SBExploriants objectToPermutation at: (requestor := thisContext sender receiver) ifAbsent: [^ defaultBehavior value]. + SBExploriants objectToPermutation at: requestor ifAbsent: [^ defaultBehavior value]. "The permutation is outdated and does not know this variant" (requiredPermutation := SBExploriants objectToPermutation at: requestor) at: uuid ifAbsent: [^ defaultBehavior value]. "An outdated permutation in which an alternative with a higher index than current has been deleted" From f30610ee8417c172879e64392a9839ea06a417aa Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Tue, 23 Apr 2024 17:37:05 +0200 Subject: [PATCH 2/4] Change permutation by clicking on label when original method and object have been closed --- .../SBExploriants.class.st | 13 ++++++++ .../SBExploriantsView.class.st | 6 ++++ .../SBMultiverse.class.st | 24 +++++++++++--- .../SBVariantsView.class.st | 31 +++++++++++++++--- packages/Sandblocks-Core/SBTabView.class.st | 2 ++ .../SBVariantProxy.class.st | 10 +++++- .../Sandblocks-Utils/SBPermutation.class.st | 32 ++++++++++++++++--- 7 files changed, 103 insertions(+), 15 deletions(-) diff --git a/packages/Sandblocks-Babylonian/SBExploriants.class.st b/packages/Sandblocks-Babylonian/SBExploriants.class.st index 0a9674c7..b213a77c 100644 --- a/packages/Sandblocks-Babylonian/SBExploriants.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriants.class.st @@ -93,6 +93,13 @@ SBExploriants >> buttonClass [ SBExploriants >> cacheType: aClass for: aBlock [ ] +{ #category : #actions } +SBExploriants >> changeIndexOf: aVariantId to: aNewIndex [ + + namedBlocks detect: #isVariantsView + ifFound: [:variantsView | variantsView changeIndexOf: aVariantId to: aNewIndex] +] + { #category : #testing } SBExploriants >> evaluationContext [ @@ -221,6 +228,12 @@ SBExploriants >> updateInBackgroundOnTimeoutRevertTo: theOldMultiverse [ ] forkAt: Processor userBackgroundPriority. ] +{ #category : #actions } +SBExploriants >> variantsView [ + + ^ namedBlocks detect: #isVariantsView +] + { #category : #actions } SBExploriants >> visualize [ diff --git a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st index 39160a95..6a06faa5 100644 --- a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st @@ -105,6 +105,12 @@ SBExploriantsView >> isOverview [ ^false ] +{ #category : #accessing } +SBExploriantsView >> isVariantsView [ + + ^ false +] + { #category : #accessing } SBExploriantsView >> multiverse [ diff --git a/packages/Sandblocks-Babylonian/SBMultiverse.class.st b/packages/Sandblocks-Babylonian/SBMultiverse.class.st index 84efba0e..b981f182 100644 --- a/packages/Sandblocks-Babylonian/SBMultiverse.class.st +++ b/packages/Sandblocks-Babylonian/SBMultiverse.class.st @@ -149,19 +149,33 @@ SBMultiverse >> findExistingOrConvertToBlocksMaintainingWatches: aCollectionOfCo { #category : #'initialize-release' } SBMultiverse >> gatherElements [ + universes := OrderedCollection new. + activeExamples := self allActiveExamples. + + self gatherVariants. + + self gatherWatches + +] + +{ #category : #'initialize-release' } +SBMultiverse >> gatherVariants [ + "We are looking for already opened methods so that we can assign the variant there as the original in SBVariantProxy. That way, we immediately have consistency between changes." allMethodBlocksContainingVariants := self findExistingOrConvertToBlocks: self allCompiledMethodsContainingVariants. - allMethodBlocksContainingWatches := self findExistingOrConvertToBlocksMaintainingWatches: self allCompiledMethodsContainingExampleWatches. - - universes := OrderedCollection new. - activeExamples := self allActiveExamples. - variants := (allMethodBlocksContainingVariants collect: #containedVariants) flatten. variants := variants select: #isActive. +] + +{ #category : #'initialize-release' } +SBMultiverse >> gatherWatches [ + + allMethodBlocksContainingWatches := self findExistingOrConvertToBlocksMaintainingWatches: self allCompiledMethodsContainingExampleWatches. + watches := (allMethodBlocksContainingWatches collect: [:aMethodBlock | | copies | copies := aMethodBlock containedExampleWatches. "Because the watches share the id, values would be reported to original too. Stop that" diff --git a/packages/Sandblocks-Babylonian/SBVariantsView.class.st b/packages/Sandblocks-Babylonian/SBVariantsView.class.st index 3c746903..8e576855 100644 --- a/packages/Sandblocks-Babylonian/SBVariantsView.class.st +++ b/packages/Sandblocks-Babylonian/SBVariantsView.class.st @@ -10,16 +10,25 @@ Class { { #category : #building } SBVariantsView >> buildMethodSectionFor: aSBStMethod [ + | newProxy | + newProxy := aSBStMethod containedVariants collect: #asProxy. contents addAllMorphsBack: {aSBStMethod methodDefinition. - self containerRow - addAllMorphsBack: (aSBStMethod containedVariants collect: #asProxy). + self containerRow addAllMorphsBack: newProxy. LineMorph from: 0@0 to: 50@0 color: Color black width: 2} ] { #category : #building } SBVariantsView >> buildNoVariantsText [ - contents addMorphBack: (SBOwnTextMorph new contents: 'No variants exist.') + contents addMorphBack: (SBOwnTextMorph new contents: 'No variation points exist.') +] + +{ #category : #actions } +SBVariantsView >> changeIndexOf: aVariantId to: aNewIndex [ + + self proxies + detect: [:aProxy | aProxy original id = aVariantId] + ifFound: [:theProxy | theProxy changeActiveIndexTo: aNewIndex ] ] { #category : #actions } @@ -27,7 +36,7 @@ SBVariantsView >> clean [ super clean. - contents submorphs copy do: #delete + contents submorphs copy do: #delete. ] @@ -38,7 +47,19 @@ SBVariantsView >> initialize [ contents := self containerRow listDirection: #topToBottom. - self name: 'Variants'. + self name: 'Variation Points'. +] + +{ #category : #accessing } +SBVariantsView >> isVariantsView [ + + ^ true +] + +{ #category : #actions } +SBVariantsView >> proxies [ + + ^ (contents allMorphs select: [:aMorph | aMorph isKindOf: SBVariantProxy]) ] { #category : #copying } diff --git a/packages/Sandblocks-Core/SBTabView.class.st b/packages/Sandblocks-Core/SBTabView.class.st index 01d450ea..3c76b136 100644 --- a/packages/Sandblocks-Core/SBTabView.class.st +++ b/packages/Sandblocks-Core/SBTabView.class.st @@ -174,6 +174,8 @@ SBTabView >> asTabButton: aNamedBlock [ { #category : #tabs } SBTabView >> basicSetActive: aNamedBlock [ + self sandblockEditor ifNil: [^ self activeIndex: (self namedBlocks indexOf: aNamedBlock ifAbsent: 1)]. + self sandblockEditor do: (self switchCommandFor: (self namedBlocks indexOf: aNamedBlock ifAbsent: 1)). diff --git a/packages/Sandblocks-Smalltalk/SBVariantProxy.class.st b/packages/Sandblocks-Smalltalk/SBVariantProxy.class.st index 7caf7153..51dd137c 100644 --- a/packages/Sandblocks-Smalltalk/SBVariantProxy.class.st +++ b/packages/Sandblocks-Smalltalk/SBVariantProxy.class.st @@ -16,7 +16,6 @@ SBVariantProxy class >> for: aVariant [ { #category : #callbacks } SBVariantProxy >> artefactChanged: anArtefact [ - anArtefact = self ifTrue: [self updateOriginalWithOwnValues ]. @@ -36,6 +35,15 @@ SBVariantProxy >> binding: aString for: block class: aClass ifPresent: aBlock [ ^ original binding: aString for: block class: aClass ifPresent: aBlock ] +{ #category : #accessing } +SBVariantProxy >> changeActiveIndexTo: aNewIndex [ + + self firstSubmorph switchToAlternativeWithoutSaving: aNewIndex. + self updateOriginalWithOwnValues + + +] + { #category : #accessing } SBVariantProxy >> containedMethod [ diff --git a/packages/Sandblocks-Utils/SBPermutation.class.st b/packages/Sandblocks-Utils/SBPermutation.class.st index 5e7a01e7..481021ca 100644 --- a/packages/Sandblocks-Utils/SBPermutation.class.st +++ b/packages/Sandblocks-Utils/SBPermutation.class.st @@ -52,15 +52,39 @@ SBPermutation >> activeScore [ { #category : #actions } SBPermutation >> apply [ + + self flag: #todo. "outdated references, jb" + (self referencedVariants anySatisfy: [:aVariant | aVariant sandblockEditor isNil]) + ifTrue: [ self applyWithOutdatedReferences ] + ifFalse: [ self applyOnOriginals ]. + + +] +{ #category : #private } +SBPermutation >> applyOnOriginals [ + self referencedVariants do: [:aVariant | aVariant switchToAlternativeWithoutSaving: (self at: aVariant id)]. SBExploriants uniqueInstance ignoreUpdate: true. ((self referencedVariants collect: #containingArtefact) asSet) do: [:aMethod | - self referencedVariants first sandblockEditor save: aMethod tryFixing: false quick: false]. + aMethod sandblockEditor save: aMethod tryFixing: false quick: false]. + (self referencedVariants collect: #sandblockEditor) do: #sendNewPermutationNotification + + +] + +{ #category : #private } +SBPermutation >> applyWithOutdatedReferences [ + + | newVariants | + self keys do: [:anId | SBExploriants uniqueInstance changeIndexOf: anId to: (self at: anId)]. + newVariants := SBExploriants uniqueInstance variantsView proxies collect: #original. + self referencedVariants do: [:aVariant | + newVariants detect: [:new | new id = aVariant id] + ifFound: [:theVariant | aVariant becomeForward: theVariant]]. + SBEditor current sendNewPermutationNotification + - ((Set newFrom: (referencedVariants collect: #sandblockEditor)) - reject: #isNil) - do: #sendNewPermutationNotification ] { #category : #converting } From ffb5756ad2ecb90669d61f9576f02d8a1385be79 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Tue, 7 May 2024 16:56:40 +0200 Subject: [PATCH 3/4] Code refactoring, new collection of all watches when multiverse is created --- .../Sandblocks-Babylonian/Morph.extension.st | 6 +++ .../SBCorrelationView.class.st | 4 +- .../SBExampleWatch.class.st | 14 ------ .../SBExploriants.class.st | 8 +++- .../SBGridResultsView.class.st | 3 +- .../SBMultiverse.class.st | 27 ++++-------- .../SBPlainResultsView.class.st | 2 +- .../SBSwitchableResultsView.class.st | 2 +- .../Sandblocks-Babylonian/SBTrace.class.st | 4 +- .../Sandblocks-Core/Collection.extension.st | 6 +-- .../Sandblocks-Smalltalk/SBVariant.class.st | 12 +++--- .../SBVariantProxy.class.st | 23 ++++++++-- .../Sandblocks-Utils/SBPermutation.class.st | 43 +++++++++++++------ .../Sandblocks-Watch/SBLineChart.class.st | 6 +-- .../Sandblocks-Watch/SBWatchView.class.st | 4 +- 15 files changed, 96 insertions(+), 68 deletions(-) diff --git a/packages/Sandblocks-Babylonian/Morph.extension.st b/packages/Sandblocks-Babylonian/Morph.extension.st index e7970c36..6cea1b56 100644 --- a/packages/Sandblocks-Babylonian/Morph.extension.st +++ b/packages/Sandblocks-Babylonian/Morph.extension.st @@ -12,6 +12,12 @@ Morph class >> exampleObject [ ^ self new ] +{ #category : #'*Sandblocks-Babylonian' } +Morph >> isVariantProxy [ + + ^ false +] + { #category : #'*Sandblocks-Babylonian' } Morph >> listensToPermutations [ diff --git a/packages/Sandblocks-Babylonian/SBCorrelationView.class.st b/packages/Sandblocks-Babylonian/SBCorrelationView.class.st index 47937be3..65a3acaa 100644 --- a/packages/Sandblocks-Babylonian/SBCorrelationView.class.st +++ b/packages/Sandblocks-Babylonian/SBCorrelationView.class.st @@ -29,7 +29,7 @@ SBCorrelationView >> buildForExample: anExample watching: aWatch [ self containerRow listDirection: #topToBottom; addAllMorphsBack: { SBOwnTextMorph new contents: ( - '{1}{2}' format: {"anExample label" ''. + '{1}{2}' format: {anExample label. (aWatch cleanedExpression sourceString withoutLineEndings)}). self containerRow listDirection: #topToBottom; @@ -113,7 +113,7 @@ SBCorrelationView >> changeVariants [ SBCorrelationView >> collectAllPermutationsOfSelectedVariants [ | allPermutations | - selectedVariants ifEmpty: [^ {SBNilPermutation new referencedVariants: {}} asSet]. + selectedVariants ifEmpty: [^ {SBPermutation singularity} asSet]. allPermutations := Set new. groupedUniverses first do: [:aUniverseContainingSelected | | base | base := SBPermutation new referencedVariants: selectedVariants. diff --git a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st index 7856135e..2df882ec 100644 --- a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st @@ -82,7 +82,6 @@ SBExampleWatch class >> report: aValue for: aSymbol modifying: aBlock [ example := SBExecutionEnvironment value ifNil: [^ aValue]. watchers := self registry select: [:watcher | watcher notNil and: [watcher identifier = aSymbol] - and: [watcher ignoreReports not] and: [watcher isActive]]. watchers do: [:watcher | watcher reportValue: aValue asSBWatchValue for: example]. @@ -248,7 +247,6 @@ SBExampleWatch >> exampleFinished: anExample [ SBExampleWatch >> exampleStarting: anExample [ exampleToValues at: anExample put: OrderedCollection new. - self ignoreReports: false. (exampleToDisplay at: anExample ifAbsentPut: [self buildDefaultDisplayFor: anExample]) exampleStarting: anExample; @@ -326,18 +324,6 @@ SBExampleWatch >> identifier: aSymbol [ self world ifNotNil: [self class registerWatch: self] ] -{ #category : #accessing } -SBExampleWatch >> ignoreReports [ - - ^ ignoreReports -] - -{ #category : #accessing } -SBExampleWatch >> ignoreReports: aBoolean [ - - ignoreReports := aBoolean -] - { #category : #initialization } SBExampleWatch >> initialize [ diff --git a/packages/Sandblocks-Babylonian/SBExploriants.class.st b/packages/Sandblocks-Babylonian/SBExploriants.class.st index b213a77c..5ff7562e 100644 --- a/packages/Sandblocks-Babylonian/SBExploriants.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriants.class.st @@ -112,6 +112,12 @@ SBExploriants >> evaluationReceiver [ ^ self object ] +{ #category : #accessing } +SBExploriants >> generationTimeout [ + + ^ 20 seconds +] + { #category : #accessing } SBExploriants >> ignoreUpdate [ @@ -221,7 +227,7 @@ SBExploriants >> updateInBackgroundOnTimeoutRevertTo: theOldMultiverse [ newMultiverse := SBMultiverse bigbangInEditorWithoutKaboom: self sandblockEditor. self namedBlocks do: [:aTab | aTab multiverse: newMultiverse]. [newMultiverse kaboom] - valueWithin: 20 seconds + valueWithin: self generationTimeout onTimeout: [newMultiverse cleanUp. self namedBlocks do: [:aTab | aTab multiverse: theOldMultiverse]]. updateProcess := nil. updateProcessRunning := false. diff --git a/packages/Sandblocks-Babylonian/SBGridResultsView.class.st b/packages/Sandblocks-Babylonian/SBGridResultsView.class.st index c1a41922..40fd8f57 100644 --- a/packages/Sandblocks-Babylonian/SBGridResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBGridResultsView.class.st @@ -54,5 +54,6 @@ SBGridResultsView >> newGridContainer [ SBGridResultsView >> visualize [ super visualize. - self concludeContainerWidth + self concludeContainerWidth. + ] diff --git a/packages/Sandblocks-Babylonian/SBMultiverse.class.st b/packages/Sandblocks-Babylonian/SBMultiverse.class.st index b981f182..1d0ad11a 100644 --- a/packages/Sandblocks-Babylonian/SBMultiverse.class.st +++ b/packages/Sandblocks-Babylonian/SBMultiverse.class.st @@ -116,10 +116,7 @@ SBMultiverse >> asyncKaboom [ SBMultiverse >> cleanUp [ watches do: #resumeGraphicalUpdates. - (watches select: [:anOpenWatch | anOpenWatch containingArtefact isNil]) copy do: #delete. - watches select: #isInEditor thenDo: [:aWatch | aWatch exampleToDisplay values do: #updateDisplay]. - allMethodBlocksContainingWatches do: [:aMethodBlock | - (aMethodBlock valueOfProperty: #originals) do: [:aWatch| aWatch ignoreReports: false]]. + watches reject: #isInEditor thenDo: [:aWatch | SBExampleWatch unregisterWatch: aWatch]. ] { #category : #collecting } @@ -174,16 +171,9 @@ SBMultiverse >> gatherVariants [ { #category : #'initialize-release' } SBMultiverse >> gatherWatches [ - allMethodBlocksContainingWatches := self findExistingOrConvertToBlocksMaintainingWatches: self allCompiledMethodsContainingExampleWatches. + allMethodBlocksContainingWatches := self findExistingOrConvertToBlocks: self allCompiledMethodsContainingExampleWatches. - watches := (allMethodBlocksContainingWatches collect: [:aMethodBlock | | copies | - copies := aMethodBlock containedExampleWatches. - "Because the watches share the id, values would be reported to original too. Stop that" - (aMethodBlock valueOfProperty: #originals) do: [:aWatch| aWatch ignoreReports: true]. - (aMethodBlock valueOfProperty: #originals) withIndexDo: [:original :i | (copies at: i) copySelectedDisplayIndicesFrom: original]. - copies ]) flatten. - watches do: [:aWatch | activeExamples do: [:anExample | aWatch exampleStarting: anExample]]. - watches reject: #isInEditor thenDo: [:aWatch | aWatch hide. aWatch extent: 1@1] + watches := (allMethodBlocksContainingWatches collect: #containedExampleWatches) flatten. ] @@ -198,15 +188,16 @@ SBMultiverse >> initialize [ { #category : #actions } SBMultiverse >> kaboom [ - | outOfWorldWatches permutations | - "Only open watches display values when examples are run. We want to show them too" - (outOfWorldWatches := watches reject: #isInEditor) do: [:aWatch | self sandblockEditor openMorph: aWatch]. - permutations := (SBPermutation allPermutationsOf: variants). + | permutations | watches do: #stopGraphicalUpdates. + watches reject: #isInEditor thenDo: [:aWatch | + SBExampleWatch registerWatch: aWatch. + activeExamples do: [:anExample | aWatch exampleStarting: anExample]]. + permutations := (SBPermutation allPermutationsOf: variants). "Running the active one last" (permutations sorted: [:a :b | a activeScore <= b activeScore ] ) do: [:aPermutation | - self runPermutation: aPermutation copyingWatches: watches ]. + self runPermutation: aPermutation copyingWatches: watches]. "but stay consistent of the permutation sequences for alignment in clusters" "sorting this is cheaper than running a permutation twice just to reset to prior state" diff --git a/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st b/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st index d22ff1b5..db52c0dc 100644 --- a/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st @@ -24,5 +24,5 @@ SBPlainResultsView >> initialize [ super initialize. - self name: 'Watches' + self name: 'Probes' ] diff --git a/packages/Sandblocks-Babylonian/SBSwitchableResultsView.class.st b/packages/Sandblocks-Babylonian/SBSwitchableResultsView.class.st index a186cf87..33fe624a 100644 --- a/packages/Sandblocks-Babylonian/SBSwitchableResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBSwitchableResultsView.class.st @@ -58,7 +58,7 @@ SBSwitchableResultsView >> toggleViewButton [ ^ SBButton new icon: self toggleIcon - label: 'Group By Watches <> In Execution Order' + label: 'Group By Probes <> In Execution Order' do: [self toggleView]; cornerStyle: #squared ] diff --git a/packages/Sandblocks-Babylonian/SBTrace.class.st b/packages/Sandblocks-Babylonian/SBTrace.class.st index 84f0f4d5..5c9c80c0 100644 --- a/packages/Sandblocks-Babylonian/SBTrace.class.st +++ b/packages/Sandblocks-Babylonian/SBTrace.class.st @@ -60,8 +60,8 @@ SBTrace >> sortedWatchValuesFor: anExample givenWatches: aCollectionOfWatches [ | allValues | allValues := SortedCollection sortBlock: [:a :b | a tracePosition <= b tracePosition]. aCollectionOfWatches do: [:aWatch | - aWatch exampleToValues at: anExample - ifPresent: [:aCollectionOfWatchValues | allValues addAll: aCollectionOfWatchValues ] + aWatch exampleToDisplay at: anExample + ifPresent: [:aDisplay | allValues addAll: aDisplay value display watchValues ] ifAbsent: [{}]]. ^ allValues ] diff --git a/packages/Sandblocks-Core/Collection.extension.st b/packages/Sandblocks-Core/Collection.extension.st index af15603e..67f4ef19 100644 --- a/packages/Sandblocks-Core/Collection.extension.st +++ b/packages/Sandblocks-Core/Collection.extension.st @@ -5,7 +5,7 @@ Collection >> asBarChart: converter [ converter - if: [self isString not and: [self allSatisfy: SBBarChart supportedInterface]] + if: [self allSatisfy: SBBarChart supportedInterface] do: [SBBarChart newWithValues: self] ] @@ -23,7 +23,7 @@ Collection >> asLineChart: converter [ converter - if: [self isString not and: [self allSatisfy: SBLineChart supportedInterface]] + if: [self allSatisfy: SBLineChart supportedInterface] do: [SBLineChart newWithValues: self] ] @@ -32,7 +32,7 @@ Collection >> asRectangleChart: converter [ converter - if: [self isString not and: [self isDictionary not and: [self allSatisfy: SBRectangleChart supportedInterface]]] + if: [self allSatisfy: SBRectangleChart supportedInterface] do: [SBRectangleChart newWithValues: self] ] diff --git a/packages/Sandblocks-Smalltalk/SBVariant.class.st b/packages/Sandblocks-Smalltalk/SBVariant.class.st index 73b9a694..bcd767c3 100644 --- a/packages/Sandblocks-Smalltalk/SBVariant.class.st +++ b/packages/Sandblocks-Smalltalk/SBVariant.class.st @@ -181,11 +181,7 @@ SBVariant >> allPermutations: allPermutations currentPath: aPermutation [ ifEmpty: [allPermutations add: currentPath] ifNotEmpty: [:childVariants | | permutations nestedPermutations | nestedPermutations := childVariants collect: [:child | child allPermutations: OrderedCollection new currentPath: currentPath]. - permutations := nestedPermutations first. - (2 to: topLevelVariants size) do: [:index | | nestedPermutation | - nestedPermutation := nestedPermutations at: index. - permutations := permutations gather: [:aNestedPermutation | - nestedPermutation collect: [:aNestedNestedPermutation | SBPermutation newCombinedOf: aNestedPermutation and: aNestedNestedPermutation]]]. + permutations := SBPermutation combineAllIn: nestedPermutations. allPermutations addAll: permutations. permutations ]] ] @@ -263,6 +259,12 @@ SBVariant >> color [ ^ Color transparent ] +{ #category : #accessing } +SBVariant >> hasParent [ + + ^ self parentVariant isNil not +] + { #category : #accessing } SBVariant >> id [ ^ id diff --git a/packages/Sandblocks-Smalltalk/SBVariantProxy.class.st b/packages/Sandblocks-Smalltalk/SBVariantProxy.class.st index 51dd137c..ad38de5d 100644 --- a/packages/Sandblocks-Smalltalk/SBVariantProxy.class.st +++ b/packages/Sandblocks-Smalltalk/SBVariantProxy.class.st @@ -14,6 +14,12 @@ SBVariantProxy class >> for: aVariant [ ^ self new for: aVariant ] +{ #category : #accessing } +SBVariantProxy >> activeIndex [ + + ^ original activeIndex +] + { #category : #callbacks } SBVariantProxy >> artefactChanged: anArtefact [ @@ -60,6 +66,12 @@ SBVariantProxy >> for: aVariant [ self addMorphBack: original copyBlock. ] +{ #category : #accessing } +SBVariantProxy >> id [ + + ^ original id +] + { #category : #initialization } SBVariantProxy >> initialize [ @@ -79,6 +91,12 @@ SBVariantProxy >> isArtefact [ ^ true ] +{ #category : #testing } +SBVariantProxy >> isVariantProxy [ + + ^ true +] + { #category : #accessing } SBVariantProxy >> original [ @@ -106,12 +124,11 @@ SBVariantProxy >> updateOriginalWithOwnValues [ | variantThatNeedsChanging | variantThatNeedsChanging := self containedMethod detectVariant: original. - variantThatNeedsChanging ifNil: [^self delete]. original replaceBy: (original := self firstSubmorph copyBlock). - original isVariant - ifFalse: [ + "If a double click on the widget occured and it replaced itself with code or text" + original isVariant ifFalse: [ self containedMethod save. ^ self delete]. diff --git a/packages/Sandblocks-Utils/SBPermutation.class.st b/packages/Sandblocks-Utils/SBPermutation.class.st index 481021ca..be41683a 100644 --- a/packages/Sandblocks-Utils/SBPermutation.class.st +++ b/packages/Sandblocks-Utils/SBPermutation.class.st @@ -14,19 +14,32 @@ Class { { #category : #utils } SBPermutation class >> allPermutationsOf: aCollectionOfVariants [ - | permutations topLevelVariants nestedPermutations | - aCollectionOfVariants ifEmpty:[^{SBNilPermutation new referencedVariants: {}}]. - topLevelVariants := aCollectionOfVariants select: [:aVariant | aVariant parentVariant isNil]. + | topLevelVariants nestedPermutations | + aCollectionOfVariants ifEmpty:[^{SBPermutation singularity}]. + topLevelVariants := aCollectionOfVariants reject: #hasParent. nestedPermutations := topLevelVariants collect: #allPermutations. - permutations := nestedPermutations first. - (2 to: topLevelVariants size) do: [:i | | nestedPermutation | - nestedPermutation := (nestedPermutations at: i). - permutations := permutations gather: [:aPermutation | - nestedPermutation collect: [:aNestedPermutation | self newCombinedOf: aPermutation and: aNestedPermutation]]]. - - ^ permutations - + ^ SBPermutation combineAllIn: nestedPermutations. +] + +{ #category : #utils } +SBPermutation class >> combine: aPermutation withAll: aCollectionOfPermutations [ + + ^ aCollectionOfPermutations collect: [:anotherPermutation | + self newCombinedOf: aPermutation and: anotherPermutation] +] + +{ #category : #utils } +SBPermutation class >> combineAllIn: aCollectionOfNestedPermutations [ + + | combinedPermutations | + combinedPermutations := aCollectionOfNestedPermutations first. + (2 to: aCollectionOfNestedPermutations size) do: [:index | | aCollectionOfPermutations | + aCollectionOfPermutations := aCollectionOfNestedPermutations at: index. + combinedPermutations := combinedPermutations gather: [:aPermutation | + SBPermutation combine: aPermutation withAll: aCollectionOfPermutations]]. + + ^ combinedPermutations ] { #category : #utils } @@ -42,6 +55,12 @@ SBPermutation class >> newCombinedOf: onePermutation and: anotherPermutation [ ] +{ #category : #utils } +SBPermutation class >> singularity [ + + ^ SBNilPermutation new referencedVariants: {} +] + { #category : #accessing } SBPermutation >> activeScore [ @@ -151,7 +170,7 @@ SBPermutation >> copyRemovingVariants: aCollectionOfVariants [ | copy | copy := self class new. copy referencedVariants: (self referencedVariants reject: [:aVariant | aCollectionOfVariants includes: aVariant]). - copy referencedVariants ifEmpty: [^ SBNilPermutation new referencedVariants: {}]. + copy referencedVariants ifEmpty: [^ SBPermutation singularity]. "copy := self veryDeepCopy. copy referencedVariants: (copy referencedVariants difference: aCollectionOfVariants)." diff --git a/packages/Sandblocks-Watch/SBLineChart.class.st b/packages/Sandblocks-Watch/SBLineChart.class.st index e341c9ec..f07e4e7c 100644 --- a/packages/Sandblocks-Watch/SBLineChart.class.st +++ b/packages/Sandblocks-Watch/SBLineChart.class.st @@ -35,7 +35,7 @@ SBLineChart >> datapointDefaultColor [ { #category : #'visualization - constants' } SBLineChart >> datapointExtent [ - ^ 2@2 + ^ 3@3 sbScaled ] { #category : #geometry } @@ -60,7 +60,7 @@ SBLineChart >> lineColorFrom: aDataPoint1 to: aDataPoint2 [ { #category : #'visualization - constants' } SBLineChart >> lineWidth [ - ^ 2 + ^ 2 sbScaled ] { #category : #'visualization - constants' } @@ -166,7 +166,7 @@ SBLineChart >> positiveGradientColor [ { #category : #'visualization - constants' } SBLineChart >> spaceBetweenPoints [ - ^ 6 + ^ 6 sbScaled ] { #category : #visualization } diff --git a/packages/Sandblocks-Watch/SBWatchView.class.st b/packages/Sandblocks-Watch/SBWatchView.class.st index da79ce91..2fabfc8c 100644 --- a/packages/Sandblocks-Watch/SBWatchView.class.st +++ b/packages/Sandblocks-Watch/SBWatchView.class.st @@ -263,7 +263,7 @@ SBWatchView >> layoutCommands [ { #category : #layout } SBWatchView >> maxWidth [ - ^ 350 + ^ 350 sbScaled ] { #category : #'object interface' } @@ -309,7 +309,7 @@ SBWatchView >> reportValues: aCollectionOfWatchValues sized: aMorphResizer [ SBWatchView >> resetOnlyValues [ "Private" - count contents: '0'. + shouldUpdateDisplay ifTrue: [count contents: '0']. watchValues := LinkedList new. ] From 020c41cd8176a913ba490f88bf8b4ecd060f7c27 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Mon, 13 May 2024 15:58:33 +0200 Subject: [PATCH 4/4] Fix format --- packages/Sandblocks-Babylonian/SBCorrelationView.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/Sandblocks-Babylonian/SBCorrelationView.class.st b/packages/Sandblocks-Babylonian/SBCorrelationView.class.st index 65a3acaa..b8149d4e 100644 --- a/packages/Sandblocks-Babylonian/SBCorrelationView.class.st +++ b/packages/Sandblocks-Babylonian/SBCorrelationView.class.st @@ -29,7 +29,7 @@ SBCorrelationView >> buildForExample: anExample watching: aWatch [ self containerRow listDirection: #topToBottom; addAllMorphsBack: { SBOwnTextMorph new contents: ( - '{1}{2}' format: {anExample label. + '{1} {2}' format: {anExample label. (aWatch cleanedExpression sourceString withoutLineEndings)}). self containerRow listDirection: #topToBottom;