5939 |
5939 |
5940 varTypeInfo |
5940 varTypeInfo |
5941 "show typical usage of a variable" |
5941 "show typical usage of a variable" |
5942 |
5942 |
5943 |name idx classes values value msg cut names instCount subInstCount box |
5943 |name idx classes values value msg cut names instCount subInstCount box |
5944 searchClass| |
5944 searchClass s| |
5945 |
5945 |
5946 name := variableListView selectionValue. |
5946 name := variableListView selectionValue. |
5947 name isNil ifTrue:[^ self]. |
5947 name isNil ifTrue:[^ self]. |
5948 |
5948 |
5949 searchClass := actualClass whichClassDefinesInstVar:name. |
5949 showInstance ifFalse:[ |
5950 |
5950 searchClass := currentClass whichClassDefinesClassVar:name. |
5951 idx := searchClass instVarOffsetOf:name. |
5951 value := searchClass classVarAt:(name asSymbol). |
5952 idx isNil ifTrue:[^ self]. |
5952 s := value displayString. |
5953 |
5953 s size > 60 ifTrue:[ |
5954 classes := IdentitySet new. |
5954 s := (s copyTo:60) , ' ...' |
5955 values := IdentitySet new. |
5955 ]. |
5956 instCount := 0. |
5956 msg := name , ' is (currently):\\' , s. |
5957 subInstCount := 0. |
5957 s ~= value classNameWithArticle ifTrue:[ |
5958 searchClass allSubInstancesDo:[:i | |
5958 msg := msg , '\\(' , value class name , ')' |
5959 |val| |
5959 ] |
5960 |
5960 ] ifTrue:[ |
5961 val := i instVarAt:idx. |
5961 searchClass := actualClass whichClassDefinesInstVar:name. |
5962 val notNil ifTrue:[values add:val]. |
5962 |
5963 classes add:val class. |
5963 idx := searchClass instVarOffsetOf:name. |
5964 (i isMemberOf:searchClass) ifTrue:[ |
5964 idx isNil ifTrue:[^ self]. |
5965 instCount := instCount + 1. |
5965 |
5966 ] ifFalse:[ |
5966 classes := IdentitySet new. |
5967 subInstCount := subInstCount + 1 |
5967 values := IdentitySet new. |
5968 ] |
5968 instCount := 0. |
5969 ]. |
5969 subInstCount := 0. |
5970 (instCount == 0 and:[subInstCount == 0]) ifTrue:[ |
5970 searchClass allSubInstancesDo:[:i | |
5971 self warn:'there are currently no instances of ' , currentClass name. |
5971 |val| |
5972 ^ self |
5972 |
5973 ]. |
5973 val := i instVarAt:idx. |
5974 |
5974 val notNil ifTrue:[values add:val]. |
5975 instCount ~~ 0 ifTrue:[ |
5975 classes add:val class. |
5976 msg := 'in (currently: ' , instCount printString,') instances '. |
5976 (i isMemberOf:searchClass) ifTrue:[ |
5977 subInstCount ~~ 0 ifTrue:[ |
5977 instCount := instCount + 1. |
5978 msg := msg , 'and ' |
5978 ] ifFalse:[ |
5979 ] |
5979 subInstCount := subInstCount + 1 |
5980 ] ifFalse:[ |
5980 ] |
5981 msg := 'in '. |
5981 ]. |
5982 ]. |
5982 (instCount == 0 and:[subInstCount == 0]) ifTrue:[ |
5983 subInstCount ~~ 0 ifTrue:[ |
5983 self warn:'there are currently no instances of ' , currentClass name. |
5984 msg := msg , '(currently: ' , subInstCount printString, ') derived instances ' |
5984 ^ self |
5985 ]. |
5985 ]. |
5986 msg := msg, 'of ' , searchClass name , ',\'. |
5986 |
5987 msg := msg , name , ' '. |
5987 instCount ~~ 0 ifTrue:[ |
5988 ((values size == 1) |
5988 msg := 'in (currently: ' , instCount printString,') instances '. |
5989 or:[classes size == 1 and:[classes first == UndefinedObject]]) ifTrue:[ |
5989 subInstCount ~~ 0 ifTrue:[ |
5990 values size == 1 ifTrue:[value := values first]. |
5990 msg := msg , 'and ' |
5991 (value isNumber or:[value isString]) ifTrue:[ |
5991 ] |
5992 msg := msg , 'is always the same:\\ ' , |
5992 ] ifFalse:[ |
5993 value class name , ' (' , value storeString , ')'. |
5993 msg := 'in '. |
5994 ] ifFalse:[ |
5994 ]. |
5995 (value isNil or:[value == true or:[value == false]]) ifTrue:[ |
5995 subInstCount ~~ 0 ifTrue:[ |
5996 msg := msg , 'is always:\\ ' , |
5996 msg := msg , '(currently: ' , subInstCount printString, ') derived instances ' |
5997 value printString. |
5997 ]. |
5998 ] ifFalse:[ |
5998 msg := msg, 'of ' , searchClass name , ',\'. |
5999 msg := msg , 'is always the same:\\'. |
5999 msg := msg , name , ' '. |
6000 msg := msg , ' ' , value class name. |
6000 ((values size == 1) |
6001 value isLiteral ifTrue:[ |
6001 or:[classes size == 1 and:[classes first == UndefinedObject]]) ifTrue:[ |
6002 msg := msg , ' (' , value storeString , ')' |
6002 values size == 1 ifTrue:[value := values first]. |
6003 ] |
6003 (value isNumber or:[value isString]) ifTrue:[ |
6004 ] |
6004 msg := msg , 'is always the same:\\ ' , |
6005 ] |
6005 value class name , ' (' , value storeString , ')'. |
6006 ] ifFalse:[ |
6006 ] ifFalse:[ |
6007 classes size == 1 ifTrue:[ |
6007 (value isNil or:[value == true or:[value == false]]) ifTrue:[ |
6008 msg := msg , 'is always:\\'. |
6008 msg := msg , 'is always:\\ ' , |
6009 msg := msg , ' ' , classes first name , '\'. |
6009 value printString. |
6010 ] ifFalse:[ |
6010 ] ifFalse:[ |
6011 msg := msg , 'is one of:\\'. |
6011 msg := msg , 'is always the same:\\'. |
6012 classes := classes asOrderedCollection. |
6012 msg := msg , ' ' , value class name. |
6013 classes size > 20 ifTrue:[ |
6013 value isLiteral ifTrue:[ |
6014 classes := classes copyFrom:1 to:20. |
6014 msg := msg , ' (' , value storeString , ')' |
6015 cut := true |
6015 ] |
6016 ] ifFalse:[ |
6016 ] |
6017 cut := false. |
6017 ] |
6018 ]. |
6018 ] ifFalse:[ |
6019 names := classes collect:[:cls | |
6019 classes size == 1 ifTrue:[ |
6020 |nm| |
6020 msg := msg , 'is always:\\'. |
6021 cls == UndefinedObject ifTrue:[ |
6021 msg := msg , ' ' , classes first name , '\'. |
6022 'nil' |
6022 ] ifFalse:[ |
6023 ] ifFalse:[ |
6023 msg := msg , 'is one of:\\'. |
6024 cls == True ifTrue:[ |
6024 classes := classes asOrderedCollection. |
6025 'true' |
6025 classes size > 20 ifTrue:[ |
6026 ] ifFalse:[ |
6026 classes := classes copyFrom:1 to:20. |
6027 cls == False ifTrue:[ |
6027 cut := true |
6028 'false' |
6028 ] ifFalse:[ |
6029 ] ifFalse:[ |
6029 cut := false. |
6030 cls name |
6030 ]. |
6031 ] |
6031 names := classes collect:[:cls | |
6032 ] |
6032 |nm| |
6033 ]. |
6033 cls == UndefinedObject ifTrue:[ |
6034 ]. |
6034 'nil' |
6035 names sort. |
6035 ] ifFalse:[ |
6036 names do:[:nm | |
6036 cls == True ifTrue:[ |
6037 msg := msg , ' ' , nm , '\'. |
6037 'true' |
6038 ]. |
6038 ] ifFalse:[ |
6039 ] |
6039 cls == False ifTrue:[ |
|
6040 'false' |
|
6041 ] ifFalse:[ |
|
6042 cls name |
|
6043 ] |
|
6044 ] |
|
6045 ]. |
|
6046 ]. |
|
6047 names sort. |
|
6048 names do:[:nm | |
|
6049 msg := msg , ' ' , nm , '\'. |
|
6050 ]. |
|
6051 ] |
|
6052 ]. |
6040 ]. |
6053 ]. |
6041 |
6054 |
6042 box := InfoBox title:msg withCRs. |
6055 box := InfoBox title:msg withCRs. |
6043 box label:'variable type information'. |
6056 box label:'variable type information'. |
6044 box showAtPointer |
6057 box showAtPointer |
|
6058 |
|
6059 "Modified: 13.12.1995 / 12:59:03 / cg" |
6045 ! |
6060 ! |
6046 |
6061 |
6047 variableListMenu |
6062 variableListMenu |
6048 |labels selectors| |
6063 |labels selectors| |
6049 |
6064 |
6050 currentClass isNil ifTrue:[ |
6065 currentClass isNil ifTrue:[ |
6051 variableListView flash. |
6066 variableListView flash. |
6052 ^ nil |
6067 ^ nil |
6053 ]. |
6068 ]. |
6054 |
6069 |
6055 labels := #( |
6070 labels := #( |
6056 'instvar refs ...' |
6071 'instvar refs ...' |
6057 'classvar refs ...' |
6072 'classvar refs ...' |
6058 'all instvar refs ...' |
6073 'all instvar refs ...' |
6059 'all classvar refs ...' |
6074 'all classvar refs ...' |
6060 '-' |
6075 '-' |
6061 'instvar mods ...' |
6076 'instvar mods ...' |
6062 'classvar mods ...' |
6077 'classvar mods ...' |
6063 'all instvar mods ...' |
6078 'all instvar mods ...' |
6064 'all classvar mods ...' |
6079 'all classvar mods ...' |
6065 ). |
6080 ). |
6066 selectors := #( |
6081 selectors := #( |
6067 instVarRefs |
6082 instVarRefs |
6068 classVarRefs |
6083 classVarRefs |
6069 allInstVarRefs |
6084 allInstVarRefs |
6070 allClassVarRefs |
6085 allClassVarRefs |
6071 nil |
6086 nil |
6072 instVarMods |
6087 instVarMods |
6073 classVarMods |
6088 classVarMods |
6074 allInstVarMods |
6089 allInstVarMods |
6075 allClassVarMods |
6090 allClassVarMods |
6076 ). |
6091 ). |
6077 |
6092 |
6078 (showInstance and:[variableListView hasSelection]) ifTrue:[ |
6093 ("showInstance and:[" variableListView hasSelection "]" ) ifTrue:[ |
6079 labels := labels , #( |
6094 labels := labels , #( |
6080 '-' |
6095 '-' |
6081 'type information' |
6096 'type information' |
6082 ). |
6097 ). |
6083 selectors := selectors , #( |
6098 selectors := selectors , #( |
6084 nil |
6099 nil |
6085 varTypeInfo |
6100 varTypeInfo |
6086 ). |
6101 ). |
6087 ]. |
6102 ]. |
6088 |
6103 |
6089 ^ PopUpMenu labels:(resources array:labels) |
6104 ^ PopUpMenu labels:(resources array:labels) |
6090 selectors:selectors |
6105 selectors:selectors |
|
6106 |
|
6107 "Modified: 13.12.1995 / 12:49:49 / cg" |
6091 ! |
6108 ! |
6092 |
6109 |
6093 variableSelection:lineNr |
6110 variableSelection:lineNr |
6094 "variable selection changed" |
6111 "variable selection changed" |
6095 |
6112 |