--- a/ContextInspectorView.st Wed Feb 19 00:06:42 2014 +0100
+++ b/ContextInspectorView.st Wed Feb 19 11:37:56 2014 +0100
@@ -12,7 +12,8 @@
"{ Package: 'stx:libtool' }"
InspectorView subclass:#ContextInspectorView
- instanceVariableNames:'inspectedContext names showingTemporaries argsOnly contextSize'
+ instanceVariableNames:'inspectedContext names showingTemporaries argsOnly contextSize
+ workspaceVariableNamesInDoIts'
classVariableNames:''
poolDictionaries:''
category:'Interface-Inspector'
@@ -94,6 +95,7 @@
inspectedContext := object := aContext.
contextSize := inspectedContext size.
+ workspaceVariableNamesInDoIts := nil.
aContext isNil ifTrue:[
names := nil.
listView list:nil.
@@ -101,8 +103,8 @@
].
methodHomeContext := aContext methodHome.
- methodHomeContext isNil ifTrue:[
- "its a cheap blocks context"
+ (methodHomeContext isNil) ifTrue:[
+ "its a cheap block's context"
rec := aContext receiver.
sel := aContext selector.
homeNames := OrderedCollection new.
@@ -142,10 +144,8 @@
].
"/ there is one case, where the above is by purpose:
- "/ the #doIt - method, which has been given an invalid
- "/ source.
- "/ care for this here.
-
+ "/ the #doIt - method, which has been given an invalid source.
+ "/ Care for this here.
isDoIt ifTrue:[
homeNames := #().
] ifFalse:[
@@ -214,7 +214,7 @@
].
"/ now, see if we can find out more
- "/ (failes, if source is not available)
+ "/ (fails, if source is not available)
method notNil ifTrue:[
(isDoIt and:[tempNames size > 0]) ifTrue:[
@@ -262,7 +262,21 @@
with:realTempNames.
].
homeNames addAll:tempNames.
- ]
+ ].
+ isDoIt ifTrue:[
+ "/ care for workspace- and doIt vars
+ method notNil ifTrue:[
+ |p names wsNames|
+
+ wsNames := Workspace workspaceVariableNames.
+ wsNames notEmptyOrNil ifTrue:[
+ p := Parser new source:method source; parseMethodBody; yourself.
+ names := (Set withAll:p readGlobals) addAll:p modifiedGlobals; yourself.
+ workspaceVariableNamesInDoIts := (names select:[:nm | wsNames includes:nm] )
+ asOrderedCollection sort.
+ ].
+ ].
+ ].
].
"
@@ -469,6 +483,9 @@
(sel startsWith:'-all local vars') ifTrue:[
^ self stringWithAllLocalValues
].
+ (sel startsWith:'-all workspace vars') ifTrue:[
+ ^ self stringWithAllWorkspaceValues
+ ].
^ super displayStringForValue:someValue
@@ -478,16 +495,30 @@
fieldList
"generate a list of names (& pseudo names) to be shown on the left side"
+ |list|
+
names size == 0 ifTrue:[
- inspectedContext home isNil ifTrue:[
+ (inspectedContext isBlockContext and:[inspectedContext home isNil]) ifTrue:[
"/ hack to guide beginners
^ { '>> no home in cheap block <<' colorizeAllWith:Color grey }
].
- ^ names
+ list := #()
+ ] ifFalse:[
+ list := { '-','all local vars' allItalic }
+ , (names keysAndValuesCollect:
+ [:idx :nm | self listEntryForName:nm value:(self valueAtIndex:idx) ]
+ )
].
- ^ (Array with:('-', 'all local vars' allItalic))
- , (names keysAndValuesCollect:[:idx :nm |
- self listEntryForName:nm value:(self valueAtIndex:idx) ])
+
+ workspaceVariableNamesInDoIts notEmptyOrNil ifTrue:[
+ list := list
+ , { '-','all workspace vars' allItalic}
+ , (workspaceVariableNamesInDoIts keysAndValuesCollect:
+ [:idx :nm | self listEntryForName:nm value:(Workspace workspaceVariableAt:nm) ]
+ )
+ ].
+
+ ^ list
"Modified: / 16-05-2012 / 18:54:59 / cg"
!
@@ -512,12 +543,21 @@
!
stringWithAllLocalValues
+ "when clicked on '-all local vars'"
+
+ ^ self stringWithAllNames:names andValues:((1 to:names size) collect:[:i| (self valueAtIndex:i)])
+!
+
+stringWithAllNames:names andValues:values
+ "helper for '-all local vars' and '-all workspace vars'"
+
|s maxLen varString|
s := '' writeStream.
maxLen := (names collect:[:eachName | eachName size]) max.
- names keysAndValuesDo:[:varIdx :eachLocalName |
- s nextPutAll:((eachLocalName , ' ') paddedTo:maxLen+1 with:$.).
+
+ names with:values do:[:eachName :eachValue |
+ s nextPutAll:((eachName , ' ') paddedTo:maxLen+1 with:$.).
s nextPutAll:' : '.
[
@@ -525,7 +565,7 @@
s := WriteStream on:(String new:10).
s writeLimit:100000.
- (self valueAtIndex:varIdx) displayOn:s.
+ eachValue displayOn:s.
varString := s contents.
"/ varString := (self valueAtIndex:varIdx) displayString.
] on:Error do:[:ex |
@@ -543,6 +583,14 @@
^ s contents
!
+stringWithAllWorkspaceValues
+ "when clicked on '-all workspace vars'"
+
+ ^ self
+ stringWithAllNames:workspaceVariableNamesInDoIts
+ andValues:(workspaceVariableNamesInDoIts collect:[:nm| (Workspace workspaceVariableAt:nm)value])
+!
+
valueAtIndex:varIdx
"helper - return the value of the selected entry"
@@ -588,6 +636,15 @@
]
].
+ varIdx > values size ifTrue:[
+ |wsIndex|
+
+ wsIndex := varIdx - values size.
+ wsIndex <= workspaceVariableNamesInDoIts size ifTrue:[
+ ^ (Workspace workspaceVariableAt:(workspaceVariableNamesInDoIts at:wsIndex)) value.
+ ].
+ ^ '** oops - could not found value **'
+ ].
^ values at:varIdx.
@@ -636,6 +693,9 @@
(line startsWith:'-all local vars') ifTrue:[
^ inspectedObject
].
+ (line startsWith:'-all workspace vars') ifTrue:[
+ ^ workspaceVariableNamesInDoIts collect:[:nm | (Workspace workspaceVariableAt:nm) value].
+ ].
self error:'unknown special line'.
@@ -684,10 +744,10 @@
!ContextInspectorView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/ContextInspectorView.st,v 1.91 2014-02-05 18:56:24 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/ContextInspectorView.st,v 1.92 2014-02-19 10:37:56 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libtool/ContextInspectorView.st,v 1.91 2014-02-05 18:56:24 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/ContextInspectorView.st,v 1.92 2014-02-19 10:37:56 cg Exp $'
! !