Skip to content

Commit

Permalink
Exploriants can now handle no variants
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeAtHPI committed Oct 11, 2023
1 parent 872cab9 commit 02ee4cf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/Sandblocks-Babylonian/SBResultsView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ Class {
#category : #'Sandblocks-Babylonian'
}

{ #category : #building }
SBResultsView >> addAllWatchesFrom: aCollectionOfMethodBlocks [

self block addAllMorphsBack: { (self containerRow listDirection: #leftToRight)
addAllMorphsBack: (self allWatchesIn: aCollectionOfMethodBlocks).
LineMorph from: 0@0 to: 50@0 color: Color black width: 2}
]

{ #category : #accessing }
SBResultsView >> allActiveExamples [

Expand Down Expand Up @@ -65,6 +73,8 @@ SBResultsView >> buildAllPossibleResults [
activeExamples := self allActiveExamples.
permutations := SBPermutation allPermutationsOf: variants.

permutations ifEmpty: [self addAllWatchesFrom: watchMethodBlocks].

[ permutations do: [:aPermutation |
SBActiveVariantPermutation value: aPermutation.
activeExamples do: #runSynchronouslyIgnoreReturn.
Expand Down
10 changes: 9 additions & 1 deletion packages/Sandblocks-Babylonian/SBVariantsView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ SBVariantsView >> buildMethodSectionFor: aSBStMethod [
LineMorph from: 0@0 to: 50@0 color: Color black width: 2}
]

{ #category : #building }
SBVariantsView >> buildNoVariantsText [

self block addMorphBack: (SBOwnTextMorph new contents: 'No variants exist.')
]

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

Expand All @@ -28,5 +34,7 @@ SBVariantsView >> visualize [

self clean.

self allMethodBlocksContainingVariants do: [:aSBStMethod | self buildMethodSectionFor: aSBStMethod]
self allMethodBlocksContainingVariants
ifNotEmptyDo: [:aSBStMethod | self buildMethodSectionFor: aSBStMethod]
ifEmpty: [self buildNoVariantsText]
]
1 change: 1 addition & 0 deletions packages/Sandblocks-Utils/SBPermutation.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Class {
SBPermutation class >> allPermutationsOf: aCollectionOfVariants [

| permutations |
aCollectionOfVariants ifEmpty:[^#()].
permutations := (1 to: aCollectionOfVariants first alternativesCount) collect: #asArray.

(2 to: aCollectionOfVariants size) do: [:i | | alternatives |
Expand Down

0 comments on commit 02ee4cf

Please sign in to comment.