--- a/VDBVariableObjectPresenter.st Mon Jul 08 13:31:11 2019 +0100
+++ b/VDBVariableObjectPresenter.st Mon Jul 08 23:12:19 2019 +0100
@@ -69,12 +69,13 @@
!VDBVariableObjectPresenter methodsFor:'accessing'!
label
- ^ (varobj parent notNil or:[varobj parentIsDynamic])
- ifTrue:[ varobj expression ]
- ifFalse:[ varobj path ]
+ ^ varobj expression
+"/ ^ (varobj parent notNil or:[varobj parentIsDynamic])
+"/ ifTrue:[ varobj expression ]
+"/ ifFalse:[ varobj path ]
"Created: / 27-02-2015 / 15:57:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 10-09-2018 / 16:45:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 08-07-2019 / 23:10:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
subject
@@ -121,24 +122,39 @@
!VDBVariableObjectPresenter methodsFor:'menu'!
+contextMenuBee: aMenu
+ "Adds a Smalltalk/X debugging menu items to the context menu."
+
+ <menuextension: #contextMenu>
+
+ (varobj type endsWith: 'Bee::oop_t *') ifTrue:[
+ aMenu addItem: (
+ (MenuItem label: (self class classResources string: 'Inspect Object')
+ itemValue: #doInspectBeeObject)
+ receiver: self
+ ).
+ aMenu addSeparator.
+ ].
+
+ "Created: / 08-07-2019 / 21:54:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
contextMenuStX: aMenu
"Adds a Smalltalk/X debugging menu items to the context menu."
<menuextension: #contextMenu>
(varobj type endsWith: 'OBJ') ifTrue:[
- | path |
-
- path := varobj path.
aMenu addItem: (
- (MenuItem label: (self class classResources string: 'Inspect - *(%1)' with: path)
- itemValue: #doInspectOBJ)
+ (MenuItem label: (self class classResources string: 'Inspect Object')
+ itemValue: #doInspectStXObject)
receiver: self
).
aMenu addSeparator.
].
"Created: / 10-02-2018 / 23:06:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 08-07-2019 / 22:52:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!VDBVariableObjectPresenter methodsFor:'menu actions'!
@@ -157,34 +173,88 @@
!
doDoubleClick
- self doInspectOBJ
+ "/ This is really an ugly hack: in Smalltalk IDEs, double clock
+ "/ on variable usually inspects it. We want the same, but in this case,
+ "/ inspect operation may involve changing varobj's visualizer.
+ "/
+ "/ To allow plugins to define their own inspect actions, first search
+ "/ extending menu items for item matching "Inspect" - if there's one,
+ "/ do this, if none or more than one, do `super doDoubleClick`.
+
+ | dummy inspects |
+
+ dummy := Menu new.
+ self contextMenuExtendersFor: #contextMenu do:[:each |
+ self perform: each with: dummy
+ ].
+ inspects := dummy items select:[:item | item label startsWith:'Inspect' ].
+ inspects size == 1 ifTrue:[
+ | value |
+
+ value := inspects anyOne value.
+ value isSymbol ifTrue:[
+ inspects anyOne receiver perform: value
+ ].
+ ] ifFalse:[
+ super doDoubleClick
+ ].
"Created: / 19-02-2018 / 16:10:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 08-07-2019 / 23:07:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-doInspectOBJ
- | dup app wnd |
+doInspect:visualizerExpr
+ "
+ Open an inspector of a copy of varobj. If `visualizerExpr`
+ is not nil then the visualizer of a *copy* is set to
+ `visualizerExpr`
+"
+
+ | dup app wnd |
dup := varobj duplicate.
- dup visualizer: 'lambda val: instance_create(val)'.
-
+ dup == varobj ifTrue:[
+ dup := VDBVariableObject
+ evaluate:varobj path
+ in:varobj frame
+ using:varobj debugger.
+ ].
+ visualizerExpr notNil ifTrue:[
+ dup visualizer:visualizerExpr
+ ].
+
"/ If used in Inspector2, open child in the same inspector windpow.
+
app := self application.
- app notNil ifTrue:[
+ app notNil ifTrue:[
wnd := app window.
- wnd notNil ifTrue:[
+ wnd notNil ifTrue:[
wnd := wnd topView.
- (wnd application isKindOf: Tools::Inspector2) ifTrue:[
- wnd application inspect: dup.
+ (wnd application isKindOf:Tools::Inspector2) ifTrue:[
+ wnd application inspect:dup.
^ self.
].
].
].
+
"/ ...otherwise open a new inspector...
+
dup inspect.
+ "Created: / 08-07-2019 / 20:17:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+doInspectBeeObject
+ self doInspect:'obj'.
+
+ "Created: / 08-07-2019 / 21:55:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+doInspectStXObject
+ self doInspect:'instance_create'.
+
"Created: / 10-02-2018 / 23:17:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 08-09-2018 / 16:00:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 08-07-2019 / 22:50:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!VDBVariableObjectPresenter methodsFor:'private'!