Skip to content

Commit e59b14b

Browse files
authored
Merge pull request #1254 from fouziray/fix1207
filtering protocols when creating a new method in debugger
2 parents 2fba668 + 91d9565 commit e59b14b

File tree

3 files changed

+63
-3
lines changed

3 files changed

+63
-3
lines changed

src/NewTools-Debugger-Tests/StDebuggerMNUExtensionTest.class.st

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,43 @@ StDebuggerMNUExtensionTest >> tearDown [
5757
super tearDown
5858
]
5959

60+
{ #category : 'tests' }
61+
StDebuggerMNUExtensionTest >> testExtensionDisplaysFilteredProtocolsDNU [
62+
63+
self hideExtensionInDebugger.
64+
debugger := StTestDebuggerProvider new debuggerWithDNUContext.
65+
debugger
66+
application: debugger class currentApplication;
67+
initialize.
68+
69+
self assert: debugger debuggerActionModel isInterruptedContextDoesNotUnderstand.
70+
self assert: debugger canExecuteCreateMissingMethodCommand.
71+
72+
self displayExtensionInDebugger.
73+
74+
self assertCollection: ( (debugger extensionTools first instVarNamed: #selectedProtocol) items collect: #name) hasSameElements: StTestDebuggerProvider protocolNames.
75+
self denyCollection: ( (debugger extensionTools first instVarNamed: #selectedProtocol) items collect: #name) includesAny: Object protocolNames.
76+
]
77+
78+
{ #category : 'tests' }
79+
StDebuggerMNUExtensionTest >> testExtensionDisplaysObjectProtocolsDNU [
80+
81+
| extensionFilteredProtocols |
82+
self hideExtensionInDebugger.
83+
debugger := StTestDebuggerProvider new debuggerWithObjectClassDNUContext.
84+
debugger
85+
application: debugger class currentApplication;
86+
initialize.
87+
88+
self assert: debugger debuggerActionModel isInterruptedContextDoesNotUnderstand.
89+
self assert: debugger canExecuteCreateMissingMethodCommand.
90+
91+
self displayExtensionInDebugger.
92+
extensionFilteredProtocols:=( (debugger extensionTools first instVarNamed: #selectedProtocol) items ).
93+
self assertCollection: (extensionFilteredProtocols collect: #name) includesAll: Object class protocolNames.
94+
self denyCollection: (extensionFilteredProtocols reject: #isExtensionProtocol thenCollect: #name) includesAny: ((Object allSuperclasses collect:#protocols) flattened reject:#isExtensionProtocol thenCollect:#name).
95+
]
96+
6097
{ #category : 'tests' }
6198
StDebuggerMNUExtensionTest >> testExtensionDisplaysWhenDNU [
6299

src/NewTools-Debugger-Tests/StTestDebuggerProvider.class.st

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,15 @@ StTestDebuggerProvider >> debuggerWithMissingSubclassResponsibilityContextWithSt
153153
^ dbg
154154
]
155155

156+
{ #category : 'helpers' }
157+
StTestDebuggerProvider >> debuggerWithObjectClassDNUContext [
158+
[ self methodProducingDNUonObject ]
159+
on: Error
160+
do: [ :err |
161+
self sessionFor: err signalerContext exception: err.
162+
^ self newDebugger ]
163+
]
164+
156165
{ #category : 'helpers' }
157166
StTestDebuggerProvider >> debuggerWithObjectHalting [
158167
[ StDebuggerObjectForTests new haltingMethod ]
@@ -198,6 +207,12 @@ StTestDebuggerProvider >> methodProducingDNU [
198207
^ self foobar
199208
]
200209

210+
{ #category : 'helpers' }
211+
StTestDebuggerProvider >> methodProducingDNUonObject [
212+
213+
^ Object foobar
214+
]
215+
201216
{ #category : 'helpers' }
202217
StTestDebuggerProvider >> methodThatGeneratesCode [
203218

src/NewTools-Debugger/StDebuggerMethodImplementorPresenter.class.st

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,20 @@ StDebuggerMethodImplementorPresenter >> addProtocolsFrom: aClassOrTrait [
5454
aClassOrTrait ifNil: [ ^ self ].
5555

5656
allProtocolsWithDuplicates := Dictionary new.
57+
5758
(aClassOrTrait isTrait
5859
ifTrue: [ aClassOrTrait protocols ]
5960
ifFalse: [
60-
(aClassOrTrait withAllSuperclasses copyWithoutAll: {
61-
Object.
62-
ProtoObject }) flatCollect: #protocols ]) do: [ :protocol |
61+
((aClassOrTrait withAllSuperclasses copyWithoutAll: ({
62+
Object.
63+
ProtoObject.
64+
Class.
65+
Behavior.
66+
ClassDescription.
67+
Object class.
68+
ProtoObject class } copyWithout: aClassOrTrait)) flatCollect: #protocols) asSet .
69+
70+
]) do: [ :protocol |
6371
allProtocolsWithDuplicates at: protocol name put: protocol ].
6472
self addProtocols: allProtocolsWithDuplicates values
6573
]

0 commit comments

Comments
 (0)