Skip to content
Permalink
Browse files

Rewrite Pre debugger.

- Split the pre debugger into two. One for notification and one for stacks.
- Migrate to Spec 2

Fixes #3841
  • Loading branch information
jecisc committed Jul 9, 2019
1 parent 05b83b0 commit ccc5777a13619429d3957918d05031756e9114da
@@ -39,7 +39,6 @@ DebugAction >> specId [
]

{ #category : #'*GT-Debugger' }
DebugAction >> specModel [

^ #GTDebugActionButton
DebugAction >> specPresenter [
^ GTDebugActionButton
]
@@ -1,6 +1,6 @@
Class {
#name : #GTDebugActionButton,
#superclass : #ButtonPresenter,
#superclass : #SpButtonPresenter,
#instVars : [
'debugActionHolder'
],
@@ -31,10 +31,9 @@ GTGenericStackDebugger class >> alwaysOpenFullDebugger: aBoolean [
{ #category : #'utilities api' }
GTGenericStackDebugger class >> closeAllDebuggers [
"GTGenericStackDebugger closeAllDebuggers"
(SystemWindow allSubInstances select: [:w |
w model isKindOf: GTGenericStackDebugger])
do: [:w | w delete ].
GTSpecPreDebugWindow allInstances do: #delete.

(SystemWindow allSubInstances select: [ :w | w model isKindOf: GTGenericStackDebugger ]) do: [ :w | w delete ].
GTSpecPreDebugPresenter allSubInstances do: #close
]

{ #category : #'settings api' }
@@ -368,12 +367,14 @@ GTGenericStackDebugger >> openWithNotification: notificationString [
"NOTE: When this method returns, a new process has been scheduled to
run the windows, and thus this notifier, but the previous active porcess
has not been suspended. The sender will do this."

GTSpecPreDebugWindow new
setTitle: self title;

(notificationString
ifNil: [ GTSpecPreDebugStackPresenter on: self ]
ifNotNil: [ (GTSpecPreDebugNotificationPresenter on: self)
message: notificationString;
yourself ])
openWithSpec;
debugger: self
setTitle: self title
]

{ #category : #'printing/formatting' }
@@ -0,0 +1,53 @@
"
I am a presenter that will hold the action buttons of a pre debugger.
I'll collect the actions via pragmas and create button presenters for them.
"
Class {
#name : #GTSpecPreDebugActionsPresenter,
#superclass : #SpPresenter,
#traits : 'TSpDynamicPresenter',
#classTraits : 'TSpDynamicPresenter classTrait',
#category : #'GT-Debugger-UI'
}

{ #category : #initialization }
GTSpecPreDebugActionsPresenter >> buttonFor: anAction [
^ (self instantiate: anAction specPresenter)
debugAction: anAction;
yourself
]

{ #category : #accessing }
GTSpecPreDebugActionsPresenter >> debugger [
^ self owner debugger
]

{ #category : #initialization }
GTSpecPreDebugActionsPresenter >> initializeWidgets [
self preDebuggingActions do: [ :action | self presenterAt: action specId put: (self buttonFor: action) ].

self presentersDo: [ :button | self focusOrder add: button ]
]

{ #category : #accessing }
GTSpecPreDebugActionsPresenter >> layout [
| row |
row := SpBoxLayout newHorizontal.
self basicPresenters keysDo: [ :id | row add: id ].
^ row
]

{ #category : #'actions lookup' }
GTSpecPreDebugActionsPresenter >> preDebuggingActions [
"Return a collection of debug actions constructed based on the pragmas 'self preDebuggingActionsPragmas'.
These actions should understand the message #preDebugWindow:"

^ (self session class debuggingActionsForPragmas: {#preDebuggingAction} for: self debugger)
do: [ :each | each preDebugWindow: self owner ]
]

{ #category : #accessing }
GTSpecPreDebugActionsPresenter >> session [
^ self owner session
]
@@ -0,0 +1,43 @@
"
I am a pre debugger showing to the user textual informations.
I'll typically display notifications.
Internal Representation and Key Implementation Points.
--------------------
Instance Variables
textPresenter: <aTextPresenter> A presenter to display the notification.
"
Class {
#name : #GTSpecPreDebugNotificationPresenter,
#superclass : #GTSpecPreDebugPresenter,
#instVars : [
'textPresenter'
],
#category : #'GT-Debugger-UI'
}

{ #category : #specs }
GTSpecPreDebugNotificationPresenter class >> defaultSpec [
^ SpBoxLayout newVertical
add: #actions withConstraints: [ :constraints | constraints height: self toolbarHeight ];
add: #textPresenter;
yourself
]

{ #category : #initialization }
GTSpecPreDebugNotificationPresenter >> initializeWidgets [
super initializeWidgets.
textPresenter := self newText.

textPresenter disable.

self focusOrder add: textPresenter
]

{ #category : #accessing }
GTSpecPreDebugNotificationPresenter >> message: aString [
textPresenter text: aString
]
@@ -0,0 +1,75 @@
"
I am an abstract class for pre debug windows.
Depending on the error raised I'll open one of my subclass to display the pre informations to the user.
Internal Representation and Key Implementation Points.
--------------------
Instance Variables
actions: <aGTSpecPreDebugActionPresenter> A presenter holding the actions to execute in the pre debugger.
debugger: <aDebugger> The debuggeur opening me.
"
Class {
#name : #GTSpecPreDebugPresenter,
#superclass : #SpPresenter,
#instVars : [
'debugger',
'actions'
],
#category : #'GT-Debugger-UI'
}

{ #category : #testing }
GTSpecPreDebugPresenter class >> isAbstract [
^ self = GTSpecPreDebugPresenter
]

{ #category : #actions }
GTSpecPreDebugPresenter >> close [
self withWindowDo: #close
]

{ #category : #accessing }
GTSpecPreDebugPresenter >> debugger [
^ debugger
]

{ #category : #initialization }
GTSpecPreDebugPresenter >> initializeWidgets [
actions := self instantiate: GTSpecPreDebugActionsPresenter.

self focusOrder add: actions
]

{ #category : #initialization }
GTSpecPreDebugPresenter >> initializeWindow: aWindowPresenter [
aWindowPresenter
whenClosedDo: [ debugger ifNotNil: #windowIsClosing ];
initialExtent: 700 @ 180
]

{ #category : #actions }
GTSpecPreDebugPresenter >> openFullDebugger [
| currentDebugger |
currentDebugger := self debugger.
debugger := nil.
self close.
currentDebugger openWithFullView
]

{ #category : #accessing }
GTSpecPreDebugPresenter >> session [
^ self debugger session
]

{ #category : #'accessing model' }
GTSpecPreDebugPresenter >> setModelBeforeInitialization: aDebugger [
debugger := aDebugger
]

{ #category : #initialization }
GTSpecPreDebugPresenter >> setTitle: aString [
self withWindowDo: [ :w | w title: aString ]
]
@@ -0,0 +1,70 @@
"
I am a pre debugger showing to the user the beginning of a stack trace.
I'll typically display errors (vs notifications).
Internal Representation and Key Implementation Points.
--------------------
Instance Variables
stackPresenter: <aTablePresenter> A table to display informations on a stack.
"
Class {
#name : #GTSpecPreDebugStackPresenter,
#superclass : #GTSpecPreDebugPresenter,
#instVars : [
'stackPresenter'
],
#category : #'GT-Debugger-UI'
}

{ #category : #specs }
GTSpecPreDebugStackPresenter class >> defaultSpec [
^ SpBoxLayout newVertical
add: #actions withConstraints: [ :constraints | constraints height: self toolbarHeight ];
add: #stackPresenter;
yourself
]

{ #category : #initialization }
GTSpecPreDebugStackPresenter >> initializePresenter [
stackPresenter
items: self debugger filteredStack;
whenSelectionChangedDo: [ :selection |
"Set the selection before, as debugAction removes the link with the debugger. "
self debugger stackPresentation selection: selection selectedItem.
self openFullDebugger ]
]

{ #category : #initialization }
GTSpecPreDebugStackPresenter >> initializeWidgets [
super initializeWidgets.
stackPresenter := self newTable.

self flag: #todo. "We should remove the #asTextMorph but for now there is no way in Spec to use Text as table cell content."
stackPresenter
addColumn:
(SpStringTableColumn
title: 'Class'
evaluated: [ :context |
(self debugger formatStackClassColumnForContext: context) asTextMorph
lock;
yourself ]);
addColumn:
(SpStringTableColumn
title: 'Method'
evaluated: [ :context |
(self debugger formatStackMethodColumnForContext: context) asTextMorph
lock;
yourself ]);
addColumn:
(SpStringTableColumn
title: 'Extra'
evaluated: [ :context |
(self debugger formatStackExtraColumnForContext: context) asTextMorph
lock;
yourself ]);
beResizable.

self focusOrder add: stackPresenter
]

0 comments on commit ccc5777

Please sign in to comment.
You can’t perform that action at this time.