--- a/ContextInspectorView.st Sun Jan 12 23:30:25 2014 +0000
+++ b/ContextInspectorView.st Wed Apr 01 10:38:01 2015 +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.
+ ].
+ ].
+ ].
].
"
@@ -307,7 +321,7 @@
numArgs := aContext numArgs.
numVars := aContext numVars.
- (numArgs > 0 or:[numVars > 0]) ifTrue:[
+ (numArgs + numVars) > 0 ifTrue:[
argAndVarNames := aContext argAndVarNames.
argAndVarNames notEmptyOrNil ifTrue:[
argNames := argAndVarNames copyTo:numArgs.
@@ -469,6 +483,9 @@
(sel startsWith:'-all local vars') ifTrue:[
^ self stringWithAllLocalValues
].
+ (sel startsWith:'-all workspace vars') ifTrue:[
+ ^ self stringWithAllWorkspaceValues
+ ].
^ super displayStringForValue:someValue
@@ -478,18 +495,35 @@
fieldList
"generate a list of names (& pseudo names) to be shown on the left side"
+ |list|
+
+ inspectedContext isNil ifTrue:[ ^ #() ].
+
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 }
+ ^ { '>> no home in cheap block <<' colorizeAllWith:Color gray }
].
- ^ 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"
+ "Modified: / 25-02-2014 / 15:10:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
hasSelfEntry
@@ -512,12 +546,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 +568,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 +586,14 @@
^ s contents
!
+stringWithAllWorkspaceValues
+ "when clicked on '-all workspace vars'"
+
+ ^ self
+ stringWithAllNames:workspaceVariableNamesInDoIts
+ andValues:(workspaceVariableNamesInDoIts collect:[:nm| Workspace workspaceVariableAt:nm])
+!
+
valueAtIndex:varIdx
"helper - return the value of the selected entry"
@@ -588,6 +639,15 @@
]
].
+ varIdx > values size ifTrue:[
+ |wsIndex|
+
+ wsIndex := varIdx - values size - 1.
+ wsIndex <= workspaceVariableNamesInDoIts size ifTrue:[
+ ^ Workspace workspaceVariableAt:(workspaceVariableNamesInDoIts at:wsIndex).
+ ].
+ ^ '** oops - could not find value **'
+ ].
^ values at:varIdx.
@@ -636,6 +696,9 @@
(line startsWith:'-all local vars') ifTrue:[
^ inspectedObject
].
+ (line startsWith:'-all workspace vars') ifTrue:[
+ ^ workspaceVariableNamesInDoIts collect:[:nm | Workspace workspaceVariableAt:nm].
+ ].
self error:'unknown special line'.
@@ -684,19 +747,10 @@
!ContextInspectorView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/ContextInspectorView.st,v 1.89 2013-09-01 09:00:46 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/ContextInspectorView.st,v 1.97 2014-07-08 21:53:39 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libtool/ContextInspectorView.st,v 1.89 2013-09-01 09:00:46 cg Exp $'
-!
-
-version_HG
-
- ^ '$Changeset: <not expanded> $'
-!
-
-version_SVN
- ^ '$Id: ContextInspectorView.st 8022 2012-07-25 09:51:30Z vranyj1 $'
+ ^ '$Header: /cvs/stx/stx/libtool/ContextInspectorView.st,v 1.97 2014-07-08 21:53:39 cg Exp $'
! !