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

452 in the debugger create subclass responsibility button does not offers the possibility to create the responsibility in subclasses of the receiver but in the exception class subclass responsibility but only after performing steps #575

13 changes: 13 additions & 0 deletions src/NewTools-Debugger-Tests/StDebuggerActionModelTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,19 @@ StDebuggerActionModelTest >> testIsInterruptedContextSubclassResponsibilityExcep
self assert: debugActionModel isInterruptedContextSubclassResponsibilityException
]

{ #category : 'tests - predicates' }
StDebuggerActionModelTest >> testIsInterruptedContextSubclassResponsibilityExceptionWithSteps [

| dummyActionModel |
dummyActionModel := StTestDebuggerProvider new
debuggerWithMissingSubclassResponsibilityContextWithSteps
debuggerActionModel.
self changeSession: dummyActionModel session.
dummyActionModel clear.
self assert:
debugActionModel isInterruptedContextSubclassResponsibilityException
]

{ #category : 'tests - actions' }
StDebuggerActionModelTest >> testPeelToFirstLike [

Expand Down
41 changes: 41 additions & 0 deletions src/NewTools-Debugger-Tests/StDebuggerCommandTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,47 @@ StDebuggerCommandTest >> testCommandsInMissingSubclassResponsibilityContext [
debugger debuggerActionModel clear
]

{ #category : 'tests' }
StDebuggerCommandTest >> testCommandsInMissingSubclassResponsibilityContextWithSteps [

| debugger |
[
debugger := debuggerProvider
debuggerWithMissingSubclassResponsibilityContextWithSteps.
self assert: debugger debuggerActionModel
isInterruptedContextSubclassResponsibilityException.

"Executable commands relative to context"
self assert:
(StDefineSubclassResponsabilityCommand forContext: debugger)
canBeExecuted.
self assert:
(StDefineMissingEntityCommand forContext: debugger) canBeExecuted.
self assert: (StRestartCommand forContext: debugger) canBeExecuted.
self assert:
(StReturnValueCommand forContext: debugger) canBeExecuted.

"Non-executable commands relative to context"
self deny: (StStepIntoCommand forContext: debugger) canBeExecuted.
self deny: (StStepOverCommand forContext: debugger) canBeExecuted.
self deny: (StStepThroughCommand forContext: debugger) canBeExecuted.
self deny:
(StRunToSelectionCommand forContext: debugger) canBeExecuted.
self deny: (StProceedCommand forContext: debugger) canBeExecuted.
self deny: (StDefineClassCommand forContext: debugger) canBeExecuted.
self deny: (StDefineMethodCommand forContext: debugger) canBeExecuted.

"Executable commands, whatever the context"
self assert:
(StCopyStackToClipboardCommand forContext: debugger) canBeExecuted.
self assert:
(StFileOutMethodCommand forContext: debugger) canBeExecuted.
self assert:
(StPeelToFirstCommand forContext: debugger) canBeExecuted.
self assert: (StWhereIsCommand forContext: debugger) canBeExecuted ]
ensure: [ debugger ifNotNil: [ debugger clear ] ]
]

{ #category : 'tests' }
StDebuggerCommandTest >> testCommandsInRunnableContext [

Expand Down
25 changes: 25 additions & 0 deletions src/NewTools-Debugger-Tests/StTestDebuggerProvider.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,31 @@ StTestDebuggerProvider >> debuggerWithMissingSubclassResponsibilityContext [
^ self newDebugger ]
]

{ #category : 'helpers' }
StTestDebuggerProvider >> debuggerWithMissingSubclassResponsibilityContextWithSteps [

| ctx dbg |
ctx := [
StDummyDebuggerPresenter new
unimplementedSubclassResponsibility ] asContext.

self
sessionFor: ctx
exception: (OupsNullException fromSignallerContext: ctx).
dbg := self newDebugger.
dbg
application: dbg class currentApplication;
initialize.
"We reach the subclass responsability"
dbg
stepOver;
stepOver;
stepInto;
stepOver.

^ dbg
]

{ #category : 'helpers' }
StTestDebuggerProvider >> debuggerWithObjectHalting [
[ StDebuggerObjectForTests new haltingMethod ]
Expand Down
16 changes: 14 additions & 2 deletions src/NewTools-Debugger/StDebugger.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,13 @@ StDebugger >> createMissingMethodFor: aMessage in: aClass [
StDebugger >> createSubclassResponsibility [

| senderContext msg chosenClass |
senderContext := self interruptedContext sender.
senderContext := self signalingSubclassResponsabilityContext.
msg := Message
selector: senderContext selector
arguments: senderContext arguments.
chosenClass := self requestClassFrom: senderContext receiver class to: senderContext methodClass.
chosenClass := self
requestClassFrom: senderContext receiver class
to: senderContext methodClass.
chosenClass ifNil: [ ^ self ].
self debuggerActionModel
implement: msg
Expand Down Expand Up @@ -1126,6 +1128,16 @@ StDebugger >> setStackAndCodeContainer [
ifFalse: [ self stackAndCodeLayout ]
]

{ #category : 'accessing - context' }
StDebugger >> signalingSubclassResponsabilityContext [

| signalingContext |
signalingContext := self interruptedContext.
[ signalingContext selector = #subclassResponsibility ] whileFalse: [
signalingContext := signalingContext sender ].
^ signalingContext sender
]

{ #category : 'stack' }
StDebugger >> stack [
^ self debuggerActionModel stack
Expand Down
Loading