extraNamedField support
authorClaus Gittinger <cg@exept.de>
Thu, 03 Aug 2006 13:54:32 +0200
changeset 6840 52d3f2cbf130
parent 6839 c25218305e50
child 6841 6d72f92ed6cd
extraNamedField support
InspectorView.st
--- a/InspectorView.st	Wed Aug 02 11:22:06 2006 +0200
+++ b/InspectorView.st	Thu Aug 03 13:54:32 2006 +0200
@@ -1042,11 +1042,68 @@
     ^ self basicDisplayStringForValue:someValue
 !
 
+extraNamedFields
+    ^ [object inspectorExtraNamedFields]
+                on: MessageNotUnderstood
+                do: [:ex | ex return: Array new]
+
+    "Created: / 03-08-2006 / 13:34:18 / cg"
+!
+
+extraNamedVarIndexForLine:lineNr
+    "helper - return the index for a named instVar;
+     nil, if self or a keyed instvar is selected."
+
+    |idx nNamedInstvarsShown nExtraNamedInstvarsShown cls baseCls firstRealIndex line|
+
+    lineNr isNil ifTrue:[^ nil].
+    firstRealIndex := 1.
+
+    idx := lineNr.
+    self hasSelfEntry ifTrue:[
+        (lineNr == 1 or:[lineNr isNil]) ifTrue:[
+            ^ nil "/ self selected
+        ].
+        idx := idx - 1.
+        firstRealIndex := 2.
+    ].
+
+    [line := listView at:firstRealIndex. 
+     (line startsWith:'-') and:[line size < 2 or:[line second isDigit not]]] whileTrue:[
+        firstRealIndex := firstRealIndex + 1.
+        idx := idx - 1.
+    ].
+
+    cls := inspectedObject class.
+    baseCls := self baseInspectedObjectClass.
+
+    nNamedInstvarsShown := cls instSize.
+    "/ only the namedInstvars below baseInspectedObjectClass
+    "/ are shown ...
+    (cls == baseCls or:[cls isSubclassOf:baseCls]) ifTrue:[
+        nNamedInstvarsShown := nNamedInstvarsShown - baseCls instSize.
+    ].
+
+    idx := idx - nNamedInstvarsShown.
+    idx < 1 ifTrue:[
+        ^ nil.
+    ].
+
+    nExtraNamedInstvarsShown := self extraNamedFields.
+    idx <= nExtraNamedInstvarsShown ifTrue:[
+        ^ idx.
+    ].
+
+    ^ nil "/ indexed instvar or other selected
+
+    "Created: / 03-08-2006 / 13:45:14 / cg"
+!
+
 fieldList 
     "return a list of names to show in the selectionList.
      Leave hasMore as true, if a '...' entry should be added."
 
-    |derivedFieldList namedFieldList fieldList cls indexedList|
+    |derivedFieldList namedFieldList fieldList cls indexedList extraNamedFieldList|
 
     inspectedObject isNil ifTrue:[
         ^ self hasSelfEntry ifFalse:[ #() ] ifTrue:[ #('-self') ]
@@ -1055,6 +1112,7 @@
     self topView withWaitCursorDo:[
         namedFieldList := self namedFieldList.
         indexedList := self indexedFieldList.
+        extraNamedFieldList := OrderedCollection new.
 
         self hasSelfEntry ifTrue:[
             self suppressPseudoSlots ifFalse:[
@@ -1079,17 +1137,23 @@
                     do:[:eachKeyValuePair| 
                         derivedFieldList add:('-',eachKeyValuePair key)
                     ].
+
+                self extraNamedFields 
+                    do:[:eachKeyValuePair| 
+                        extraNamedFieldList add:(eachKeyValuePair key)
+                    ].
             ].
         ].
 
         fieldList := OrderedCollection new.
         derivedFieldList notNil ifTrue:[fieldList addAll:derivedFieldList].
         namedFieldList notNil ifTrue:[fieldList addAll:namedFieldList].
+        extraNamedFieldList notNil ifTrue:[fieldList addAll:extraNamedFieldList].
         indexedList notNil ifTrue:[fieldList addAll:indexedList].
     ].
     ^ fieldList
 
-    "Modified: / 17-07-2006 / 11:15:58 / cg"
+    "Modified: / 03-08-2006 / 13:39:15 / cg"
 !
 
 hasSelfEntry
@@ -1191,7 +1255,7 @@
     "helper - return the index of the key-list;
      nil, if self or a namedInstVar is selected."
 
-    |idx nNamedInstvarsShown cls baseCls firstRealIndex line|
+    |idx nNamedInstvarsShown nExtraNamedInstvarsShown cls baseCls firstRealIndex line|
 
     lineNr isNil ifTrue:[^ nil].
 
@@ -1222,13 +1286,14 @@
     (cls == baseCls or:[cls isSubclassOf:baseCls]) ifTrue:[
         nNamedInstvarsShown := nNamedInstvarsShown - baseCls instSize.
     ].
+    nExtraNamedInstvarsShown := self extraNamedFields.
 
-    idx <= nNamedInstvarsShown ifTrue:[
+    idx <= (nNamedInstvarsShown+nExtraNamedInstvarsShown) ifTrue:[
         ^ nil "/ named instVar selected.
     ].
-    ^ idx - nNamedInstvarsShown.
+    ^ idx - (nNamedInstvarsShown+nExtraNamedInstvarsShown).
 
-    "Modified: / 31.10.2001 / 09:21:13 / cg"
+    "Modified: / 03-08-2006 / 13:40:57 / cg"
 !
 
 namedFieldList 
@@ -1484,6 +1549,14 @@
         ]
     ].
 
+    "/ an extra named field ?
+    idx := self extraNamedVarIndexForLine:lineNr.
+    idx notNil ifTrue:[
+        BreakPointInterrupt catch:[
+            ^ ((self extraNamedFields) at:idx) value
+        ]
+    ].
+
     "/ an indexed instVar ?
     idx := self keyIndexForLine:lineNr.
     idx notNil ifTrue:[
@@ -1495,7 +1568,7 @@
     "/ nope
     ^ nil
 
-    "Modified: / 16.11.2001 / 16:19:04 / cg"
+    "Modified: / 03-08-2006 / 13:46:02 / cg"
 !
 
 valueAtLine:lineNr put:newValue
@@ -1518,6 +1591,9 @@
     |fieldEntry|
 
     fieldEntry := self derivedFields detect:[:entry| ('-',entry key)=line] ifNone:nil.
+    fieldEntry isNil ifTrue:[
+        fieldEntry := self extraNamedFields detect:[:entry| entry key=line] ifNone:nil.
+    ].
     fieldEntry notNil ifTrue:[
         ^ fieldEntry value
     ].
@@ -1559,7 +1635,7 @@
     self error:'unknown special line'.
 
     "Created: / 31-10-2001 / 09:17:45 / cg"
-    "Modified: / 17-07-2006 / 11:09:05 / cg"
+    "Modified: / 03-08-2006 / 13:35:39 / cg"
 ! !
 
 !InspectorView methodsFor:'queries'!
@@ -1820,5 +1896,5 @@
 !InspectorView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/InspectorView.st,v 1.161 2006-07-17 11:29:58 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/InspectorView.st,v 1.162 2006-08-03 11:54:32 cg Exp $'
 ! !