Skip to content

Commit

Permalink
Block which opens all methods containing variants
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeAtHPI committed Aug 17, 2023
1 parent 5c9c15c commit 9ace940
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/Sandblocks-Core/SBBlock.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,12 @@ SBBlock >> isValidAction: aPragmaOrMethod [
^ validMode and: [validInvocation]
]

{ #category : #testing }
SBBlock >> isVariant [

^ false
]

{ #category : #testing }
SBBlock >> isWatch [

Expand Down
30 changes: 30 additions & 0 deletions packages/Sandblocks-Core/SBEditor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,36 @@ SBEditor >> openAll: aCollection [
aCollection do: [:object | self open: object]
]

{ #category : #actions }
SBEditor >> openExploriants [
<globalAction>

SBExploriants openIn: self

"| allCompiledMethodsContainingVariants |
allCompiledMethodsContainingVariants := ((self systemNavigation allCallsOn: #named:associations:activeIndex:)
reject: [:aMethodReference | aMethodReference methodSymbol = #openExploriants])
collect: #compiledMethod.
allCompiledMethodsContainingVariants
collect: #asSandblock
thenDo: [:aSBStMethod |
aSBStMethod body allMorphsMutableDo: [:aMorph | aMorph visible: false].
aSBStMethod containedVariants
do: [:aVariant | |current|
current := aVariant.
[current := current owner]
doWhileFalse: [current = aSBStMethod].
current submorphsDo: [:m| m visible: true]].
self openMorphInView: aSBStMethod]."

"collect: [:aMethodBlock | aMethodBlock allMorphs
select: [:aMorph | aMorph submorphs
ifEmpty: [false]
ifNotEmpty: [(aMorph submorphOfClass: SBVariant) isNil not]]]
thenDo: [:aCollectionOfOwnersOfVariants | aCollectionOfOwnersOfVariants do: [:aVariantOwner| self openMorphInView: aVariantOwner]]"
]

{ #category : #'actions creating' }
SBEditor >> openFile [
<addAction>
Expand Down
52 changes: 52 additions & 0 deletions packages/Sandblocks-Core/SBExploriants.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Class {
#name : #SBExploriants,
#superclass : #SBBlock,
#category : #'Sandblocks-Core'
}

{ #category : #'as yet unclassified' }
SBExploriants class >> openIn: anEditor [

(self new visualize) openIn: anEditor
]

{ #category : #'as yet unclassified' }
SBExploriants >> allMethodsContainingVariants [

^ ((self systemNavigation allCallsOn: SBVariant matchingSelector)
reject: [:aMethodReference | aMethodReference actualClass = SBVariant class])
collect: #compiledMethod
]

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

super initialize.

self
attachDecorator: SBMoveDecorator new;
attachDecorator: SBResizableDecorator new;
changeTableLayout;
listDirection: #topToBottom;
layoutInset: 8;
cellGap: 16;
hResizing: #shrinkWrap;
vResizing: #shrinkWrap
]

{ #category : #'as yet unclassified' }
SBExploriants >> openIn: anEditor [

anEditor openMorphInView: self
]

{ #category : #'as yet unclassified' }
SBExploriants >> visualize [

self allMethodsContainingVariants
collect: #asSandblock
thenDo: [:aSBStMethod | self addMorphBack: aSBStMethod].



]
14 changes: 13 additions & 1 deletion packages/Sandblocks-Smalltalk/SBVariant.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ SBVariant class >> matches: aBlock [

^ aBlock receiver isBinding
and: [aBlock receiver contents = 'SBVariant']
and: [aBlock selector = 'named:associations:activeIndex:']
and: [aBlock selector = self matchingSelector]
]

{ #category : #constants }
SBVariant class >> matchingSelector [

^ #named:associations:activeIndex:
]

{ #category : #'instance creation' }
Expand Down Expand Up @@ -134,6 +140,12 @@ SBVariant >> initialize [
hResizing: #shrinkWrap
]

{ #category : #testing }
SBVariant >> isVariant [

^ true
]

{ #category : #accessing }
SBVariant >> name [

Expand Down

0 comments on commit 9ace940

Please sign in to comment.