Skip to content

Commit

Permalink
merge with spec 0.6 (preview)
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanlm committed May 8, 2020
1 parent 1a9014f commit be896fe
Show file tree
Hide file tree
Showing 198 changed files with 3,519 additions and 3,000 deletions.
Expand Up @@ -33,11 +33,12 @@ SpContactBookPresenter class >> buildCommandsGroupWith: presenterIntance forRoot
]

{ #category : #commands }
SpContactBookPresenter class >> buildContextualMenuGroupWith: presenterIntance [
SpContactBookPresenter class >> buildContextualMenuGroupWith: presenterInstance [

^ (CmCommandGroup named: 'Context Menu') asSpecGroup
register: (self buildEditionGroupWith: presenterIntance);
register: (self buildAddingGroupWith: presenterIntance);
register: (self buildRemovingGroupWith: presenterIntance);
register: (self buildEditionGroupWith: presenterInstance);
register: (self buildAddingGroupWith: presenterInstance);
register: (self buildRemovingGroupWith: presenterInstance);
yourself
]

Expand Down
Expand Up @@ -28,7 +28,7 @@ CmUILeftPositionStrategyExtensionsTest >> testAddButtonToActionBar [
CmUILeftPositionStrategyExtensionsTest >> testAddButtonToToolbar [
| toolbar button |
toolbar := SpToolBarPresenter new.
button := SpToolBarButton new.
button := SpToolBarButtonPresenter new.

self assertEmpty: toolbar items.

Expand Down
Expand Up @@ -28,7 +28,7 @@ CmUIRightPositionStrategyExtensionsTest >> testAddButtonToActionBar [
CmUIRightPositionStrategyExtensionsTest >> testAddButtonToToolbar [
| toolbar button |
toolbar := SpToolBarPresenter new.
button := SpToolBarButton new.
button := SpToolBarButtonPresenter new.

self assertEmpty: toolbar items.

Expand Down
22 changes: 20 additions & 2 deletions src/Spec2-Commander2-Tests/SpCommandTest.class.st
Expand Up @@ -71,6 +71,24 @@ SpCommandTest >> testAsButtonPresenterExecutesOnClick [
self assert: flag equals: true
]

{ #category : #test }
SpCommandTest >> testCanUpdateEnableStatus [
| buttonPresenter shouldBeAvailable |
shouldBeAvailable := true.
command := CmBlockCommand new
canBeExecutedBlock: [ :ctx | shouldBeAvailable ];
context: #foo; "need a conext for #canBeExecuted to be performed"
yourself.
command := command asSpecCommand.
buttonPresenter := command asButtonPresenter.
self assert: buttonPresenter isEnabled.

shouldBeAvailable := false.
command updateEnableStatus.

self deny: buttonPresenter isEnabled
]

{ #category : #test }
SpCommandTest >> testConfigureAsButton [
| button |
Expand Down Expand Up @@ -118,7 +136,7 @@ SpCommandTest >> testConfigureAsToolBarButton [
configureAsToolBarButton;
buildPresenter.

self assert: button class equals: SpToolBarButton.
self assert: button class equals: SpToolBarButtonPresenter.
self assert: button label equals: command name.
self assert: button help equals: command description.
self assert: button icon isNil.
Expand All @@ -138,7 +156,7 @@ SpCommandTest >> testConfigureAsToolBarToggleButton [
configureAsToolBarToggleButton;
buildPresenter.

self assert: button class equals: SpToolBarToggleButton.
self assert: button class equals: SpToolBarToggleButtonPresenter.
self assert: button label equals: command name.
self assert: button help equals: command description.
self assert: button icon isNil.
Expand Down
19 changes: 15 additions & 4 deletions src/Spec2-Commander2/SpCommand.class.st
Expand Up @@ -12,7 +12,8 @@ Class {
#name : #SpCommand,
#superclass : #CmUICommand,
#instVars : [
'buildPresenterBlock'
'buildPresenterBlock',
'presenter'
],
#category : #'Spec2-Commander2-Core'
}
Expand All @@ -26,7 +27,7 @@ SpCommand >> asButtonPresenter [

{ #category : #'presenter building' }
SpCommand >> buildPresenter [
^ self buildPresenterBlock value: self
^ presenter := self buildPresenterBlock value: self
]

{ #category : #accessing }
Expand Down Expand Up @@ -60,12 +61,12 @@ SpCommand >> configureAsButtonOfClass: aButtonClass [

{ #category : #'presenter building' }
SpCommand >> configureAsToolBarButton [
self configureAsButtonOfClass: SpToolBarButton
self configureAsButtonOfClass: SpToolBarButtonPresenter
]

{ #category : #'presenter building' }
SpCommand >> configureAsToolBarToggleButton [
self configureAsButtonOfClass: SpToolBarToggleButton
self configureAsButtonOfClass: SpToolBarToggleButtonPresenter
]

{ #category : #displaying }
Expand All @@ -82,3 +83,13 @@ SpCommand >> initialize [
super initialize.
self configureAsToolBarButton
]

{ #category : #accessing }
SpCommand >> presenter [
^ presenter
]

{ #category : #updating }
SpCommand >> updateEnableStatus [
self presenter enabled: self canBeExecuted
]
1 change: 1 addition & 0 deletions src/Spec2-Commander2/SpCommandGroup.class.st
Expand Up @@ -39,6 +39,7 @@ SpCommandGroup >> asMenuBarPresenterWith: aBlock [

{ #category : #converting }
SpCommandGroup >> asMenuPresenter [

^ SpMenuPresenterBuilder new
visit: self;
menuPresenter
Expand Down
5 changes: 4 additions & 1 deletion src/Spec2-Commander2/SpPresenter.extension.st
Expand Up @@ -35,5 +35,8 @@ SpPresenter >> defaultCommandsContext [

{ #category : #'*Spec2-Commander2' }
SpPresenter >> rootCommandsGroup [
^ SpRecursiveContextSetter visit: (self class buildRootCommandsGroupFor: self defaultCommandsContext) toSetContext: self defaultCommandsContext

^ SpRecursiveContextSetter
visit: (self class buildRootCommandsGroupFor: self defaultCommandsContext)
toSetContext: self defaultCommandsContext
]
3 changes: 2 additions & 1 deletion src/Spec2-Commands/SpBrowseClassCommand.class.st
Expand Up @@ -29,5 +29,6 @@ SpBrowseClassCommand class >> shortName [

{ #category : #execution }
SpBrowseClassCommand >> execute [
self context ifNotNil: [ :ctx | ctx browse ]

self target ifNotNil: [ :aTarget | aTarget browse ]
]
3 changes: 2 additions & 1 deletion src/Spec2-Commands/SpBrowseClassHierarchyCommand.class.st
Expand Up @@ -20,5 +20,6 @@ SpBrowseClassHierarchyCommand class >> shortName [

{ #category : #executing }
SpBrowseClassHierarchyCommand >> execute [
self systemNavigation browseHierarchy: self context

self systemNavigation browseHierarchy: self target
]
3 changes: 2 additions & 1 deletion src/Spec2-Commands/SpBrowseClassReferencesCommand.class.st
Expand Up @@ -21,7 +21,8 @@ SpBrowseClassReferencesCommand class >> shortName [
{ #category : #execution }
SpBrowseClassReferencesCommand >> execute [
| class |
class := self context instanceSide.

class := self target instanceSide.
class isTrait
ifTrue: [ self systemNavigation browseAllUsersOfTrait: class ]
ifFalse: [ self systemNavigation browseAllCallsOnClass: class ]
Expand Down
3 changes: 2 additions & 1 deletion src/Spec2-Commands/SpBrowseClassVarRefsCommand.class.st
Expand Up @@ -21,5 +21,6 @@ SpBrowseClassVarRefsCommand class >> shortName [

{ #category : #executing }
SpBrowseClassVarRefsCommand >> execute [
self systemNavigation browseClassVarRefs: self context

self systemNavigation browseClassVarRefs: self target
]
5 changes: 3 additions & 2 deletions src/Spec2-Commands/SpBrowseClassVariablesCommand.class.st
Expand Up @@ -19,6 +19,7 @@ SpBrowseClassVariablesCommand class >> shortName [
]

{ #category : #executing }
SpBrowseClassVariablesCommand >> execute [
self systemNavigation browseClassVariables: self context
SpBrowseClassVariablesCommand >> execute [

self systemNavigation browseClassVariables: self target
]
1 change: 1 addition & 0 deletions src/Spec2-Commands/SpBrowseImplementorsCommand.class.st
Expand Up @@ -28,5 +28,6 @@ SpBrowseImplementorsCommand class >> shortName [

{ #category : #executing }
SpBrowseImplementorsCommand >> execute [

self systemNavigation browseAllImplementorsOf: self selector
]
2 changes: 1 addition & 1 deletion src/Spec2-Commands/SpBrowseInstVarRefsCommand.class.st
Expand Up @@ -21,5 +21,5 @@ SpBrowseInstVarRefsCommand class >> shortName [

{ #category : #executing }
SpBrowseInstVarRefsCommand >> execute [
self systemNavigation browseInstVarRefs: self context
self systemNavigation browseInstVarRefs: self target
]
3 changes: 2 additions & 1 deletion src/Spec2-Commands/SpBrowseInstancesCommand.class.st
Expand Up @@ -20,5 +20,6 @@ SpBrowseInstancesCommand class >> shortName [

{ #category : #executing }
SpBrowseInstancesCommand >> execute [
self context instanceSide inspectAllInstances

self target instanceSide inspectAllInstances
]
4 changes: 2 additions & 2 deletions src/Spec2-Commands/SpBrowseMethodInheritanceCommand.class.st
Expand Up @@ -21,6 +21,6 @@ SpBrowseMethodInheritanceCommand class >> shortName [
{ #category : #executing }
SpBrowseMethodInheritanceCommand >> execute [
self systemNavigation
methodHierarchyBrowserForClass: self context methodClass
selector: self context selector
methodHierarchyBrowserForClass: self target methodClass
selector: self target selector
]
Expand Up @@ -20,5 +20,6 @@ SpBrowseMethodReferencesCommand class >> shortName [

{ #category : #executing }
SpBrowseMethodReferencesCommand >> execute [

self systemNavigation browseAllReferencesTo: self selector
]
7 changes: 5 additions & 2 deletions src/Spec2-Commands/SpBrowseMethodVersionsCommand.class.st
Expand Up @@ -20,7 +20,10 @@ SpBrowseMethodVersionsCommand class >> shortName [

{ #category : #executing }
SpBrowseMethodVersionsCommand >> execute [
| target |

target := self target.
Smalltalk tools versionBrowser
browseVersionsForClass: self context methodClass
selector: self context selector
browseVersionsForClass: target methodClass
selector: target selector
]
Expand Up @@ -20,5 +20,8 @@ SpBrowseMethodsContainingStringCommand class >> shortName [

{ #category : #executing }
SpBrowseMethodsContainingStringCommand >> execute [
self systemNavigation browseMethodsWithSourceString: self context matchCase: false

self systemNavigation
browseMethodsWithSourceString: self target
matchCase: false
]
3 changes: 2 additions & 1 deletion src/Spec2-Commands/SpBrowsePointersToCommand.class.st
Expand Up @@ -20,5 +20,6 @@ SpBrowsePointersToCommand class >> shortName [

{ #category : #executing }
SpBrowsePointersToCommand >> execute [
self context pointersTo inspect

self target pointersTo inspect
]
1 change: 1 addition & 0 deletions src/Spec2-Commands/SpBrowseSendersCommand.class.st
Expand Up @@ -28,5 +28,6 @@ SpBrowseSendersCommand class >> shortName [

{ #category : #executing }
SpBrowseSendersCommand >> execute [

self systemNavigation browseAllSendersOf: self selector
]
3 changes: 2 additions & 1 deletion src/Spec2-Commands/SpBrowseSubInstancesCommand.class.st
Expand Up @@ -20,5 +20,6 @@ SpBrowseSubInstancesCommand class >> shortName [

{ #category : #executing }
SpBrowseSubInstancesCommand >> execute [
self context instanceSide inspectSubInstances

self target instanceSide inspectSubInstances
]
63 changes: 61 additions & 2 deletions src/Spec2-Commands/SpCodeDebugItCommand.class.st
Expand Up @@ -23,8 +23,67 @@ SpCodeDebugItCommand class >> defaultShortcutKey [
| $d shift control unix
]

{ #category : #private }
SpCodeDebugItCommand >> compile: aStream for: anObject in: evalContext [
| methodClass |

methodClass := evalContext
ifNil: [ anObject class ]
ifNotNil: [ evalContext methodClass ].

^ context class compiler
source: aStream;
class: methodClass;
context: evalContext;
requestor: nil;
noPattern: true;
failBlock: [ ^ nil ];
compile
]

{ #category : #private }
SpCodeDebugItCommand >> debug: aStream [
| method doItReceiver doItContext |

(self context respondsTo: #doItReceiver)
ifTrue: [
doItReceiver := self context doItReceiver.
doItContext := self context doItContext ]
ifFalse: [
doItReceiver := doItContext := nil ].

method := self compile: aStream for: doItReceiver in: doItContext.
method isReturnSpecial
ifTrue: [ self inform: 'Nothing to debug, the expression is optimized'.
^ self ].
method notNil
ifTrue: [ self debug: method receiver: doItReceiver in: doItContext ]
]

{ #category : #private }
SpCodeDebugItCommand >> debug: aCompiledMethod receiver: anObject in: evalContext [
| guineaPig suspendedContext debugSession |

guineaPig := [
aCompiledMethod
valueWithReceiver: anObject
arguments: (evalContext ifNil: [ #() ] ifNotNil: [ { evalContext } ]) ]
newProcess.
suspendedContext := guineaPig suspendedContext.

debugSession := guineaPig newDebugSessionNamed: 'debug it' startedAt: suspendedContext.
debugSession stepIntoUntil: [ :currentContext |
currentContext method == aCompiledMethod ].

Smalltalk tools debugger openOn: debugSession withFullView: true.
]

{ #category : #execution }
SpCodeDebugItCommand >> execute [
self flag: 'TODO'.
'OK' crTrace
| selection |

selection := self selectedTextOrLine.
selection ifEmpty: [ ^ '' ].

self debug: selection readStream
]
4 changes: 4 additions & 0 deletions src/Spec2-Commands/SpCodeDoItCommand.class.st
@@ -1,3 +1,7 @@
"
I'm a ""do it"" command.
I will execute the selection (or line) of the playground.
"
Class {
#name : #SpCodeDoItCommand,
#superclass : #SpCodeSelectionCommand,
Expand Down

0 comments on commit be896fe

Please sign in to comment.