author | Claus Gittinger <cg@exept.de> |
Sun, 23 Sep 2018 01:09:40 +0200 | |
changeset 4302 | 97c125843381 |
parent 4287 | 66641d57216d |
child 4357 | 1f18f1094e72 |
permissions | -rw-r--r-- |
4287 | 1 |
"{ Encoding: utf8 }" |
2 |
||
2 | 3 |
" |
4 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
3810 | 5 |
All Rights Reserved |
2 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
1081 | 14 |
"{ Package: 'stx:libcomp' }" |
15 |
||
3548 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
141 | 18 |
Parser subclass:#Explainer |
3813 | 19 |
instanceVariableNames:'' |
20 |
classVariableNames:'' |
|
21 |
poolDictionaries:'' |
|
22 |
category:'System-Compiler' |
|
2 | 23 |
! |
24 |
||
3866 | 25 |
Object variableSubclass:#ActionWithInfo |
26 |
instanceVariableNames:'block info' |
|
27 |
classVariableNames:'' |
|
28 |
poolDictionaries:'' |
|
29 |
privateIn:Explainer |
|
30 |
! |
|
31 |
||
396 | 32 |
!Explainer class methodsFor:'documentation'! |
2 | 33 |
|
20 | 34 |
copyright |
35 |
" |
|
36 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
3810 | 37 |
All Rights Reserved |
20 | 38 |
|
39 |
This software is furnished under a license and may be used |
|
40 |
only in accordance with the terms of that license and with the |
|
41 |
inclusion of the above copyright notice. This software may not |
|
42 |
be provided or otherwise made available to, or used by, any |
|
43 |
other person. No title to or ownership of the software is |
|
44 |
hereby transferred. |
|
45 |
" |
|
46 |
! |
|
47 |
||
2 | 48 |
documentation |
49 |
" |
|
2828
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
50 |
a very simple explainer - much more should be added... |
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
51 |
|
3608 | 52 |
This one is involved, when the 'explain' menu function is used in a |
1728 | 53 |
codeView (popup or via CMD-E), or if the mouse button is clicked |
3608 | 54 |
on some code construct in the new browser (then a short explanaition |
55 |
is shown in the lower info area). |
|
263 | 56 |
|
2828
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
57 |
Most of the texts returned here are heuristically motivated, |
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
58 |
based on the experience with beginners and their frequently asked questions. |
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
59 |
|
3885 | 60 |
TODO: |
61 |
this is in an experimental stage; the naive type inferer replicates code |
|
62 |
found in DWIM support; it should use the code there. |
|
63 |
||
263 | 64 |
[author:] |
3608 | 65 |
Claus Gittinger |
2 | 66 |
" |
67 |
! ! |
|
68 |
||
396 | 69 |
!Explainer class methodsFor:'explaining'! |
2 | 70 |
|
2193
9416fc17ee62
pass the interval to the explainer
Claus Gittinger <cg@exept.de>
parents:
2191
diff
changeset
|
71 |
explainLiteralNode:node in:code forClass:cls short:short interval:intervalIfKnown |
3842 | 72 |
|expl literalValue literalsClass findInnerMost elementIndex codeOfCharacterBeforeCursor| |
1728 | 73 |
|
74 |
literalValue := node value. |
|
3842 | 75 |
literalsClass := literalValue class. |
76 |
expl := (self asClassLink:literalsClass name "allBold") , '-constant'. |
|
2954
0943337cfb73
changed: #explainLiteralNode:in:forClass:short:interval:
Claus Gittinger <cg@exept.de>
parents:
2940
diff
changeset
|
77 |
|
2316
f09794e008f8
changed: #explainLiteralNode:in:forClass:short:interval:
Claus Gittinger <cg@exept.de>
parents:
2315
diff
changeset
|
78 |
(literalValue isInteger) ifTrue:[ |
3697 | 79 |
(literalValue ~~ 0 and:[literalValue ~~ 1]) ifTrue:[ |
3319 | 80 |
expl := expl , ' ('. |
3798 | 81 |
#(2 10 16) with:#('binary: ' 'decimal: ' 'hex: ') do:[:base :baseExpl | |
3319 | 82 |
|bStr| |
3203 | 83 |
|
3319 | 84 |
base ~= (node token radix ? 10) ifTrue:[ |
85 |
bStr := base==10 |
|
86 |
ifTrue:[literalValue printString] |
|
3798 | 87 |
ifFalse:[(literalValue printStringRadix:base) leftPaddedTo:2 with:$0]. "/ looks better: at least a size of 2 |
88 |
"/ oops - someone looks at a largeInteger |
|
89 |
bStr := bStr contractAtEndTo:40. |
|
3319 | 90 |
expl := expl , ' ' , baseExpl, bStr |
91 |
]. |
|
92 |
]. |
|
93 |
expl := expl , ' )'. |
|
3798 | 94 |
]. |
3319 | 95 |
^ expl. |
96 |
]. |
|
97 |
(literalValue isCharacter) ifTrue:[ |
|
98 |
expl := expl , ' ',literalValue storeString,' (code: ',literalValue codePoint printString,' hex: 16r',literalValue codePoint hexPrintString,')'. |
|
99 |
^ expl. |
|
2316
f09794e008f8
changed: #explainLiteralNode:in:forClass:short:interval:
Claus Gittinger <cg@exept.de>
parents:
2315
diff
changeset
|
100 |
]. |
2954
0943337cfb73
changed: #explainLiteralNode:in:forClass:short:interval:
Claus Gittinger <cg@exept.de>
parents:
2940
diff
changeset
|
101 |
|
0943337cfb73
changed: #explainLiteralNode:in:forClass:short:interval:
Claus Gittinger <cg@exept.de>
parents:
2940
diff
changeset
|
102 |
(node isLiteralArray and:[intervalIfKnown notNil]) ifTrue:[ |
3319 | 103 |
"/ see which element we have to explain |
104 |
findInnerMost := |
|
105 |
[:token | |
|
106 |
token value keysAndValuesDo:[:index :eachToken | |
|
3810 | 107 |
|selectorOrName selectorExplanation| |
2954
0943337cfb73
changed: #explainLiteralNode:in:forClass:short:interval:
Claus Gittinger <cg@exept.de>
parents:
2940
diff
changeset
|
108 |
|
3319 | 109 |
((eachToken start to:eachToken stop) intersect:intervalIfKnown) notEmpty ifTrue:[ |
110 |
elementIndex := index. "/ see below |
|
2954
0943337cfb73
changed: #explainLiteralNode:in:forClass:short:interval:
Claus Gittinger <cg@exept.de>
parents:
2940
diff
changeset
|
111 |
|
3319 | 112 |
eachToken value isArray ifTrue:[ |
113 |
findInnerMost value:eachToken. |
|
114 |
]. |
|
115 |
eachToken value isSymbol ifTrue:[ |
|
116 |
selectorOrName := eachToken value. |
|
117 |
selectorOrName isUppercaseFirst ifTrue:[ |
|
118 |
(Smalltalk includesKey:selectorOrName) ifTrue:[ |
|
119 |
^ expl, ' / ', (Explainer explainGlobal:selectorOrName inClass:cls short:short) |
|
120 |
]. |
|
121 |
]. |
|
3810 | 122 |
selectorExplanation := (Explainer explainSelector:selectorOrName inClass:cls short:short). |
123 |
selectorExplanation isNil ifTrue:[^ expl]. |
|
124 |
^ expl, ' / ', selectorExplanation. |
|
3319 | 125 |
]. |
126 |
]. |
|
127 |
] |
|
128 |
]. |
|
129 |
findInnerMost value:node token. |
|
2954
0943337cfb73
changed: #explainLiteralNode:in:forClass:short:interval:
Claus Gittinger <cg@exept.de>
parents:
2940
diff
changeset
|
130 |
]. |
0943337cfb73
changed: #explainLiteralNode:in:forClass:short:interval:
Claus Gittinger <cg@exept.de>
parents:
2940
diff
changeset
|
131 |
|
2955
d52a51930921
changed: #explainLiteralNode:in:forClass:short:interval:
Claus Gittinger <cg@exept.de>
parents:
2954
diff
changeset
|
132 |
(literalValue isArray or:[ literalValue isByteArray or:[ literalValue isString ]]) ifTrue:[ |
3319 | 133 |
literalValue size == 0 ifTrue:[ |
134 |
^ 'empty ' , expl |
|
135 |
]. |
|
136 |
elementIndex notNil ifTrue:[ |
|
137 |
^ expl , (' (size=%1; element=%2)' bindWith:literalValue size with:elementIndex) |
|
138 |
]. |
|
139 |
literalValue isString ifTrue:[ |
|
140 |
elementIndex := intervalIfKnown start - node token start. |
|
2955
d52a51930921
changed: #explainLiteralNode:in:forClass:short:interval:
Claus Gittinger <cg@exept.de>
parents:
2954
diff
changeset
|
141 |
|
3319 | 142 |
(elementIndex between:1 and:literalValue size) ifTrue:[ |
3601 | 143 |
codeOfCharacterBeforeCursor := (literalValue at:elementIndex) codePoint. |
144 |
^ expl , (' (size=%1; position=%2; codePoint=16r%3)' |
|
145 |
bindWith:literalValue size |
|
146 |
with:elementIndex |
|
147 |
with:codeOfCharacterBeforeCursor hexPrintString) |
|
3319 | 148 |
] |
149 |
]. |
|
150 |
^ expl , (' (size=%1)' bindWith:literalValue size) |
|
1728 | 151 |
]. |
2191
87e08ab150e2
improved explain (symbol in an array literal)
Claus Gittinger <cg@exept.de>
parents:
2190
diff
changeset
|
152 |
|
1728 | 153 |
^ expl |
1926
935dbaeca76f
show class package in explanation
Claus Gittinger <cg@exept.de>
parents:
1910
diff
changeset
|
154 |
|
3798 | 155 |
"Modified (format): / 30-04-2016 / 16:00:05 / cg" |
1728 | 156 |
! |
157 |
||
2193
9416fc17ee62
pass the interval to the explainer
Claus Gittinger <cg@exept.de>
parents:
2191
diff
changeset
|
158 |
explainMessageNode:node in:code forClass:cls short:short interval:intervalIfKnown |
1771 | 159 |
"answer a string which explains node" |
160 |
||
3203 | 161 |
|receiver nm srchClass selector selectorString implClass |
1728 | 162 |
boldSelectorString globalValue recClassSet |
3855 | 163 |
implMethod implMethodComment info definer |
1854 | 164 |
instances classesOfInstVars implementingClasses canBeNil |
3866 | 165 |
bestMatches hint redefiningClasses| |
1728 | 166 |
|
3538 | 167 |
selector := node buildSelectorString. |
3842 | 168 |
selectorString := selector printString contractTo:50. |
3548 | 169 |
selector := selector asSymbolIfInterned. "/ avoid creating new symbols. |
3810 | 170 |
selector isNil ifTrue:[ |
171 |
^ '%1 is NOWHERE impemented.' bindWith:boldSelectorString |
|
172 |
]. |
|
173 |
||
3859 | 174 |
selectorString := self asLink:selectorString to:(self actionToBrowseImplementorsOf:selector). |
1926
935dbaeca76f
show class package in explanation
Claus Gittinger <cg@exept.de>
parents:
1910
diff
changeset
|
175 |
boldSelectorString := selectorString "allBold". |
3810 | 176 |
|
3885 | 177 |
recClassSet := self guessPossibleClassesFor:(node receiver) in:code forClass:cls. |
1733 | 178 |
recClassSet size == 1 ifTrue:[ |
3209 | 179 |
srchClass := recClassSet first. |
180 |
"take care - Set cannot store nil!!" |
|
181 |
implementingClasses := (recClassSet collect:[:cls | cls whichClassIncludesSelector:selector]) asArray. |
|
1869 | 182 |
|
3209 | 183 |
(implementingClasses includes:nil) ifTrue:[ |
184 |
implementingClasses size > 1 ifTrue:[ |
|
185 |
^ 'possibly not understood: %1 (%2 other implementors)' |
|
186 |
bindWith:selector "allBold" |
|
187 |
with:(implementingClasses size - 1) |
|
188 |
]. |
|
1869 | 189 |
|
3209 | 190 |
(#('self' 'super' 'true' 'false' 'thisContext') includes:selector) ifTrue:[ |
3885 | 191 |
^ ('%1 is NOT understood here (missing period after previous statement?)' |
3854 | 192 |
bindWith:selector allBold) |
3209 | 193 |
]. |
3193 | 194 |
|
3854 | 195 |
hint := ''. |
3209 | 196 |
(recClassSet contains:[:cls | cls isMeta not and:[cls theMetaclass canUnderstand:selector]]) ifTrue:[ |
197 |
hint := '. But class understands it - did you mean "rcvr class ',selector,'..." ?'. |
|
198 |
]. |
|
199 |
bestMatches := Parser findBestSelectorsFor:selector in:srchClass. |
|
3927 | 200 |
bestMatches notEmptyOrNil ifTrue:[ |
3928 | 201 |
|guessedClass| |
202 |
guessedClass := srchClass whichClassIncludesSelector:bestMatches first. |
|
203 |
guessedClass notNil ifTrue:[ |
|
3927 | 204 |
^ ('%1 is NOT understood here (best guess is: "%2" from %3)' |
205 |
bindWith:selector allBold |
|
206 |
with:(bestMatches first "allBold") |
|
3928 | 207 |
with:guessedClass name) , hint. |
3927 | 208 |
]. |
3209 | 209 |
]. |
3927 | 210 |
^ ('%1 is NOT understood here' bindWith:selector allBold), hint |
3209 | 211 |
]. |
1733 | 212 |
]. |
213 |
||
214 |
implementingClasses isNil ifTrue:[ |
|
3209 | 215 |
receiver := node receiver. |
216 |
receiver isVariable ifTrue:[ |
|
217 |
nm := receiver name. |
|
218 |
nm = 'self' ifTrue:[ |
|
219 |
srchClass := cls |
|
220 |
]. |
|
221 |
nm = 'super' ifTrue:[ |
|
222 |
srchClass := cls superclass |
|
223 |
]. |
|
224 |
definer := receiver whoDefines:nm. |
|
225 |
definer isNil ifTrue:[ |
|
226 |
"/ not a local or argument |
|
227 |
(cls instanceVariableNames includes:nm) ifTrue:[ |
|
228 |
"/ ok - an instVar; see what values we find... |
|
4059 | 229 |
instances := cls allSubInstances select:[:eachInst| eachInst isProtoObject not]. |
3209 | 230 |
classesOfInstVars := instances collect:[:eachInst | (eachInst instVarNamed:nm) class] as:Set. |
231 |
canBeNil := (classesOfInstVars remove:UndefinedObject ifAbsent:[]) notNil. |
|
232 |
"take care - Set cannot store nil!!" |
|
233 |
implementingClasses := classesOfInstVars collect:[:cls | (cls whichClassIncludesSelector:selector) ? 0]. |
|
234 |
implementingClasses remove:0 ifAbsent:[]. |
|
235 |
] ifFalse:[ |
|
236 |
nm isUppercaseFirst ifTrue:[ |
|
237 |
nm knownAsSymbol ifTrue:[ |
|
238 |
globalValue := Smalltalk at:nm asSymbol. |
|
239 |
globalValue isClass ifTrue:[ |
|
240 |
srchClass := globalValue class. |
|
241 |
]. |
|
242 |
] |
|
243 |
]. |
|
244 |
]. |
|
245 |
]. |
|
246 |
]. |
|
1728 | 247 |
|
3209 | 248 |
receiver isLiteral ifTrue:[ |
249 |
srchClass := receiver value class |
|
250 |
]. |
|
1728 | 251 |
|
3209 | 252 |
srchClass notNil ifTrue:[ |
253 |
implClass := srchClass whichClassIncludesSelector:selector. |
|
254 |
implClass isNil ifTrue:[ |
|
255 |
^ '%1 is NOT understood here.' bindWith:boldSelectorString |
|
256 |
]. |
|
3866 | 257 |
redefiningClasses := srchClass allSubclasses select:[:cls | cls implements:selector]. |
258 |
] ifFalse:[ |
|
259 |
implementingClasses isNil ifTrue:[ |
|
260 |
implementingClasses := Smalltalk allImplementorsOf:selector |
|
261 |
]. |
|
3209 | 262 |
]. |
1728 | 263 |
]. |
264 |
||
3866 | 265 |
implClass isNil ifTrue:[ |
266 |
implementingClasses size == 1 ifTrue:[ |
|
267 |
implClass := implementingClasses anElement. |
|
268 |
] |
|
269 |
]. |
|
270 |
implClass notNil ifTrue:[ |
|
271 |
|clsName action1 action2| |
|
3855 | 272 |
|
3810 | 273 |
implMethod := implClass compiledMethodAt:selector. |
274 |
clsName := implClass name. |
|
3859 | 275 |
clsName := self asLink:clsName to:(self actionToBrowseClass:implClass selector:selector). |
4287 | 276 |
info := '%1 » %2' bindWith:clsName "allBold" with:selectorString. |
3866 | 277 |
info := self asLink:info to:(action1 := self actionToBrowseClass:implClass selector:selector info:nil). |
278 |
||
279 |
redefiningClasses size > 0 ifTrue:[ |
|
280 |
redefiningClasses size == 1 ifTrue:[ |
|
281 |
|redefiner| |
|
282 |
redefiner := redefiningClasses first. |
|
283 |
info := info,(' (redefined in %1)' |
|
284 |
bindWith:(self |
|
285 |
asLink:redefiner name |
|
286 |
to:(action2 := self actionToBrowseClass:redefiner selector:selector))). |
|
287 |
action2 info:((redefiner compiledMethodAt:selector) source) |
|
288 |
] ifFalse:[ |
|
289 |
info := info,' (redefined in ' |
|
290 |
,('%1 classes' |
|
291 |
bindWith:(self |
|
292 |
asLink:redefiningClasses size printString |
|
293 |
info:'Browse redefiners' |
|
294 |
to:(action2 := self actionToBrowseImplementorsOf:selector in:redefiningClasses))) |
|
295 |
,')'. |
|
296 |
action2 info:'Browse redefiners' |
|
297 |
]. |
|
298 |
]. |
|
299 |
||
3885 | 300 |
implMethodComment := self fetchDescriptionOfMethod:"fetchCommentOfMethod:"implMethod. |
3855 | 301 |
implMethodComment notNil ifTrue:[ |
3883 | 302 |
info := info , Character cr , implMethodComment. |
3866 | 303 |
action1 info:implMethod source. |
3855 | 304 |
]. |
305 |
^ info |
|
3842 | 306 |
"/ (srchClass isNil and:[(cls includesBehavior:implClass) not]) ifTrue:[ |
307 |
"/ "/ info := 'guess: ', info. |
|
308 |
"/ info := info , ' (guess)'. |
|
309 |
"/ ]. |
|
1728 | 310 |
] ifFalse:[ |
3209 | 311 |
info := Explainer explainSelector:selector inClass:cls short:short. |
1728 | 312 |
]. |
313 |
||
3798 | 314 |
"/ implementingClasses notEmptyOrNil ifTrue:[ |
315 |
"/ implMethods := implementingClasses collect:[:implClass | implClass compiledMethodAt:selector]. |
|
316 |
"/ implMethods size <= 8 ifTrue:[ |
|
317 |
"/ implMethods size < 4 ifTrue:[ |
|
318 |
"/ "/ show full comments |
|
319 |
"/ comments := implMethods |
|
320 |
"/ collect:[:implMethod | implMethod comment] |
|
321 |
"/ thenSelect:[:comment | comment notEmptyOrNil]. |
|
322 |
"/ ] ifFalse:[ |
|
323 |
"/ "/ show first lines one |
|
324 |
"/ comments := implMethods |
|
325 |
"/ collect:[:implMethod | (self fetchCommentOfMethod:implMethod)] |
|
326 |
"/ thenSelect:[:comment | comment notEmptyOrNil]. |
|
327 |
"/ ]. |
|
328 |
"/ comments := comments collect:[:each | each colorizeAllWith:(UserPreferences current commentColor) ]. |
|
329 |
"/ short ifTrue:[ |
|
330 |
"/ comments := comments collect:[:implMethodComment | implMethodComment firstLine] as:Set. |
|
331 |
"/ comments size == 1 ifTrue:[ |
|
332 |
"/ ^ info , ' ' , (comments first). |
|
333 |
"/ ]. |
|
334 |
"/ ^ info |
|
335 |
"/ ]. |
|
336 |
"/ info := info,'\'withCRs. |
|
337 |
"/ comments |
|
338 |
"/ with:implementingClasses |
|
339 |
"/ do:[:eachComment :eachClass | |
|
340 |
"/ info := info,'\comment in ',eachClass name,':\',(eachComment asStringCollection asString) |
|
341 |
"/ ]. |
|
342 |
"/ ]. |
|
343 |
"/ ]. |
|
1728 | 344 |
^ info |
1854 | 345 |
|
3798 | 346 |
"Modified: / 30-04-2016 / 17:08:11 / cg" |
1728 | 347 |
! |
348 |
||
2193
9416fc17ee62
pass the interval to the explainer
Claus Gittinger <cg@exept.de>
parents:
2191
diff
changeset
|
349 |
explainMethodNode:node in:code forClass:cls short:short interval:intervalIfKnown |
3203 | 350 |
|srchClass selector selectorString implClass |
3859 | 351 |
"sendingMethods numSendingMethods sendingClasses" | |
1728 | 352 |
|
3203 | 353 |
selector := node selector. |
3549 | 354 |
selector := selector asSymbolIfInterned. "/ avoid creating new symbols. |
3842 | 355 |
selectorString := selector printString contractTo:50. |
1728 | 356 |
|
357 |
(srchClass := cls superclass) notNil ifTrue:[ |
|
3549 | 358 |
implClass := srchClass whichClassIncludesSelector:selector. |
359 |
implClass notNil ifTrue:[ |
|
3855 | 360 |
^ '%1 overrides implementation in %2.' |
3859 | 361 |
bindWith:(self asLink:selectorString "allBold" to:(self actionToOpenMethodFinderFor:selector)) |
362 |
with:(self asLink:implClass name "allBold" to:(self actionToBrowseClass:implClass selector:selector)) |
|
3549 | 363 |
]. |
1728 | 364 |
]. |
2223
50b76baab48b
changed: #explainMethodNode:in:forClass:short:interval:
Claus Gittinger <cg@exept.de>
parents:
2214
diff
changeset
|
365 |
(cls includesSelector:selector) ifFalse:[ |
3859 | 366 |
^ '%1: a new method.' bindWith:selectorString "allBold" |
1728 | 367 |
]. |
368 |
"/ |
|
3203 | 369 |
"/ sendingMethods := SystemBrowser |
370 |
"/ allCallsOn:selector |
|
371 |
"/ in:(cls withAllSubclasses , cls allSubclasses) |
|
372 |
"/ ignoreCase:false |
|
1728 | 373 |
"/ match:false. |
374 |
"/ sendingMethods := sendingMethods select:[:eachMethod | eachMethod mclass notNil]. "/ remove unbound ones |
|
375 |
"/ |
|
376 |
"/ sendingClasses := (sendingMethods collect:[:eachMethod | eachMethod mclass]) asSet. |
|
377 |
"/ numSendingMethods := sendingMethods size. |
|
378 |
"/ numSendingMethods == 1 ifTrue:[ |
|
379 |
"/ sendingClasses first == cls ifTrue:[ |
|
3203 | 380 |
"/ ^ '%1: sent locally from %2.' |
1728 | 381 |
"/ bindWith:boldSelectorString |
1926
935dbaeca76f
show class package in explanation
Claus Gittinger <cg@exept.de>
parents:
1910
diff
changeset
|
382 |
"/ with:sendingMethods first selector "allBold" |
1728 | 383 |
"/ ]. |
3203 | 384 |
"/ ^ '%1: sent in hierarchy from %2 in %3.' |
1728 | 385 |
"/ bindWith:boldSelectorString |
1926
935dbaeca76f
show class package in explanation
Claus Gittinger <cg@exept.de>
parents:
1910
diff
changeset
|
386 |
"/ with:sendingMethods first selector "allBold" |
1728 | 387 |
"/ with:sendingClasses first name. |
388 |
"/ ]. |
|
389 |
"/ numSendingMethods == 2 ifTrue:[ |
|
390 |
"/ sendingClasses asIdentitySet size == 1 ifTrue:[ |
|
391 |
"/ sendingClasses first == cls ifTrue:[ |
|
3203 | 392 |
"/ ^ '%1: sent locally from %2 and %3.' |
1728 | 393 |
"/ bindWith:boldSelectorString |
1926
935dbaeca76f
show class package in explanation
Claus Gittinger <cg@exept.de>
parents:
1910
diff
changeset
|
394 |
"/ with:sendingMethods first selector "allBold" |
935dbaeca76f
show class package in explanation
Claus Gittinger <cg@exept.de>
parents:
1910
diff
changeset
|
395 |
"/ with:sendingMethods second selector "allBold" |
1728 | 396 |
"/ ]. |
3203 | 397 |
"/ ^ '%1: sent in hierarchy from %2 and %3 in %4.' |
1728 | 398 |
"/ bindWith:boldSelectorString |
1926
935dbaeca76f
show class package in explanation
Claus Gittinger <cg@exept.de>
parents:
1910
diff
changeset
|
399 |
"/ with:sendingMethods first selector "allBold" |
935dbaeca76f
show class package in explanation
Claus Gittinger <cg@exept.de>
parents:
1910
diff
changeset
|
400 |
"/ with:sendingMethods second selector "allBold" |
1728 | 401 |
"/ with:sendingClasses first name. |
402 |
"/ ]. |
|
403 |
"/ ]. |
|
404 |
"/ numSendingMethods == 0 ifTrue:[ |
|
3203 | 405 |
"/"/ ^ '%1: no sender found.' |
1728 | 406 |
"/"/ bindWith:boldSelectorString. |
407 |
"/ ^ nil |
|
408 |
"/ ]. |
|
3203 | 409 |
"/ ^ '%1: %2 sending methods in hierarchy.' |
1728 | 410 |
"/ bindWith:boldSelectorString |
411 |
"/ with:numSendingMethods. |
|
412 |
"/ |
|
413 |
"/ "/ the following is too expensive... |
|
414 |
"/"/ sendingMethods := SystemBrowser allCallsOn:selector in:Smalltalk allClasses. |
|
415 |
"/"/ numSendingMethods == 0 ifTrue:[ |
|
416 |
"/"/ ^ '%1: nowhere sent.' bindWith:boldSelectorString |
|
417 |
"/"/ ]. |
|
418 |
"/"/ numSendingMethods == 1 ifTrue:[ |
|
419 |
"/"/ sendingMethods first mclass == cls ifTrue:[ |
|
3203 | 420 |
"/"/ ^ '%1: only sent from %2.' |
1728 | 421 |
"/"/ bindWith:boldSelectorString |
1926
935dbaeca76f
show class package in explanation
Claus Gittinger <cg@exept.de>
parents:
1910
diff
changeset
|
422 |
"/"/ with:sendingMethods first selector "allBold" |
1728 | 423 |
"/"/ ]. |
3203 | 424 |
"/"/ ^ '%1: only sent from %2 in %3.' |
1728 | 425 |
"/"/ bindWith:boldSelectorString |
1926
935dbaeca76f
show class package in explanation
Claus Gittinger <cg@exept.de>
parents:
1910
diff
changeset
|
426 |
"/"/ with:sendingMethods first selector "allBold" |
1728 | 427 |
"/"/ with:sendingMethods first mclass name. |
428 |
"/"/ ]. |
|
429 |
"/"/ sendingClasses := (sendingMethods collect:[:eachMethod | eachMethod mclass]) asSet. |
|
430 |
"/"/ sendingClasses size == 1 ifTrue:[ |
|
431 |
"/"/ sendingClasses first == cls ifTrue:[ |
|
3203 | 432 |
"/"/ ^ '%1: locally sent from %2 methods.' |
1728 | 433 |
"/"/ bindWith:boldSelectorString |
434 |
"/"/ with:numSendingMethods |
|
435 |
"/"/ ]. |
|
3203 | 436 |
"/"/ ^ '%1 only sent from %2 methods in %3.' |
1728 | 437 |
"/"/ bindWith:boldSelectorString |
438 |
"/"/ with:numSendingMethods |
|
439 |
"/"/ with:sendingClasses first name. |
|
440 |
"/"/ ]. |
|
441 |
||
442 |
^ nil |
|
1926
935dbaeca76f
show class package in explanation
Claus Gittinger <cg@exept.de>
parents:
1910
diff
changeset
|
443 |
|
935dbaeca76f
show class package in explanation
Claus Gittinger <cg@exept.de>
parents:
1910
diff
changeset
|
444 |
"Modified: / 09-10-2006 / 12:11:16 / cg" |
1728 | 445 |
! |
446 |
||
3203 | 447 |
explainNode:node in:code forClass:cls short:short |
2193
9416fc17ee62
pass the interval to the explainer
Claus Gittinger <cg@exept.de>
parents:
2191
diff
changeset
|
448 |
self explainNode:node in:code forClass:cls short:short interval:nil |
9416fc17ee62
pass the interval to the explainer
Claus Gittinger <cg@exept.de>
parents:
2191
diff
changeset
|
449 |
! |
9416fc17ee62
pass the interval to the explainer
Claus Gittinger <cg@exept.de>
parents:
2191
diff
changeset
|
450 |
|
9416fc17ee62
pass the interval to the explainer
Claus Gittinger <cg@exept.de>
parents:
2191
diff
changeset
|
451 |
explainNode:node in:code forClass:cls short:short interval:intervalIfKnown |
4210 | 452 |
"parsetree based explanations" |
453 |
||
1728 | 454 |
node isVariable ifTrue:[ |
3810 | 455 |
^ self explainVariableNode:node in:code forClass:cls short:short interval:intervalIfKnown. |
1728 | 456 |
]. |
457 |
||
458 |
node isLiteral ifTrue:[ |
|
3810 | 459 |
^ self explainLiteralNode:node in:code forClass:cls short:short interval:intervalIfKnown |
1728 | 460 |
]. |
461 |
||
462 |
node isMessage ifTrue:[ |
|
3810 | 463 |
^ self explainMessageNode:node in:code forClass:cls short:short interval:intervalIfKnown |
1728 | 464 |
]. |
465 |
||
466 |
node isMethod ifTrue:[ |
|
3810 | 467 |
^ self explainMethodNode:node in:code forClass:cls short:short interval:intervalIfKnown |
1728 | 468 |
]. |
469 |
^ nil |
|
4210 | 470 |
|
471 |
"Modified (comment): / 27-11-2017 / 18:05:22 / cg" |
|
1728 | 472 |
! |
473 |
||
2193
9416fc17ee62
pass the interval to the explainer
Claus Gittinger <cg@exept.de>
parents:
2191
diff
changeset
|
474 |
explainVariableNode:node in:code forClass:cls short:short interval:intervalIfKnown |
3842 | 475 |
|expl nm nmBold definingNode namePart argNode argClass argClassSet| |
1728 | 476 |
|
477 |
nm := node name. |
|
478 |
||
479 |
(#( 'self' 'super' 'thisContext' 'here') includes:nm) ifTrue:[ |
|
3810 | 480 |
^ Explainer explainPseudoVariable:nm in:cls short:short |
1728 | 481 |
]. |
482 |
||
1926
935dbaeca76f
show class package in explanation
Claus Gittinger <cg@exept.de>
parents:
1910
diff
changeset
|
483 |
nm notNil ifTrue:[ nmBold := nm "allBold" ]. |
1728 | 484 |
|
485 |
definingNode := node whoDefines:nm. |
|
486 |
definingNode notNil ifTrue:[ |
|
3810 | 487 |
namePart := '''' , nmBold , ''''. |
488 |
definingNode isMethod ifTrue:[ |
|
3842 | 489 |
argNode := definingNode arguments detect:[:arg | arg name = nm] ifNone:nil. |
490 |
argNode notNil ifTrue:[ |
|
3883 | 491 |
expl := namePart , ': a method argument.'. |
3842 | 492 |
|
3885 | 493 |
argClassSet := self guessPossibleClassesFor:argNode in:code forClass:cls. |
3842 | 494 |
argClassSet size == 1 ifTrue:[ |
495 |
argClass := argClassSet first. |
|
496 |
]. |
|
3810 | 497 |
]. |
498 |
]. |
|
499 |
expl isNil ifTrue:[ |
|
500 |
definingNode isBlock ifTrue:[ |
|
501 |
(definingNode arguments contains:[:arg | arg name = nm]) ifTrue:[ |
|
3883 | 502 |
expl := namePart , ': a block argument.' |
3810 | 503 |
]. |
504 |
]. |
|
505 |
]. |
|
506 |
expl isNil ifTrue:[ |
|
3885 | 507 |
| parentNode setOfTypes isLocal typesDescription | |
3810 | 508 |
|
509 |
(parentNode := definingNode parent) notNil ifTrue:[ |
|
510 |
(isLocal := parentNode isMethod) ifTrue:[ |
|
3883 | 511 |
expl := namePart , ': a method temporary.'. |
3810 | 512 |
] ifFalse:[ |
513 |
(isLocal := parentNode isBlock) ifTrue:[ |
|
3883 | 514 |
expl := namePart , ': a block temporary.'. |
3810 | 515 |
] |
516 |
]. |
|
517 |
isLocal ifTrue:[ |
|
518 |
setOfTypes := Set new. |
|
519 |
self addTypesAssignedToLocal:nm inTree:parentNode to:setOfTypes. |
|
3885 | 520 |
setOfTypes remove:UndefinedObject ifAbsent:[]. |
3810 | 521 |
typesDescription := self typeDescriptionFor:setOfTypes andSelector:nil. |
522 |
typesDescription notNil ifTrue:[ |
|
523 |
expl := expl,' (',typesDescription,')'. |
|
524 |
]. |
|
525 |
]. |
|
526 |
]. |
|
527 |
]. |
|
528 |
expl isNil ifTrue:[ |
|
3883 | 529 |
expl := namePart , ': temporary.' |
3810 | 530 |
]. |
531 |
(cls allInstanceVariableNames includes:nm) ifTrue:[ |
|
3883 | 532 |
expl := expl , ' (instance variable is hidden)' |
3810 | 533 |
]. |
534 |
^ expl. |
|
1728 | 535 |
]. |
1938 | 536 |
|
1728 | 537 |
^ Explainer explain:node name in:code forClass:cls short:short |
1926
935dbaeca76f
show class package in explanation
Claus Gittinger <cg@exept.de>
parents:
1910
diff
changeset
|
538 |
|
1938 | 539 |
"Modified: / 07-11-2006 / 12:22:09 / cg" |
1728 | 540 |
! |
541 |
||
3203 | 542 |
fetchCommentOfMethod:mthd |
3885 | 543 |
"retrieve the comment of a method |
544 |
(if possible and there is one; otherwise, return nil)" |
|
545 |
||
546 |
|methodSource methodComment lines maxNumLines| |
|
547 |
||
548 |
self withWaitCursorDo:[ |
|
549 |
SourceCodeManagerError handle:[:ex | |
|
550 |
] do:[ |
|
551 |
methodSource := mthd source. |
|
552 |
methodComment := mthd comment |
|
3883 | 553 |
]. |
3885 | 554 |
]. |
3883 | 555 |
|
3885 | 556 |
methodComment isEmptyOrNil ifTrue:[^ nil]. |
557 |
||
558 |
lines := methodComment asStringCollection. |
|
559 |
maxNumLines := 1. |
|
560 |
true ifTrue:[ |
|
561 |
methodComment := (lines copyToMax:maxNumLines) asString. |
|
562 |
maxNumLines := 5. |
|
563 |
] ifFalse:[ |
|
564 |
methodComment := lines first. |
|
565 |
methodComment := methodComment withoutSeparators. |
|
566 |
(methodComment endsWith:',') ifTrue:[ methodComment := methodComment copyButLast:1]. |
|
567 |
methodComment := methodComment withoutSeparators. |
|
568 |
]. |
|
569 |
(lines size > maxNumLines) ifTrue:[ |
|
570 |
methodComment := methodComment , '\...' withCRs |
|
3233 | 571 |
]. |
3885 | 572 |
^ (methodComment) withColor:(UserPreferences current commentColor). |
573 |
||
574 |
"Created: / 14-09-2006 / 14:11:58 / cg" |
|
575 |
"Modified (comment): / 30-04-2016 / 16:17:18 / cg" |
|
576 |
! |
|
577 |
||
578 |
fetchDescriptionOfMethod:mthd |
|
579 |
"retrieve a desription of a method |
|
580 |
(if possible and there is one; otherwise, return nil)" |
|
581 |
||
3888 | 582 |
|methodDecl methodSource methodComment lines maxNumLines firstIndent| |
3885 | 583 |
|
584 |
self withWaitCursorDo:[ |
|
585 |
SourceCodeManagerError handle:[:ex | |
|
586 |
] do:[ |
|
587 |
methodSource := mthd source. |
|
3918 | 588 |
mthd selector isNil ifTrue:[ |
589 |
methodDecl := '??? (method removed from class)'. |
|
590 |
] ifFalse:[ |
|
591 |
methodDecl := mthd methodDefinitionTemplate. |
|
592 |
]. |
|
3885 | 593 |
methodComment := mthd comment. |
594 |
]. |
|
595 |
]. |
|
596 |
methodComment isEmptyOrNil ifTrue:[ |
|
597 |
^ methodDecl |
|
3888 | 598 |
]. |
3891 | 599 |
lines := methodComment asStringCollection withoutLeadingAndTrailingBlankLines. |
600 |
lines isEmptyOrNil ifTrue:[ |
|
601 |
^ methodDecl |
|
602 |
]. |
|
603 |
||
3888 | 604 |
firstIndent := 0. |
3889 | 605 |
lines size > 1 ifTrue:[ |
3888 | 606 |
|line2| |
3889 | 607 |
line2 := lines at:2. |
3888 | 608 |
line2 notEmpty ifTrue:[ |
4153 | 609 |
firstIndent := (line2 indexOfNonSeparator - 1) max:0. |
3888 | 610 |
]. |
3885 | 611 |
]. |
3889 | 612 |
lines := lines |
3888 | 613 |
collect:[:line | |
614 |
|l| |
|
615 |
l := line withTabsExpanded. |
|
616 |
l indexOfNonSeparator > firstIndent ifTrue:[ |
|
617 |
l := l copyFrom:firstIndent+1 |
|
618 |
]. |
|
619 |
l |
|
620 |
]. |
|
3889 | 621 |
methodComment := lines asString. |
3888 | 622 |
|
3885 | 623 |
^ methodDecl , Character cr , |
624 |
(methodComment withColor:(UserPreferences current commentColor)). |
|
3855 | 625 |
|
3888 | 626 |
"/ methodComment isEmptyOrNil ifTrue:[^ nil]. |
627 |
"/ |
|
628 |
"/ lines := methodComment asStringCollection. |
|
629 |
"/ maxNumLines := 1. |
|
630 |
"/true ifTrue:[ |
|
631 |
"/ methodComment := (lines copyToMax:maxNumLines) asString. |
|
632 |
"/ maxNumLines := 5. |
|
633 |
"/] ifFalse:[ |
|
634 |
"/ methodComment := lines first. |
|
635 |
"/ methodComment := methodComment withoutSeparators. |
|
636 |
"/ (methodComment endsWith:',') ifTrue:[ methodComment := methodComment copyButLast:1]. |
|
637 |
"/ methodComment := methodComment withoutSeparators. |
|
638 |
"/]. |
|
639 |
"/ (lines size > maxNumLines) ifTrue:[ |
|
640 |
"/ methodComment := methodComment , '\...' withCRs |
|
641 |
"/ ]. |
|
642 |
"/ ^ (methodComment) withColor:(UserPreferences current commentColor). |
|
1909 | 643 |
|
644 |
"Created: / 14-09-2006 / 14:11:58 / cg" |
|
4153 | 645 |
"Modified (format): / 20-06-2017 / 10:29:13 / cg" |
1909 | 646 |
! |
647 |
||
3885 | 648 |
guessPossibleClassesFor:node in:code forClass:cls |
2191
87e08ab150e2
improved explain (symbol in an array literal)
Claus Gittinger <cg@exept.de>
parents:
2190
diff
changeset
|
649 |
"given a node of some code of a method in cls, |
3885 | 650 |
return a collection of possible types of the node." |
2191
87e08ab150e2
improved explain (symbol in an array literal)
Claus Gittinger <cg@exept.de>
parents:
2190
diff
changeset
|
651 |
|
2809
bbf42cc4d305
changed: #guessPossibleImplementorClassesFor:in:forClass:
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
652 |
|nm globalValue definer instances classesOfInstVars ns| |
1728 | 653 |
|
654 |
node isVariable ifTrue:[ |
|
3549 | 655 |
nm := node name. |
1728 | 656 |
|
3549 | 657 |
nm = #self ifTrue:[ |
658 |
^ cls withAllSubclasses |
|
659 |
]. |
|
660 |
nm = #here ifTrue:[ |
|
661 |
^ cls withAllSuperclasses |
|
662 |
]. |
|
663 |
nm = #super ifTrue:[ |
|
664 |
^ cls allSuperclasses |
|
665 |
]. |
|
1728 | 666 |
|
3549 | 667 |
definer := node whoDefines:nm. |
668 |
definer isNil ifTrue:[ |
|
669 |
"/ not a local or argument |
|
670 |
(cls instanceVariableNames includes:nm) ifTrue:[ |
|
671 |
"/ ok - an instVar; see what values we find... |
|
4059 | 672 |
instances := cls allSubInstances select:[:eachInst | eachInst isProtoObject not]. |
3549 | 673 |
classesOfInstVars := instances collect:[:eachInst | (eachInst instVarNamed:nm) class] as:Set. |
674 |
^ classesOfInstVars. |
|
675 |
]. |
|
676 |
(cls classVariableNames includes:nm) ifTrue:[ |
|
677 |
^ Array with:(cls classVarAt:nm asSymbol) class. |
|
678 |
]. |
|
679 |
nm isUppercaseFirst ifTrue:[ |
|
680 |
nm knownAsSymbol ifTrue:[ |
|
681 |
globalValue := Smalltalk at:nm asSymbol. |
|
682 |
globalValue isClass ifTrue:[ |
|
683 |
^ Array with:globalValue class. |
|
684 |
]. |
|
685 |
]. |
|
686 |
((ns := cls topNameSpace) notNil and:[ns ~~ Smalltalk]) ifTrue:[ |
|
687 |
nm knownAsSymbol ifTrue:[ |
|
688 |
globalValue := ns at:nm asSymbol. |
|
689 |
globalValue isClass ifTrue:[ |
|
690 |
^ Array with:globalValue class. |
|
691 |
]. |
|
692 |
]. |
|
693 |
] |
|
694 |
]. |
|
695 |
]. |
|
3885 | 696 |
definer isMethod ifTrue:[ |
697 |
|callers argNr setOfTypes| |
|
698 |
||
699 |
argNr := definer arguments findFirst:[:arg | arg name = nm]. |
|
700 |
setOfTypes := IdentitySet new. |
|
701 |
"/ see who calls this message; are there any calls with an obvious type? |
|
702 |
callers := SystemBrowser allCallsOn:definer selector. |
|
703 |
callers do:[:eachCaller | |
|
704 |
|tree| |
|
3940 | 705 |
(tree := eachCaller parseTree) notNil ifTrue:[ |
706 |
tree allMessageNodesDo:[:msg | |
|
707 |
|argExpr| |
|
708 |
||
709 |
msg selector = definer selector ifTrue:[ |
|
710 |
argExpr := (msg arguments at:argNr). |
|
711 |
self addTypeOfExpressionNode:argExpr forAssignmentTo:nil to:setOfTypes. |
|
712 |
]. |
|
713 |
]. |
|
714 |
]. |
|
3885 | 715 |
]. |
716 |
setOfTypes notEmpty ifTrue:[ |
|
717 |
^ setOfTypes. |
|
718 |
]. |
|
719 |
]. |
|
3549 | 720 |
^ nil |
1728 | 721 |
]. |
722 |
||
723 |
node isLiteral ifTrue:[ |
|
3549 | 724 |
^ Array with:(node value class) |
1728 | 725 |
]. |
726 |
||
2191
87e08ab150e2
improved explain (symbol in an array literal)
Claus Gittinger <cg@exept.de>
parents:
2190
diff
changeset
|
727 |
"/ node isMessage ifTrue:[ |
87e08ab150e2
improved explain (symbol in an array literal)
Claus Gittinger <cg@exept.de>
parents:
2190
diff
changeset
|
728 |
"/ recClassSet := self guessPossibleImplementorClassesFor:(node receiver) in:code forClass:cls. |
87e08ab150e2
improved explain (symbol in an array literal)
Claus Gittinger <cg@exept.de>
parents:
2190
diff
changeset
|
729 |
"/ recClassSet isNil ifTrue:[ ^ nil ]. |
87e08ab150e2
improved explain (symbol in an array literal)
Claus Gittinger <cg@exept.de>
parents:
2190
diff
changeset
|
730 |
"/ recClassSet isEmpty ifTrue:[ ^ nil ]. |
87e08ab150e2
improved explain (symbol in an array literal)
Claus Gittinger <cg@exept.de>
parents:
2190
diff
changeset
|
731 |
"/ |
87e08ab150e2
improved explain (symbol in an array literal)
Claus Gittinger <cg@exept.de>
parents:
2190
diff
changeset
|
732 |
"/ implSet := recClassSet collect:[:recClass | recClass whichClassIncludesSelector:node selector]. |
87e08ab150e2
improved explain (symbol in an array literal)
Claus Gittinger <cg@exept.de>
parents:
2190
diff
changeset
|
733 |
"/ "/ toDo: for each implementor, parse its method for possible return types. |
87e08ab150e2
improved explain (symbol in an array literal)
Claus Gittinger <cg@exept.de>
parents:
2190
diff
changeset
|
734 |
"/ ^ rsltClassSet. |
87e08ab150e2
improved explain (symbol in an array literal)
Claus Gittinger <cg@exept.de>
parents:
2190
diff
changeset
|
735 |
"/ ]. |
1731 | 736 |
^ nil |
2809
bbf42cc4d305
changed: #guessPossibleImplementorClassesFor:in:forClass:
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
737 |
|
bbf42cc4d305
changed: #guessPossibleImplementorClassesFor:in:forClass:
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
738 |
"Modified: / 07-02-2012 / 22:19:53 / cg" |
3885 | 739 |
! |
740 |
||
741 |
withWaitCursorDo:aBlock |
|
742 |
"with wait cursor; |
|
743 |
however: this class is in libcomp (should be in libtool) |
|
744 |
so check if WindowGroup (from libview) is present" |
|
745 |
||
746 |
|windowGroup wg| |
|
747 |
||
748 |
windowGroup := Smalltalk at:#WindowGroup. |
|
749 |
windowGroup notNil ifTrue:[ |
|
750 |
(wg := windowGroup activeGroup) notNil ifTrue:[ |
|
751 |
^ wg withWaitCursorDo:aBlock. |
|
752 |
]. |
|
753 |
]. |
|
754 |
^ aBlock value. |
|
1728 | 755 |
! ! |
756 |
||
757 |
!Explainer class methodsFor:'explaining-naive'! |
|
758 |
||
2 | 759 |
explain:someText in:source forClass:aClass |
6 | 760 |
"Given a source and a substring of it, return a string containing |
761 |
an explanation. |
|
49 | 762 |
This is just a q&d implementation - to be correct, it should use the parser, |
763 |
and explain from the parsetree (instead of doing string matches). |
|
764 |
This leads to some wrong explanations, for example if some string is |
|
839 | 765 |
used as selector within a string, or if a variable is named like a |
766 |
message selector. I.e. the explanation should be context sensitive. |
|
49 | 767 |
Also, there could be much more detailed explanations." |
2 | 768 |
|
2037
003d9b5a2788
explain shared pool variables
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
769 |
^ self explain:someText in:source forClass:aClass short:false |
003d9b5a2788
explain shared pool variables
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
770 |
|
003d9b5a2788
explain shared pool variables
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
771 |
"Modified: / 07-06-2007 / 11:34:05 / cg" |
1183 | 772 |
! |
773 |
||
774 |
explain:someText in:source forClass:aClass short:shortText |
|
775 |
"Given a source and a substring of it, return a string containing |
|
776 |
an explanation. |
|
777 |
This is just a q&d implementation - to be correct, it should use the parser, |
|
778 |
and explain from the parsetree (instead of doing string matches). |
|
779 |
This leads to some wrong explanations, for example if some string is |
|
780 |
used as selector within a string, or if a variable is named like a |
|
781 |
message selector. I.e. the explanation should be context sensitive. |
|
782 |
Also, there could be much more detailed explanations." |
|
783 |
||
3319 | 784 |
|explainer variables c string explanation tmp1 |
4187 | 785 |
spc sym sel stringText cls clsName val valString color| |
2 | 786 |
|
675 | 787 |
string := someText string withoutSeparators. |
2314
0c590d9937bd
changed: #explain:in:forClass:short:
Claus Gittinger <cg@exept.de>
parents:
2292
diff
changeset
|
788 |
string isEmpty ifTrue:[ ^ nil ]. |
0c590d9937bd
changed: #explain:in:forClass:short:
Claus Gittinger <cg@exept.de>
parents:
2292
diff
changeset
|
789 |
|
2214 | 790 |
stringText := string allBold. |
2414
4da315c5bcf4
changed: #explain:in:forClass:short:
Claus Gittinger <cg@exept.de>
parents:
2316
diff
changeset
|
791 |
"/ stringText := '''' , stringText , ''''. |
49 | 792 |
|
793 |
" |
|
794 |
ask parser for variable names |
|
795 |
" |
|
3070 | 796 |
ParseError catch:[ |
3319 | 797 |
explainer := self parseMethod:source in:aClass ignoreErrors:true ignoreWarnings:true. |
1357 | 798 |
]. |
3320 | 799 |
"/ bad leftover from a stupid return value from ancient times |
3319 | 800 |
explainer == #Error ifTrue:[ explainer := nil ]. |
801 |
||
802 |
(explainer notNil) ifTrue:[ |
|
3233 | 803 |
"look for variables" |
2 | 804 |
|
3319 | 805 |
variables := explainer methodVars. |
3233 | 806 |
(variables notNil and:[variables includes:string]) ifTrue:[ |
807 |
^ stringText , ' a method variable.' |
|
808 |
]. |
|
3319 | 809 |
variables := explainer methodArgs. |
3233 | 810 |
(variables notNil and:[variables includes:string]) ifTrue:[ |
811 |
^ stringText , ' a method argument.' |
|
812 |
] |
|
2 | 813 |
]. |
49 | 814 |
|
3319 | 815 |
explainer isNil ifTrue:[ |
816 |
explainer := self for:(ReadStream on:source) in:aClass |
|
2 | 817 |
]. |
818 |
||
2988 | 819 |
"instvars/class instVars" |
84 | 820 |
c := aClass whichClassDefinesInstVar:string. |
821 |
c notNil ifTrue:[ |
|
3233 | 822 |
c isMeta ifTrue:[ |
823 |
clsName := c theNonMetaclass name. |
|
824 |
shortText ifTrue:[ |
|
3866 | 825 |
clsName := self asClassLink:clsName. |
3233 | 826 |
stringText := stringText , ': a class instVar in ' , clsName |
827 |
] ifFalse:[ |
|
828 |
stringText := stringText, ': a class instance variable inherited from ' , clsName |
|
829 |
]. |
|
830 |
val := aClass theNonMetaclass instVarNamed:string. |
|
831 |
valString := self valueStringFor:val. |
|
832 |
^ stringText , ' (' , valString , ').' |
|
833 |
]. |
|
3798 | 834 |
^ self explainInstanceVariable:string inClass:c short:shortText. |
2 | 835 |
]. |
836 |
||
2986 | 837 |
string isWideString ifFalse:[ |
3233 | 838 |
"classvars" |
3319 | 839 |
c := explainer inWhichClassIsClassVar:string. |
3233 | 840 |
c notNil ifTrue:[ |
4187 | 841 |
val := c theNonMetaclass classVarAt:string. "/ Smalltalk at:(clsName , ':' , string) asSymbol. |
842 |
valString := self valueStringFor:val. |
|
843 |
||
844 |
val == true ifTrue:[ |
|
845 |
color := Color green darkened. |
|
846 |
] ifFalse:[ |
|
847 |
val == false ifTrue:[ |
|
848 |
color := Color red darkened |
|
849 |
] ifFalse:[ |
|
850 |
val == nil ifTrue:[ |
|
851 |
color := Color darkGrey |
|
852 |
]. |
|
853 |
]. |
|
854 |
]. |
|
855 |
color notNil ifTrue:[ |
|
856 |
stringText := stringText withColor:color. |
|
857 |
valString := valString withColor:color. |
|
858 |
]. |
|
859 |
||
3233 | 860 |
clsName := c name. |
861 |
shortText ifTrue:[ |
|
3866 | 862 |
clsName := self asClassLink:clsName. |
3233 | 863 |
stringText := stringText , ': a classVar in ' , clsName |
864 |
] ifFalse:[ |
|
865 |
stringText := stringText , ': a class variable in ' , clsName |
|
866 |
]. |
|
2315
45f09cea2063
changed: #explain:in:forClass:short:
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
867 |
|
3233 | 868 |
^ stringText , ' (' , valString , ').' |
869 |
]. |
|
1693 | 870 |
|
3233 | 871 |
"private classes" |
872 |
c := aClass theNonMetaclass. |
|
873 |
c privateClasses do:[:pClass | |
|
874 |
(pClass name = string |
|
875 |
or:[pClass nameWithoutPrefix = string]) ifTrue:[ |
|
3866 | 876 |
stringText := self asClassLink:pClass name. |
3233 | 877 |
stringText := stringText , ': a private class in ''' , c name , '''.'. |
878 |
shortText ifFalse:[ |
|
879 |
stringText := (stringText , '\\It is only visible locally.') withCRs |
|
880 |
]. |
|
881 |
^ stringText withCRs |
|
882 |
]. |
|
883 |
]. |
|
422 | 884 |
|
3233 | 885 |
aClass theNonMetaclass sharedPoolNames do:[:eachPoolName | |
3810 | 886 |
|sharedPool sharedPoolSym poolName| |
2037
003d9b5a2788
explain shared pool variables
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
887 |
|
3407 | 888 |
sharedPoolSym := string asSymbolIfInterned. |
889 |
sharedPoolSym notNil ifTrue:[ |
|
890 |
sharedPool := Smalltalk classNamed:eachPoolName. |
|
891 |
sharedPool notNil ifTrue:[ |
|
892 |
sharedPool isSharedPool ifFalse:[ |
|
893 |
^ 'oops - not a shared pool: ',eachPoolName |
|
894 |
]. |
|
895 |
(sharedPool includesKey:sharedPoolSym) ifTrue:[ |
|
3810 | 896 |
poolName := sharedPool name. |
3866 | 897 |
poolName := self asClassLink:eachPoolName. |
3810 | 898 |
stringText := stringText , ': a pool variable in ',poolName. |
3407 | 899 |
val := sharedPool at:sharedPoolSym. |
900 |
valString := self valueStringFor:val. |
|
901 |
^ stringText , ' (' , valString , ').' |
|
902 |
]. |
|
3233 | 903 |
]. |
904 |
]. |
|
905 |
]. |
|
2037
003d9b5a2788
explain shared pool variables
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
906 |
|
3233 | 907 |
"namespace & global variables" |
908 |
(spc := aClass nameSpace) notNil ifTrue:[ |
|
909 |
sym := (spc name , '::' , string) asSymbolIfInterned. |
|
910 |
sym notNil ifTrue:[ |
|
911 |
(cls := Smalltalk at:sym) isBehavior ifTrue:[ |
|
3866 | 912 |
stringText := self asClassLink:sym. |
3233 | 913 |
string := stringText , ': '. |
914 |
cls name = sym ifFalse:[ |
|
915 |
string := string , 'refers to ',cls name,', ' |
|
916 |
]. |
|
917 |
cls isSharedPool ifTrue:[ |
|
918 |
string := string , 'a sharedPool'. |
|
919 |
] ifFalse:[ |
|
920 |
string := string , 'a class'. |
|
921 |
]. |
|
3049 | 922 |
|
3233 | 923 |
string := string , ' in the ''' , spc name , ''' nameSpace'. |
924 |
string := string , ' {', cls category ,'}'. |
|
925 |
shortText ifFalse:[ |
|
926 |
string := (string |
|
927 |
, '\\It is only visible within this nameSpace.' |
|
928 |
, '\Access from the outside is possible' |
|
929 |
, '\by the special name ''' , spc name , '::' , string , '''.') withCRs |
|
930 |
]. |
|
931 |
^ string withCRs |
|
932 |
]. |
|
933 |
]. |
|
934 |
]. |
|
422 | 935 |
|
3866 | 936 |
"/ string knownAsSymbol ifTrue:[ |
3233 | 937 |
"globals & symbols" |
839 | 938 |
|
3319 | 939 |
explanation := self explainKnownSymbol:string inClass:aClass short:shortText. |
940 |
explanation notNil ifTrue:[ |
|
3233 | 941 |
string isBinarySelector ifTrue:[ |
942 |
"/ some are both known as syntax AND as selector (for example: #| ) |
|
943 |
tmp1 := self explainSyntax:string short:shortText. |
|
944 |
tmp1 notNil ifTrue:[ |
|
3319 | 945 |
^ tmp1 , '\\also:\\' withCRs , explanation |
3233 | 946 |
]. |
947 |
]. |
|
3319 | 948 |
^ explanation |
3233 | 949 |
]. |
950 |
||
951 |
"/ try with added colon ... |
|
952 |
sel := string , ':'. |
|
953 |
Symbol allInstancesDo:[:sym | |
|
954 |
(sym startsWith:sel) ifTrue:[ |
|
3319 | 955 |
explanation := self explainKnownSymbol:sym inClass:aClass short:shortText. |
956 |
explanation notNil ifTrue:[ ^ explanation]. |
|
3233 | 957 |
] |
958 |
]. |
|
3866 | 959 |
"/ ]. |
2 | 960 |
|
3233 | 961 |
"try for some obvious things" |
3319 | 962 |
explanation := self explainPseudoVariable:string in:aClass short:true. |
963 |
explanation notNil ifTrue:[ ^ explanation]. |
|
2315
45f09cea2063
changed: #explain:in:forClass:short:
Claus Gittinger <cg@exept.de>
parents:
2314
diff
changeset
|
964 |
]. |
2 | 965 |
|
966 |
"try syntax ..." |
|
967 |
||
3319 | 968 |
explanation := self explainSyntax:string short:shortText. |
969 |
explanation notNil ifTrue:[ ^ explanation]. |
|
20 | 970 |
|
1183 | 971 |
shortText ifTrue:[ |
3883 | 972 |
|selector| |
973 |
||
974 |
(selector := SystemBrowser extractSelectorFrom:string) notNil ifTrue:[ |
|
975 |
selector ~= string string ifTrue:[ |
|
976 |
^ self explain:selector in:source forClass:aClass short:shortText |
|
977 |
]. |
|
4177 | 978 |
]. |
979 |
someText size == 1 ifTrue:[ |
|
980 |
^ 'no explanation; character encoding: %1 (0x%2)' |
|
981 |
bindWith:someText first codePoint |
|
982 |
with:(someText first codePoint hexPrintString:4) |
|
3883 | 983 |
]. |
3233 | 984 |
^ 'no explanation' |
1183 | 985 |
]. |
986 |
||
3319 | 987 |
explainer isNil ifTrue:[ |
3233 | 988 |
^ 'parse error - no explanation' |
2 | 989 |
]. |
3319 | 990 |
^ 'Sorry, I cannot explain this (could not figure out what this is). |
991 |
Please try again with an individual token selected.' |
|
146
3d407ab8ac44
suppress messages on transcript when explaining
Claus Gittinger <cg@exept.de>
parents:
141
diff
changeset
|
992 |
|
1926
935dbaeca76f
show class package in explanation
Claus Gittinger <cg@exept.de>
parents:
1910
diff
changeset
|
993 |
"Created: / 03-12-1995 / 12:47:37 / cg" |
935dbaeca76f
show class package in explanation
Claus Gittinger <cg@exept.de>
parents:
1910
diff
changeset
|
994 |
"Modified: / 16-04-1997 / 12:46:11 / stefan" |
4187 | 995 |
"Modified: / 23-08-2017 / 12:44:12 / cg" |
2 | 996 |
! |
997 |
||
1188 | 998 |
explainGlobal:string inClass:aClass short:shortText |
2828
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
999 |
"return an explanation or nil" |
1183 | 1000 |
|
2427 | 1001 |
^ self explainGlobalOrPoolVariable:string inClass:aClass short:shortText |
1002 |
||
1003 |
"Modified: / 14-10-2010 / 11:33:17 / cg" |
|
2828
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1004 |
"Modified (comment): / 28-02-2012 / 10:45:58 / cg" |
2427 | 1005 |
! |
1006 |
||
3878 | 1007 |
explainGlobalOrPoolVariable:varName inClass:aClass short:shortText |
2828
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1008 |
"return an explanation or nil" |
2427 | 1009 |
|
3879 | 1010 |
|template bindings |
3972 | 1011 |
sym explanation val pool valText doc| |
141 | 1012 |
|
3878 | 1013 |
"if not even known as key, it's definitely not a global" |
1014 |
sym := varName asSymbolIfInterned. |
|
796 | 1015 |
sym isNil ifTrue:[^ nil]. |
3879 | 1016 |
|
1017 |
template := nil. |
|
1018 |
bindings := Dictionary new. |
|
1019 |
||
2427 | 1020 |
"a pool variable?" |
1021 |
aClass notNil ifTrue:[ |
|
3319 | 1022 |
aClass theNonMetaclass sharedPoolNames do:[:eachPoolName | |
1023 |
pool := Smalltalk at:eachPoolName. |
|
1024 |
pool isNil ifTrue:[ |
|
3878 | 1025 |
"/ oops - on the fly we encountered a non existing pool... |
3319 | 1026 |
] ifFalse:[ |
3878 | 1027 |
(pool classVarNames includes:varName) ifTrue:[ |
3879 | 1028 |
template := '%(varName): pool variable in "%(poolName)"'. |
1029 |
bindings at:'poolName' put:eachPoolName. |
|
3319 | 1030 |
val := pool classVarAt:sym. |
1031 |
]. |
|
1032 |
]. |
|
1033 |
]. |
|
2427 | 1034 |
]. |
1035 |
||
3879 | 1036 |
bindings at:'varName' put:varName allBold. |
3810 | 1037 |
|
3879 | 1038 |
template isNil ifTrue:[ |
3319 | 1039 |
"try globals" |
3879 | 1040 |
(Smalltalk includesKey:sym) ifFalse:[ |
1041 |
^ '%(varName): an undefined variable.' bindWithArguments:bindings. |
|
1042 |
]. |
|
1043 |
template := '%(varName): global'. |
|
1044 |
val := Smalltalk at:sym. |
|
2427 | 1045 |
]. |
141 | 1046 |
|
1245 | 1047 |
val isBehavior ifTrue:[ |
3319 | 1048 |
"/ a class |
1049 |
val name = sym ifFalse:[ |
|
3879 | 1050 |
"/ an alias (such as OperatingSystem, Screen etc.) |
4040 | 1051 |
template := template,'. Refers to %(realName)'. |
3879 | 1052 |
bindings at:'realName' put:val name. |
3319 | 1053 |
]. |
1979 | 1054 |
|
3319 | 1055 |
(val isRealNameSpace) ifTrue:[ |
3879 | 1056 |
template := template,', a namespace.'. |
1057 |
^ template bindWithArguments:bindings. |
|
3319 | 1058 |
]. |
3879 | 1059 |
|
1060 |
"/ a real class |
|
1061 |
bindings at:'category' put:(val category ? 'uncategorized'). |
|
3319 | 1062 |
shortText ifTrue:[ |
3883 | 1063 |
template := template , ',' , (val isLoaded ifTrue:[' a'] ifFalse:[' an autoloaded']). |
3879 | 1064 |
template := template , (val isSharedPool ifTrue:[' pool'] ifFalse:[' class']). |
1065 |
template := template , ' in %(package) {%(category)}.'. |
|
1066 |
bindings at:'package' put:val package. |
|
4040 | 1067 |
bindings at:'varName' put:(self asClassLink:varName "val name"). |
3879 | 1068 |
^ template bindWithArguments:bindings |
3319 | 1069 |
]. |
1330 | 1070 |
|
3878 | 1071 |
val name = varName ifTrue:[ |
3322 | 1072 |
false ifTrue:[ |
1073 |
"/ TODO: generate a short documentation string (comment plus interface) |
|
1074 |
"/ and return { #html->htmlText . #text->regularText} |
|
3972 | 1075 |
"/ so caller can extract what he wants to see... |
3322 | 1076 |
^ (HTMLDocGenerator htmlDocOf:val). |
1077 |
]. |
|
3972 | 1078 |
explanation := varName , ' is '. |
3319 | 1079 |
explanation := explanation , (val isLoaded ifTrue:['a'] ifFalse:['an autoloaded']). |
1080 |
explanation := explanation , (val isSharedPool ifTrue:[' sharedPool'] ifFalse:[' class']). |
|
3972 | 1081 |
explanation := explanation , ' categorized as "' , val category , '"'. |
3319 | 1082 |
explanation := explanation , '\' withCRs , 'in the "' , val package , '" package.'. |
1083 |
(doc := val commentOrDocumentationString) notEmptyOrNil ifTrue:[ |
|
1084 |
doc := doc asStringCollection. |
|
1085 |
doc size > 25 ifTrue:[ |
|
1086 |
doc := doc copyTo:25. |
|
1087 |
doc add:''; add:' ... <more documentation cut off>'. |
|
1088 |
]. |
|
3864 | 1089 |
doc := doc asString withColor:(UserPreferences current commentColor). |
3319 | 1090 |
explanation := explanation,'\\' withCRs,val name,'''s documentation:\'withCRs, doc |
1091 |
]. |
|
1092 |
^ explanation. |
|
1093 |
]. |
|
1245 | 1094 |
|
3319 | 1095 |
explanation := explanation , ' |
1183 | 1096 |
|
3878 | 1097 |
' , varName , ' is bound to the class ' , val name , |
3972 | 1098 |
' in the "' , val category , '" category.'. |
3319 | 1099 |
^ explanation. |
141 | 1100 |
]. |
1101 |
||
2427 | 1102 |
valText := self valueStringFor:val. |
1103 |
||
1245 | 1104 |
shortText ifTrue:[ |
3881 | 1105 |
^ '%1: a global (%2)' |
1106 |
bindWith:varName |
|
1107 |
with:(self asLink:valText to:(self actionToBrowseClass:val class selector:nil)) |
|
1245 | 1108 |
]. |
3881 | 1109 |
|
3319 | 1110 |
explanation := explanation , ' |
1245 | 1111 |
|
2466
75b29e4a34c0
changed: #explainGlobalOrPoolVariable:inClass:short:
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
1112 |
Its current value is "%1".' bindWith:valText. |
3319 | 1113 |
^ explanation. |
1926
935dbaeca76f
show class package in explanation
Claus Gittinger <cg@exept.de>
parents:
1910
diff
changeset
|
1114 |
|
2427 | 1115 |
"Created: / 14-10-2010 / 11:33:04 / cg" |
4040 | 1116 |
"Modified: / 16-11-2016 / 13:08:07 / cg" |
1188 | 1117 |
! |
1118 |
||
2828
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1119 |
explainHereIn:aClass short:shortText |
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1120 |
"return an explanation" |
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1121 |
|
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1122 |
|className| |
1188 | 1123 |
|
2828
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1124 |
className := aClass name. |
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1125 |
|
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1126 |
shortText ifTrue:[ |
3810 | 1127 |
^ '"here" - message lookup always starts in "%1" (always call local method).' bindWith:className |
2828
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1128 |
]. |
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1129 |
|
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1130 |
^ 'like "self", "','here'allBold,'" refers to the object which received the message. |
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1131 |
|
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1132 |
However, when sending a message to "here", the search for methods |
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1133 |
implementing this message will start in the defining class (' , className , '), |
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1134 |
instead of the receiver''s class (' , className , ' or subclass). |
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1135 |
Thus, using "here", redefined methods will NOT be reached with a here-send and it is ensured, |
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1136 |
that the local method is called.' |
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1137 |
|
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1138 |
"Created: / 28-02-2012 / 10:44:55 / cg" |
1188 | 1139 |
! |
1140 |
||
3798 | 1141 |
explainInstanceVariable:instVarName inClass:aClass short:shortText |
3853 | 1142 |
|varNameInText classNameInText template stringText setOfTypes typesDescription| |
3798 | 1143 |
|
3853 | 1144 |
varNameInText := instVarName allBold. |
1145 |
classNameInText := aClass name. |
|
1146 |
||
3798 | 1147 |
shortText ifTrue:[ |
3883 | 1148 |
template := '%1: instVar in %2'. |
3878 | 1149 |
varNameInText := self |
1150 |
asLink:varNameInText |
|
1151 |
info:('Click to browse references to %1' bindWith:instVarName) |
|
1152 |
to:(self actionToBrowseInstvarRefsTo:instVarName inClass:aClass). |
|
3866 | 1153 |
classNameInText := self asClassLink:classNameInText. |
3798 | 1154 |
] ifFalse:[ |
1155 |
template := '%1: an instance variable in %2' |
|
1156 |
]. |
|
3853 | 1157 |
stringText := template bindWith:varNameInText with:classNameInText. |
3798 | 1158 |
|
1159 |
"/ look for instances |
|
1160 |
setOfTypes := IdentitySet new. |
|
1161 |
self addTypesOfInstvar:instVarName inClass:aClass fromExistingInstancesTo:setOfTypes. |
|
1162 |
"/ look for assignments |
|
3878 | 1163 |
aClass withAllSubclassesDo:[:cls | |
1164 |
self addTypesAssignedToInstvar:instVarName inClass:cls to:setOfTypes |
|
1165 |
]. |
|
1166 |
||
1167 |
"/ generate a list of up-to 3 links |
|
3810 | 1168 |
typesDescription := self typeDescriptionFor:setOfTypes andSelector:nil. |
1169 |
typesDescription notNil ifTrue:[ |
|
1170 |
stringText := stringText,' (',typesDescription,')' |
|
1171 |
]. |
|
3798 | 1172 |
^ stringText |
1173 |
! |
|
1174 |
||
1188 | 1175 |
explainKnownSymbol:string inClass:aClass |
2828
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1176 |
"return an explanation or nil" |
1188 | 1177 |
|
1178 |
^ self explainKnownSymbol:string inClass:aClass short:false |
|
2828
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1179 |
|
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1180 |
"Modified (comment): / 28-02-2012 / 10:45:40 / cg" |
1188 | 1181 |
! |
1182 |
||
1183 |
explainKnownSymbol:string inClass:aClass short:shortText |
|
2828
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1184 |
"return an explanation or nil" |
1188 | 1185 |
|
2471 | 1186 |
|sym expl| |
1188 | 1187 |
|
1188 |
sym := string asSymbolIfInterned. |
|
1189 |
sym isNil ifTrue:[^ nil]. |
|
1190 |
||
2427 | 1191 |
"try globals and pools" |
1188 | 1192 |
(Smalltalk includesKey:sym) ifTrue:[ |
3810 | 1193 |
expl := self explainGlobalOrPoolVariable:string inClass:aClass short:shortText. |
1194 |
expl notNil ifTrue:[^ expl]. |
|
1188 | 1195 |
]. |
1196 |
||
2471 | 1197 |
expl := self explainSelector:string inClass:aClass short:shortText. |
1198 |
expl notNil ifTrue:[^ expl]. |
|
1199 |
^ self explainGlobalOrPoolVariable:string inClass:aClass short:shortText. |
|
2427 | 1200 |
|
2471 | 1201 |
"Modified: / 18-01-2011 / 19:13:07 / cg" |
2828
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1202 |
"Modified (comment): / 28-02-2012 / 10:46:06 / cg" |
1188 | 1203 |
! |
1204 |
||
1205 |
explainPseudoVariable:string in:aClass |
|
2828
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1206 |
"return an explanation for the pseudoVariables self, super etc." |
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1207 |
|
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1208 |
<resource: #obsolete> |
1188 | 1209 |
|
1210 |
^ self explainPseudoVariable:string in:aClass short:false |
|
2828
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1211 |
|
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1212 |
"Modified (format): / 28-02-2012 / 10:47:17 / cg" |
1188 | 1213 |
! |
1214 |
||
1215 |
explainPseudoVariable:string in:aClass short:shortText |
|
2828
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1216 |
"return an explanation for the pseudoVariables self, super etc." |
1188 | 1217 |
|
1218 |
(string = 'self') ifTrue:[ |
|
3810 | 1219 |
^ self explainSelfIn:aClass short:shortText |
1188 | 1220 |
]. |
1221 |
||
1222 |
(string = 'super') ifTrue:[ |
|
3810 | 1223 |
^ self explainSuperIn:aClass short:shortText |
1188 | 1224 |
]. |
1225 |
||
1226 |
(string = 'here') ifTrue:[ |
|
3810 | 1227 |
^ self explainHereIn:aClass short:shortText |
1188 | 1228 |
]. |
1229 |
||
1230 |
(string = 'thisContext') ifTrue:[ |
|
3810 | 1231 |
shortText ifTrue:[ |
1232 |
^ '''thisContext'' - the current stack frame as an object.' |
|
1233 |
]. |
|
1234 |
^ 'thisContext is a pseudo variable (i.e. it is built in). |
|
1188 | 1235 |
|
1236 |
ThisContext always refers to the context object for the currently executed method or |
|
1237 |
block (an instance of Context or BlockContext respectively). The calling chain and calling |
|
1238 |
receivers/selectors can be accessed via thisContext.' |
|
1239 |
]. |
|
1240 |
||
1241 |
(string = 'true') ifTrue:[ |
|
3810 | 1242 |
shortText ifTrue:[ |
1243 |
^ '''true'' - the truth and nothing but the truth.' |
|
1244 |
]. |
|
1245 |
^ 'true is a pseudo variable (i.e. it is built in). |
|
1188 | 1246 |
|
1247 |
True represents logical truth. It is the one and only instance of class True.' |
|
1248 |
]. |
|
1249 |
||
1250 |
(string = 'false') ifTrue:[ |
|
3810 | 1251 |
shortText ifTrue:[ |
1252 |
^ '''false'' - obvisously not true.' |
|
1253 |
]. |
|
1254 |
^ 'false is a pseudo variable (i.e. it is built in). |
|
1188 | 1255 |
|
1256 |
False represents logical falseness. It is the one and only instance of class False.' |
|
1257 |
]. |
|
1258 |
||
1259 |
(string = 'nil') ifTrue:[ |
|
3810 | 1260 |
shortText ifTrue:[ |
1261 |
^ '''nil'' - undefined, unknown, void or dont care.' |
|
1262 |
]. |
|
1263 |
^ 'nil is a pseudo variable (i.e. it is built in). |
|
1188 | 1264 |
|
1265 |
Nil is used for unitialized variables (among other uses). |
|
1266 |
Nil is the one and only instance of class UndefinedObject.' |
|
1267 |
]. |
|
1268 |
^ nil |
|
2828
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1269 |
|
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1270 |
"Modified (comment): / 28-02-2012 / 10:46:18 / cg" |
1188 | 1271 |
! |
1272 |
||
1273 |
explainSelector:string inClass:aClass short:shortText |
|
2828
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1274 |
"return an explanation or nil" |
1188 | 1275 |
|
3810 | 1276 |
|selector listOfImplementingClasses listOfImplementingClassNames listOfSimilarSelectors |
3203 | 1277 |
firstImplementingClassOfSimilar count tmp commonSuperClass s s2 |
4143 | 1278 |
firstImplementingClass |
3798 | 1279 |
firstImplementingClassName secondImplementingClassName thirdImplementingClassName |
1280 |
classProvidingComment |
|
1281 |
cm msg t check| |
|
1188 | 1282 |
|
3810 | 1283 |
selector := string asSymbolIfInterned. |
1284 |
selector isNil ifTrue:[^ nil]. |
|
1188 | 1285 |
|
4143 | 1286 |
"/ look who implements it |
3798 | 1287 |
listOfImplementingClassNames := Set new. |
3174 | 1288 |
listOfImplementingClasses := Set new. |
1289 |
listOfSimilarSelectors := Set new. |
|
2288
92c7e16d6916
changed: #explainSelector:inClass:short:
Claus Gittinger <cg@exept.de>
parents:
2287
diff
changeset
|
1290 |
|
3203 | 1291 |
check := |
3233 | 1292 |
[:sel :mthd :cls | |
3810 | 1293 |
sel == selector ifTrue:[ |
3798 | 1294 |
listOfImplementingClasses add:cls. |
1295 |
listOfImplementingClassNames add:(cls name). |
|
3233 | 1296 |
firstImplementingClass isNil ifTrue:[ |
3798 | 1297 |
firstImplementingClass := cls. |
1298 |
firstImplementingClassName := cls name. |
|
3233 | 1299 |
] |
1300 |
] ifFalse:[ |
|
3810 | 1301 |
(sel startsWith:selector) ifTrue:[ |
3233 | 1302 |
listOfSimilarSelectors add:sel. |
1303 |
firstImplementingClassOfSimilar isNil ifTrue:[ |
|
1304 |
firstImplementingClassOfSimilar := cls |
|
1305 |
] |
|
1306 |
] |
|
1307 |
] |
|
1308 |
]. |
|
2288
92c7e16d6916
changed: #explainSelector:inClass:short:
Claus Gittinger <cg@exept.de>
parents:
2287
diff
changeset
|
1309 |
|
92c7e16d6916
changed: #explainSelector:inClass:short:
Claus Gittinger <cg@exept.de>
parents:
2287
diff
changeset
|
1310 |
Smalltalk allClassesDo:[:c| |
3233 | 1311 |
c methodDictionary keysAndValuesDo:[:sel :mthd | |
1312 |
check value:sel value:mthd value:c |
|
1313 |
]. |
|
1314 |
c class methodDictionary keysAndValuesDo:[:sel :mthd | |
|
1315 |
check value:sel value:mthd value:c class |
|
1316 |
]. |
|
141 | 1317 |
]. |
1318 |
||
3810 | 1319 |
(aClass canUnderstand:selector) ifTrue:[ |
1320 |
s2 := ('Instances of ''' , aClass name , ''' respond to #') , selector "allBold" , '.'. |
|
3233 | 1321 |
shortText ifFalse:[ |
1322 |
s2 := '\\' , s2 |
|
1323 |
, '\- inherited from ' withCRs |
|
3810 | 1324 |
, (aClass whichClassIncludesSelector:selector) name "allBold". |
3233 | 1325 |
]. |
3810 | 1326 |
firstImplementingClass := (aClass whichClassIncludesSelector:selector) |
835 | 1327 |
] ifFalse:[ |
3233 | 1328 |
s2 := ''. |
835 | 1329 |
]. |
1330 |
||
3798 | 1331 |
count := listOfImplementingClassNames size. |
141 | 1332 |
(count ~~ 0) ifTrue:[ |
3233 | 1333 |
" |
1334 |
for up-to 4 implementing classes, |
|
1335 |
list them |
|
1336 |
" |
|
3798 | 1337 |
listOfImplementingClassNames := listOfImplementingClassNames asOrderedCollection sort. |
3233 | 1338 |
shortText ifTrue:[ |
1339 |
tmp := ' is implemented in '. |
|
1340 |
] ifFalse:[ |
|
1341 |
tmp := ' is a selector implemented in '. |
|
1342 |
]. |
|
3881 | 1343 |
"/ s := string allBold. |
3855 | 1344 |
count > 1 ifTrue:[ |
3881 | 1345 |
s := self asLink:selector to:(self actionToOpenMethodFinderFor:selector). |
4143 | 1346 |
] ifFalse:[ |
3885 | 1347 |
s := self asLink:selector to:(self actionToBrowseClass:listOfImplementingClasses first selector:selector). |
3842 | 1348 |
]. |
4143 | 1349 |
|
3810 | 1350 |
shortText ifTrue:[ |
1351 |
|typesDescription| |
|
4143 | 1352 |
|
3810 | 1353 |
msg := s , tmp. |
3842 | 1354 |
typesDescription := self typeDescriptionFor:listOfImplementingClasses andSelector:selector wordBetween:'and'. |
3810 | 1355 |
typesDescription notNil ifTrue:[ |
3842 | 1356 |
msg := msg,typesDescription |
3233 | 1357 |
]. |
1358 |
] ifFalse:[ |
|
3810 | 1359 |
(count == 1) ifTrue:[ |
1360 |
t := firstImplementingClassName. |
|
1361 |
firstImplementingClass isMeta ifTrue:[ |
|
1362 |
t := 'the ' , t |
|
1363 |
]. |
|
1364 |
msg := s , tmp , t , '.'. |
|
3233 | 1365 |
shortText ifFalse:[ |
1366 |
msg := msg , s2. |
|
3810 | 1367 |
] |
3233 | 1368 |
] ifFalse:[ |
3810 | 1369 |
firstImplementingClassName := listOfImplementingClassNames at:1. |
1370 |
secondImplementingClassName := listOfImplementingClassNames at:2. |
|
1371 |
(count == 2) ifTrue:[ |
|
1372 |
msg := s,tmp,firstImplementingClassName,' and ',secondImplementingClassName,'.'. |
|
3233 | 1373 |
shortText ifFalse:[ |
1374 |
msg := msg , s2. |
|
1375 |
]. |
|
1376 |
] ifFalse:[ |
|
3810 | 1377 |
thirdImplementingClassName := listOfImplementingClassNames at:3. |
1378 |
(count == 3) ifTrue:[ |
|
1379 |
msg := s,tmp,firstImplementingClassName,',',secondImplementingClassName,' and ',thirdImplementingClassName,'.'. |
|
1380 |
shortText ifFalse:[ |
|
1381 |
msg := msg , s2. |
|
1382 |
]. |
|
1383 |
] ifFalse:[ |
|
1384 |
false "shortText" ifTrue:[ |
|
1385 |
msg := s , tmp , count printString , ' classes'. |
|
1386 |
commonSuperClass := Class commonSuperclassOf:listOfImplementingClassNames. |
|
1387 |
commonSuperClass notNil ifTrue:[ |
|
1388 |
(commonSuperClass == Object |
|
1389 |
and:[commonSuperClass includesSelector:selector]) ifTrue:[ |
|
1390 |
msg := msg , ' (including ' , 'Object' "allBold", ')' |
|
1391 |
] ifFalse:[ |
|
1392 |
(commonSuperClass ~= Object) ifTrue:[ |
|
1393 |
msg := msg , ' (under ' , commonSuperClass name, ')' |
|
1394 |
] |
|
1395 |
]. |
|
3492 | 1396 |
]. |
3810 | 1397 |
msg := msg , '.'. |
1398 |
^ msg |
|
3233 | 1399 |
]. |
1183 | 1400 |
|
3810 | 1401 |
" |
1402 |
if there are more, look for a common |
|
1403 |
superclass and show it ... |
|
1404 |
" |
|
1405 |
commonSuperClass := (Behavior commonSuperclassOf:listOfImplementingClasses) ? Object. |
|
1406 |
(commonSuperClass ~~ Object |
|
1407 |
and:[commonSuperClass ~~ Behavior |
|
1408 |
and:[commonSuperClass ~~ Class |
|
1409 |
and:[commonSuperClass ~~ ClassDescription]]]) ifTrue:[ |
|
1410 |
(listOfImplementingClasses includes:commonSuperClass) ifTrue:[ |
|
1411 |
msg := s . tmp , count printString , commonSuperClass name |
|
1412 |
, ' and redefined in ' , (count - 1) printString |
|
1413 |
, ' subclasses' |
|
1414 |
, s2. |
|
1415 |
firstImplementingClass := commonSuperClass |
|
1416 |
] ifFalse:[ |
|
1417 |
msg := s , tmp, count printString , ' subclasses of ' , commonSuperClass name , s2 |
|
1418 |
] |
|
3233 | 1419 |
] ifFalse:[ |
3810 | 1420 |
(commonSuperClass == Object |
1421 |
and:[commonSuperClass includesSelector:selector]) ifTrue:[ |
|
1422 |
shortText ifTrue:[ |
|
1423 |
msg := s , tmp , count printString , ' classes (incl. Object)'. |
|
1424 |
] ifFalse:[ |
|
1425 |
msg := s , tmp , count printString , ' classes. |
|
4143 | 1426 |
|
3203 | 1427 |
All objects seem to respond to that message, |
911
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
1428 |
since there is an implementation in Object.' , s2. |
3810 | 1429 |
]. |
1430 |
firstImplementingClass := Object |
|
1431 |
] ifFalse:[ |
|
1432 |
((commonSuperClass == Behavior |
|
1433 |
or:[commonSuperClass == Class |
|
1434 |
or:[commonSuperClass == ClassDescription]]) |
|
1435 |
and:[commonSuperClass includesSelector:selector]) ifTrue:[ |
|
1436 |
shortText ifTrue:[ |
|
1437 |
msg := s , tmp , count printString , ' classes (incl. all classes)'. |
|
1438 |
] ifFalse:[ |
|
1439 |
msg := s , tmp , count printString , ' classes. |
|
913 | 1440 |
|
3203 | 1441 |
All classes seem to respond to that message, |
913 | 1442 |
since there is an implementation in ' , commonSuperClass name , '.' , s2. |
3810 | 1443 |
]. |
1444 |
firstImplementingClass := commonSuperClass |
|
1445 |
] ifFalse:[ |
|
1446 |
" |
|
1447 |
otherwise just give the number. |
|
1448 |
" |
|
1449 |
msg := s , tmp , count printString , ' classes.' , s2 |
|
1450 |
] |
|
3233 | 1451 |
] |
1452 |
] |
|
1453 |
] |
|
3810 | 1454 |
]. |
3233 | 1455 |
]. |
1456 |
]. |
|
3798 | 1457 |
"/ look for a comment... |
1458 |
count == 1 ifTrue:[ |
|
1459 |
classProvidingComment := firstImplementingClass. |
|
3233 | 1460 |
] ifFalse:[ |
3798 | 1461 |
commonSuperClass isNil ifTrue:[ |
1462 |
commonSuperClass := Behavior commonSuperclassOf:listOfImplementingClasses. |
|
1463 |
] . |
|
4100 | 1464 |
|
4143 | 1465 |
((listOfImplementingClasses includes:commonSuperClass) |
4100 | 1466 |
and:[ (commonSuperClass implements:selector) ] |
1467 |
) ifTrue:[ |
|
1468 |
classProvidingComment := commonSuperClass |
|
1469 |
] ifFalse:[ |
|
4143 | 1470 |
"/ avoid some obvious misleading paths... |
1471 |
classProvidingComment := { Number . Collection . Stream . View } |
|
4100 | 1472 |
detect:[:cls | (listOfImplementingClasses includes:cls) |
1473 |
or:[cls canUnderstand:selector] ] |
|
1474 |
ifNone:nil. |
|
1475 |
classProvidingComment notNil ifTrue:[ |
|
1476 |
classProvidingComment := classProvidingComment whichClassImplements:selector. |
|
4143 | 1477 |
] ifFalse:[ |
3810 | 1478 |
classProvidingComment := firstImplementingClass. |
4143 | 1479 |
[ |
4100 | 1480 |
classProvidingComment superclass notNil |
1481 |
and:[ classProvidingComment superclass implements:selector ] |
|
1482 |
] whileTrue:[ |
|
1483 |
classProvidingComment := classProvidingComment superclass |
|
1484 |
]. |
|
3810 | 1485 |
]. |
3798 | 1486 |
]. |
1487 |
]. |
|
1488 |
classProvidingComment notNil ifTrue:[ |
|
3885 | 1489 |
cm := self fetchDescriptionOfMethod:"fetchCommentOfMethod:"(classProvidingComment compiledMethodAt:selector). |
3798 | 1490 |
]. |
1491 |
cm isNil ifTrue:[ |
|
1492 |
"/ should: find the class with most subclasses from the list |
|
1493 |
(listOfImplementingClasses includes:Collection) ifTrue:[ |
|
1494 |
classProvidingComment := Collection |
|
1495 |
] ifFalse:[ |
|
1496 |
(listOfImplementingClasses includes:Stream) ifTrue:[ |
|
1497 |
classProvidingComment := Stream |
|
1498 |
] ifFalse:[ |
|
4143 | 1499 |
classProvidingComment := listOfImplementingClasses |
1500 |
detect:[:cls | |
|
3883 | 1501 |
|mthd| |
1502 |
(mthd := cls compiledMethodAt:selector) notNil |
|
3885 | 1503 |
and:[ (self fetchCommentOfMethod:mthd) notNil]] |
3883 | 1504 |
ifNone:nil. |
3798 | 1505 |
] |
1506 |
]. |
|
3883 | 1507 |
cm isNil ifTrue:[ |
1508 |
classProvidingComment notNil ifTrue:[ |
|
3885 | 1509 |
cm := self fetchDescriptionOfMethod:(classProvidingComment compiledMethodAt:selector). |
3883 | 1510 |
] |
4143 | 1511 |
]. |
3798 | 1512 |
]. |
1513 |
cm notNil ifTrue:[ |
|
4273 | 1514 |
cm := ('%1 says:\' withCRs bindWith:(self asClassLink:classProvidingComment name)),cm. |
4143 | 1515 |
|
3883 | 1516 |
"/ msg := msg,(msg last isSeparator ifTrue:[''] ifFalse:[' ']),cm |
1517 |
msg := msg,(Character cr),cm |
|
3233 | 1518 |
]. |
1519 |
^ msg |
|
141 | 1520 |
]. |
1521 |
||
3881 | 1522 |
"/ none implements it (typo?); |
3174 | 1523 |
count := listOfSimilarSelectors size. |
2288
92c7e16d6916
changed: #explainSelector:inClass:short:
Claus Gittinger <cg@exept.de>
parents:
2287
diff
changeset
|
1524 |
(count ~~ 0) ifTrue:[ |
3233 | 1525 |
listOfSimilarSelectors := listOfSimilarSelectors asOrderedCollection sort. |
2288
92c7e16d6916
changed: #explainSelector:inClass:short:
Claus Gittinger <cg@exept.de>
parents:
2287
diff
changeset
|
1526 |
|
3233 | 1527 |
(count == 1) ifTrue:[ |
3881 | 1528 |
|sel selLink clsLink implementors| |
1529 |
||
1530 |
sel := listOfSimilarSelectors first. |
|
1531 |
selLink := self asLink:sel to:(self actionToOpenMethodFinderFor:sel). |
|
1532 |
"/ clsLink := self asLink:firstImplementingClassOfSimilar name to:(self actionToBrowseClass:firstImplementingClassOfSimilar selector:sel). |
|
1533 |
implementors := Smalltalk allImplementorsOf:sel. |
|
1534 |
clsLink := self typeDescriptionFor:implementors andSelector:sel. |
|
1535 |
msg := selLink , ' is implemented in ' , clsLink , '.'. |
|
3233 | 1536 |
shortText ifFalse:[ |
1537 |
msg := msg , s2. |
|
1538 |
] |
|
1539 |
] ifFalse:[ |
|
3881 | 1540 |
|sel1 sel2| |
1541 |
sel1 := listOfSimilarSelectors first. |
|
1542 |
sel2 := listOfSimilarSelectors second. |
|
4143 | 1543 |
msg := 'similar selectors: %1, %2' |
1544 |
bindWith:(self asLink:sel1 to:(self actionToOpenMethodFinderFor:sel1)) |
|
3881 | 1545 |
with:(self asLink:sel2 to:(self actionToOpenMethodFinderFor:sel1)). |
3233 | 1546 |
count > 2 ifTrue:[ |
1547 |
msg := msg,'...'. |
|
1548 |
]. |
|
1549 |
]. |
|
1550 |
^ msg |
|
2288
92c7e16d6916
changed: #explainSelector:inClass:short:
Claus Gittinger <cg@exept.de>
parents:
2287
diff
changeset
|
1551 |
]. |
92c7e16d6916
changed: #explainSelector:inClass:short:
Claus Gittinger <cg@exept.de>
parents:
2287
diff
changeset
|
1552 |
|
141 | 1553 |
^ nil |
290
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
1554 |
|
1909 | 1555 |
"Modified: / 17-06-1996 / 17:09:30 / stefan" |
1556 |
"Created: / 23-03-1999 / 13:29:33 / cg" |
|
3804 | 1557 |
"Modified: / 01-05-2016 / 15:42:24 / cg" |
4143 | 1558 |
"Modified: / 22-05-2017 / 11:35:31 / mawalch" |
4273 | 1559 |
"Modified: / 06-06-2018 / 11:34:14 / Claus Gittinger" |
141 | 1560 |
! |
1561 |
||
1183 | 1562 |
explainSelfIn:aClass short:shortText |
2828
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1563 |
"return an explanation" |
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1564 |
|
3883 | 1565 |
|subClasses subNames selfString className nSubClasses |
1566 |
classLink classLink2 subclassesLink| |
|
1198 | 1567 |
|
1926
935dbaeca76f
show class package in explanation
Claus Gittinger <cg@exept.de>
parents:
1910
diff
changeset
|
1568 |
selfString := '''' , 'self' "allBold" , ''''. |
6 | 1569 |
|
3883 | 1570 |
subClasses := aClass allSubclasses. |
1571 |
nSubClasses := subClasses size. |
|
1244 | 1572 |
|
1573 |
aClass isMeta ifTrue:[ |
|
3810 | 1574 |
className := aClass theNonMetaclass name. |
3883 | 1575 |
subNames := subClasses collect:[:c | c theNonMetaclass name]. |
1576 |
shortText ifTrue:[ |
|
1577 |
classLink := (self asClassLink:className). |
|
1578 |
nSubClasses == 0 ifTrue:[ |
|
1579 |
^ selfString , (' - the %1 class.' bindWith:classLink) |
|
1580 |
]. |
|
1581 |
nSubClasses == 1 ifTrue:[ |
|
1582 |
classLink2 := self asClassLink:subNames first. |
|
1583 |
^ selfString , (' - the %1- or %2 class.' bindWith:classLink with:classLink2) |
|
1584 |
]. |
|
1585 |
subclassesLink := self |
|
1586 |
asLink:('%1 subclasses' bindWith:nSubClasses) |
|
1587 |
info:('Click to browse subclasses') |
|
1588 |
to:(self actionToBrowseClasses:subClasses). |
|
1589 |
||
1590 |
^ selfString , (' - the %1 class or one of its %2.' bindWith:classLink with:subclassesLink) |
|
1591 |
]. |
|
1592 |
||
3810 | 1593 |
nSubClasses == 0 ifTrue:[ |
1594 |
^ selfString , 'refers to the object which received the message. |
|
1244 | 1595 |
|
1596 |
In this case, it will be the ' , className , '-class itself.' |
|
3810 | 1597 |
]. |
1244 | 1598 |
|
3810 | 1599 |
nSubClasses <= 5 ifTrue:[ |
1600 |
^ selfString , ' refers to the object which received the message. |
|
1244 | 1601 |
|
1602 |
In this case, it will be the ' , className , '-class |
|
1603 |
or one of its subclasses: |
|
1604 |
||
1605 |
' , subNames asStringCollection asString |
|
3810 | 1606 |
]. |
1244 | 1607 |
|
3810 | 1608 |
^ selfString , ' refers to the object which received the message. |
1244 | 1609 |
|
1610 |
In this case, it will be the ' , className , '-class |
|
1611 |
or one of its ' , nSubClasses printString , ' subclasses.' |
|
1612 |
]. |
|
1613 |
||
3883 | 1614 |
subClasses := aClass allSubclasses. |
1615 |
subNames := subClasses collect:[:c | c theNonMetaclass name]. |
|
1244 | 1616 |
className := aClass name. |
3883 | 1617 |
shortText ifTrue:[ |
1618 |
classLink := self asClassLink:className. |
|
1619 |
nSubClasses == 0 ifTrue:[ |
|
1620 |
^ selfString , (' - an instance of %1.' bindWith:classLink) |
|
1621 |
]. |
|
1622 |
nSubClasses == 1 ifTrue:[ |
|
1623 |
classLink2 := self asClassLink:subNames first. |
|
1624 |
^ selfString , (' - an instance of %1 or %2.' bindWith:classLink with:classLink2) |
|
1625 |
]. |
|
1626 |
subclassesLink := self |
|
1627 |
asLink:('%1 subclasses' bindWith:nSubClasses) |
|
1628 |
info:('Click to browse subclasses') |
|
1629 |
to:(self actionToBrowseClasses:subClasses). |
|
1630 |
^ selfString , (' - an instance of %1 or one of its %2.' bindWith:classLink with:subclassesLink) |
|
1631 |
]. |
|
1632 |
||
1244 | 1633 |
nSubClasses == 0 ifTrue:[ |
3810 | 1634 |
^ selfString , 'refers to the object which received the message. |
6 | 1635 |
|
1244 | 1636 |
In this case, it will be an instance of ' , className , '.' |
6 | 1637 |
]. |
1638 |
||
1244 | 1639 |
nSubClasses <= 5 ifTrue:[ |
3810 | 1640 |
^ selfString , ' refers to the object which received the message. |
6 | 1641 |
|
1244 | 1642 |
In this case, it will be an instance of ' , className , ' |
6 | 1643 |
or one of its subclasses: |
1644 |
||
1256 | 1645 |
' , subNames asStringCollection asString |
6 | 1646 |
]. |
1647 |
||
1198 | 1648 |
^ selfString , ' refers to the object which received the message. |
6 | 1649 |
|
1244 | 1650 |
In this case, it will be an instance of ' , className , ' |
1651 |
or one of its ' , nSubClasses printString , ' subclasses.' |
|
1926
935dbaeca76f
show class package in explanation
Claus Gittinger <cg@exept.de>
parents:
1910
diff
changeset
|
1652 |
|
935dbaeca76f
show class package in explanation
Claus Gittinger <cg@exept.de>
parents:
1910
diff
changeset
|
1653 |
"Modified: / 09-10-2006 / 12:11:44 / cg" |
2828
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1654 |
"Modified (comment): / 28-02-2012 / 10:47:06 / cg" |
6 | 1655 |
! |
1656 |
||
1188 | 1657 |
explainSuperIn:aClass short:shortText |
2828
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1658 |
"return an explanation" |
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1659 |
|
1352 | 1660 |
|superName| |
1244 | 1661 |
|
1662 |
superName := aClass superclass name. |
|
1188 | 1663 |
|
1664 |
shortText ifTrue:[ |
|
3842 | 1665 |
^ '"super" - message lookup starts in superclass "%1" (call redefined method).' bindWith:(self asClassLink:superName) |
1188 | 1666 |
]. |
1667 |
||
2828
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1668 |
^ 'like "self", "','super'allBold,'" refers to the object which received the message. |
6 | 1669 |
|
2828
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1670 |
However, when sending a message to "super", the search for methods |
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1671 |
implementing this message will start in the superclass (' , superName , '), |
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1672 |
instead of the receiver''s class (' , aClass name , ' or subclass). |
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1673 |
Thus, using "super", a redefined method can call the original (redefined) method of its superclass.' |
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1674 |
|
aa93cebd33e4
added: #explainHereIn:short:
Claus Gittinger <cg@exept.de>
parents:
2815
diff
changeset
|
1675 |
"Modified (comment): / 28-02-2012 / 10:47:03 / cg" |
6 | 1676 |
! |
2 | 1677 |
|
49 | 1678 |
explainSyntax:string |
1679 |
"try syntax ...; return explanation or nil" |
|
1680 |
||
1183 | 1681 |
^ self explainSyntax:string short:false |
1682 |
! |
|
1683 |
||
1684 |
explainSyntax:string short:shortText |
|
3842 | 1685 |
"try syntax ...; return explanation or nil. |
1686 |
This is meant for beginners..." |
|
1183 | 1687 |
|
3883 | 1688 |
|fullMsg stringWithoutSeparators| |
3881 | 1689 |
|
49 | 1690 |
((string = ':=') or:[string = '_']) ifTrue:[ |
3881 | 1691 |
fullMsg := '<variable> := <expression> |
49 | 1692 |
|
3233 | 1693 |
":=" and "_" (which is left-arrow in some fonts) mean assignment. |
3464 | 1694 |
The variable is bound to (i.e. points to) the value of <expression>. |
3881 | 1695 |
The "_" form is historic and should not be used with new code.'. |
1696 |
||
1697 |
shortText ifTrue:[ |
|
1698 |
string = '_' ifTrue:[ |
|
1699 |
^ (self |
|
1700 |
asLink:'"_"' |
|
1701 |
info:fullMsg |
|
1702 |
to:nil),' - old style for assignment. Consider changing to ":=".' |
|
1703 |
]. |
|
1704 |
^ (self |
|
1705 |
asLink:'":="' |
|
1706 |
info:fullMsg |
|
1707 |
to:nil),' - assign to variable on the left (syntax).' |
|
1708 |
]. |
|
1709 |
^ fullMsg |
|
49 | 1710 |
]. |
1711 |
||
1712 |
(string = '^') ifTrue:[ |
|
3233 | 1713 |
shortText ifTrue:[ |
3607 | 1714 |
^ '"^" - return value from method (syntax)'. |
3233 | 1715 |
]. |
1716 |
^ '^ <expression> |
|
49 | 1717 |
|
3319 | 1718 |
A return statement evaluates <expression> and returns its value from the method. |
1719 |
A return inside a block exits the method where the block is defined (not only the block).' |
|
49 | 1720 |
]. |
1721 |
||
1722 |
(string = ';') ifTrue:[ |
|
3233 | 1723 |
shortText ifTrue:[ |
3607 | 1724 |
^ '";" - a cascade expression (syntax)'. |
3233 | 1725 |
]. |
1726 |
^ '<expression> ; selector1 ; .... ; selectorN |
|
49 | 1727 |
|
3203 | 1728 |
a cascade expression; evaluate expression, and send messages |
1729 |
<selector1> ... <selectorN> to the first expression''s receiver. |
|
49 | 1730 |
Returns the value of the last send. The cascade sends may also have arguments.' |
1731 |
]. |
|
1732 |
||
1733 |
(string = '|') ifTrue:[ |
|
3233 | 1734 |
shortText ifTrue:[ |
3607 | 1735 |
^ '"|" - local variables (syntax)'. |
3233 | 1736 |
]. |
1737 |
^ '| locals | or: [:arg | statements] |
|
49 | 1738 |
|
3233 | 1739 |
"|" is used to mark a local variable declaration or separates arguments |
49 | 1740 |
from the statements in a block. Notice, that in a block-argument declaration |
3319 | 1741 |
these arg nams must be prefixed by a colon character. |
3233 | 1742 |
"|" is also a selector understood by Booleans.' |
49 | 1743 |
]. |
1744 |
||
3319 | 1745 |
(string startsWith:'$' ) ifTrue:[ |
1746 |
shortText ifTrue:[ |
|
3842 | 1747 |
^ '"$x" - ',(self asClassLink:'Character'),' literal (syntax)'. |
3319 | 1748 |
]. |
1749 |
^ 'is a Character literal constant. |
|
1750 |
||
1751 |
Character objects represent indivdual text cheracters in Unicode encoding. |
|
1752 |
For example, $a is the character "a" with an encoding of 97 "hex: 16r61". |
|
1753 |
Smalltalk/X supports unicode and uses this encoding internally for all characters |
|
1754 |
and strings. Notice, that not all Smalltalk implementations allow non-ascii (i.e. codes > 255).' |
|
1755 |
]. |
|
1756 |
||
2287
61f5dfccf2c0
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
1757 |
(string startsWith:'#' ) ifTrue:[ |
3233 | 1758 |
(string startsWith:'#(' ) ifTrue:[ |
1759 |
shortText ifTrue:[ |
|
3842 | 1760 |
^ '"#(..)" - ',(self asClassLink:'Array'),' literal (syntax)'. |
3233 | 1761 |
]. |
3607 | 1762 |
^ 'is a constant Array (literal). |
2287
61f5dfccf2c0
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
1763 |
|
61f5dfccf2c0
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
1764 |
The array-object is created at compilation time and a reference to this is |
61f5dfccf2c0
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
1765 |
used at execution time (thus, the same object is referred to every time). |
61f5dfccf2c0
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
1766 |
The elements of a constant Array must be numbers, strings, symbols, nil, true or false, |
3194 | 1767 |
other array constants or byte-arrays. |
2287
61f5dfccf2c0
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
1768 |
(notice, that not all Smalltalk implementations allow true, false and nil as |
3194 | 1769 |
element in an Array-constant).' |
3233 | 1770 |
]. |
2287
61f5dfccf2c0
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
1771 |
|
3233 | 1772 |
(string startsWith:'#[') ifTrue:[ |
1773 |
shortText ifTrue:[ |
|
3842 | 1774 |
^ '"#[..]" - ',(self asClassLink:'ByteArray'),' literal (syntax)'. |
3233 | 1775 |
]. |
3607 | 1776 |
^ 'is a constant ByteArray (literal). |
2287
61f5dfccf2c0
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
1777 |
|
61f5dfccf2c0
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
1778 |
The elements of a constant ByteArray must be Integer constants in the range |
61f5dfccf2c0
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
1779 |
0 .. 255. |
61f5dfccf2c0
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
1780 |
(notice, that not all Smalltalk implementations support constant ByteArrays).' |
3233 | 1781 |
]. |
2287
61f5dfccf2c0
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
1782 |
|
3233 | 1783 |
(string startsWith:'#''') ifTrue:[ |
1784 |
shortText ifTrue:[ |
|
3842 | 1785 |
^ '"#''..''" - ',(self asClassLink:'Symbol'),' literal (syntax)'. |
3233 | 1786 |
]. |
1787 |
^ 'is a constant symbol containing non-alphanumeric characters. |
|
2287
61f5dfccf2c0
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
1788 |
|
61f5dfccf2c0
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
1789 |
Symbols are unique strings, meaning that there exists |
61f5dfccf2c0
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
1790 |
exactly one instance of a given symbol. Therefore symbols can |
61f5dfccf2c0
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
1791 |
be compared using == (identity compare) in addition to = (contents compare). |
3194 | 1792 |
Beside this, Symbols behave mostly like Strings but are immutable.' |
3233 | 1793 |
]. |
2287
61f5dfccf2c0
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
1794 |
|
3233 | 1795 |
shortText ifTrue:[ |
3842 | 1796 |
^ '"#.." - ',(self asClassLink:'Symbol'),' literal (syntax)'. |
3233 | 1797 |
]. |
3319 | 1798 |
^ 'is a constant symbol. |
2287
61f5dfccf2c0
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
1799 |
|
61f5dfccf2c0
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
1800 |
Symbols are unique strings, meaning that there exists |
61f5dfccf2c0
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
1801 |
exactly one instance of a given symbol. Therefore symbols can |
61f5dfccf2c0
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
1802 |
be compared using == (identity compare) in addition to = (contents compare). |
3194 | 1803 |
Beside this, Symbols behave mostly like Strings but are immutable.' |
2287
61f5dfccf2c0
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2286
diff
changeset
|
1804 |
]. |
49 | 1805 |
((string startsWith:'(') or:[string endsWith:')']) ifTrue:[ |
3233 | 1806 |
shortText ifTrue:[ |
1807 |
^ ''. |
|
1808 |
]. |
|
1809 |
^ '( <expression> ) |
|
49 | 1810 |
|
3194 | 1811 |
expression grouping. Without them, expressions are evaluated left to right, |
1812 |
with unary messages preceeding binary messages, preceeding keyword mesages.' |
|
49 | 1813 |
]. |
1814 |
||
1815 |
((string startsWith:'[') or:[string endsWith:']']) ifTrue:[ |
|
3233 | 1816 |
shortText ifTrue:[ |
3842 | 1817 |
^ '"[..]" - a ',(self asClassLink:'Block'),' (aka lambda/closure for experts)'. |
3233 | 1818 |
]. |
1819 |
^ '[:arg1 .. :argN | statements] |
|
49 | 1820 |
|
3203 | 1821 |
defines a block. |
3194 | 1822 |
Blocks represent pieces of executable code. The definition of a block does |
3203 | 1823 |
not evaluate it, instead a reference to the blocks computation is created. |
3194 | 1824 |
The block can be evaluated later, by sending it a value/value: message |
1825 |
(it can be even evaluated multiple times). |
|
1826 |
Blocks are often passed as arguments to Booleans (i.e. "bool ifTrue:[...]"), |
|
1827 |
other blocks (i.e. "[...] whileTrue: [...]"]) or collections (i.e. "coll do:[...]"). |
|
1828 |
Blocks are also often used as callbacks from UI components or as exception handlers.' |
|
49 | 1829 |
]. |
1830 |
||
2286
cabf7db33a38
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2226
diff
changeset
|
1831 |
((string startsWith:'{') or:[string endsWith:'}']) ifTrue:[ |
3233 | 1832 |
shortText ifTrue:[ |
3842 | 1833 |
^ '"{..}" ',(self asClassLink:'Array'),' instantiation (syntax)'. |
3233 | 1834 |
]. |
1835 |
^ '{ <expr1>. .. <exprN> } |
|
2286
cabf7db33a38
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2226
diff
changeset
|
1836 |
|
3319 | 1837 |
This is syntactic sugar for "Array with:<expr1> .. with:<exprN>". |
1838 |
||
2286
cabf7db33a38
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2226
diff
changeset
|
1839 |
A new array is created with N elements initialized from the N expressions. |
cabf7db33a38
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2226
diff
changeset
|
1840 |
The expressions are separated by a period statement separator. |
cabf7db33a38
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2226
diff
changeset
|
1841 |
The expressions are evaluated at execution time, and a new array is always created |
cabf7db33a38
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2226
diff
changeset
|
1842 |
when executed (as opposed to an array literal, which is computed only once at |
3233 | 1843 |
compilation time) and which is shared. |
3319 | 1844 |
Notice that this construct is not supported by all Smalltalk dialects, so its use |
1845 |
makes your program somewhat dialect specific.' |
|
2286
cabf7db33a38
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2226
diff
changeset
|
1846 |
]. |
cabf7db33a38
changed: #explainSyntax:short:
Claus Gittinger <cg@exept.de>
parents:
2226
diff
changeset
|
1847 |
|
49 | 1848 |
(string = ':') ifTrue:[ |
3233 | 1849 |
shortText ifTrue:[ |
1850 |
^ ''. |
|
1851 |
]. |
|
1852 |
^ 'colons have different meaning depending on context: |
|
49 | 1853 |
|
1854 |
1) they separate keyword-parts in symbols and keyword-messages as in: |
|
1855 |
||
1856 |
#at:put: a constant keyword symbol |
|
1857 |
||
1858 |
rec at:index put:value sends the #at:put: message to rec, |
|
3233 | 1859 |
passing index and value as arguments. |
49 | 1860 |
|
1861 |
2) within block-argument declarations as in: |
|
1862 |
||
1863 |
[:arg1 :arg2 | statements] |
|
834 | 1864 |
|
1865 |
3) within an identifier, they separate the nameSpace part from |
|
1866 |
the name part; as in: |
|
1867 |
||
1868 |
Smalltalk::Array - the Array class in the Smalltalk nameSpace. |
|
1869 |
Foo::Array - the Array class in the Foo nameSpace. |
|
49 | 1870 |
' |
1871 |
]. |
|
1872 |
||
1873 |
(string = '.') ifTrue:[ |
|
3233 | 1874 |
^ 'statement. "<- period here" |
49 | 1875 |
statement |
1876 |
||
1877 |
within a method or block, individual statements are separated by periods. |
|
1878 |
' |
|
1879 |
]. |
|
1880 |
||
3883 | 1881 |
stringWithoutSeparators := string withoutSeparators. |
1882 |
||
1883 |
(stringWithoutSeparators startsWith:'"') ifTrue:[ |
|
1884 |
(stringWithoutSeparators startsWith:'"/') ifTrue:[ |
|
3464 | 1885 |
shortText ifTrue:[ |
3607 | 1886 |
^ 'an end-of-line comment (syntax)'. |
3464 | 1887 |
]. |
1888 |
^ '"/ comment |
|
3193 | 1889 |
EOL (end-of-line) comment |
1890 |
||
1891 |
anything up to the end of line is a comment and ignored (but not inside a string). |
|
3233 | 1892 |
Notice that EOL-comments are only supported by Smalltalk/X (i.e. non-portable). |
3193 | 1893 |
' |
3464 | 1894 |
]. |
3883 | 1895 |
(stringWithoutSeparators startsWith:'"<<') ifTrue:[ |
3464 | 1896 |
shortText ifTrue:[ |
4175 | 1897 |
^ 'a token delimited comment; up to line starting with the token after ''<<''.'. |
3464 | 1898 |
]. |
1899 |
^ '"<<TOKEN |
|
1900 |
... |
|
1901 |
TOKEN |
|
1902 |
||
1903 |
Token delimited comment |
|
1904 |
||
4175 | 1905 |
anything up to a line which starts with the token is a comment and ignored (but not inside a string). |
3464 | 1906 |
Notice that Token-comments are only supported by Smalltalk/X (i.e. non-portable). |
1907 |
' |
|
1908 |
]. |
|
1909 |
||
3233 | 1910 |
shortText ifTrue:[ |
3607 | 1911 |
^ 'a comment (syntax)'. |
3233 | 1912 |
]. |
1913 |
^ '" comment ... " |
|
3193 | 1914 |
comment |
1915 |
||
1916 |
anything between double quotes is a comment and ignored (but not inside a string). |
|
1917 |
' |
|
1918 |
]. |
|
1919 |
||
49 | 1920 |
"/ is it a symbol without hash-character ? |
1921 |
"/ |
|
796 | 1922 |
"/ string knownAsSymbol ifTrue:[ |
1923 |
"/ ^ 'is nothing, but #' , string , ' is known as a symbol. |
|
1924 |
"/ |
|
1925 |
"/Symbols are unique strings, meaning that there exists |
|
1926 |
"/exactly one instance of a given symbol. Therefore symbols can |
|
1927 |
"/be compared using == (identity compare) in addition to = (contents compare). |
|
1928 |
"/Beside this, Symbols behave mostly like Strings.' |
|
1929 |
"/ ]. |
|
49 | 1930 |
|
3883 | 1931 |
((stringWithoutSeparators startsWith:'<') and:[stringWithoutSeparators endsWith:'>']) ifTrue:[ |
1932 |
shortText ifTrue:[ |
|
1933 |
(stringWithoutSeparators includesString:'resource:') ifTrue:[ |
|
1934 |
^ 'a ',(self |
|
1935 |
asLink:'resource annotation' |
|
1936 |
info:fullMsg |
|
1937 |
to:(self actionToBrowseClass:Annotation)),' (syntax)' |
|
1938 |
]. |
|
1939 |
^ 'an ',(self |
|
1940 |
asLink:'annotation / pragma' |
|
1941 |
info:fullMsg |
|
1942 |
to:(self actionToBrowseClass:Annotation)),' (syntax)' |
|
1943 |
]. |
|
1944 |
]. |
|
1945 |
||
49 | 1946 |
^ nil |
796 | 1947 |
|
4175 | 1948 |
"Modified: / 28-07-2017 / 10:32:11 / cg" |
2214 | 1949 |
! |
1950 |
||
3810 | 1951 |
typeDescriptionFor:setOfTypes andSelector:selectorOrNil |
1952 |
"up to 3 types are shown by name; more are simply counted" |
|
1953 |
||
3842 | 1954 |
^ self typeDescriptionFor:setOfTypes andSelector:selectorOrNil wordBetween:'or' |
1955 |
! |
|
1956 |
||
1957 |
typeDescriptionFor:setOfTypes andSelector:selectorOrNil wordBetween:wordbetween |
|
1958 |
"up to 3 types are shown by name; more are simply counted" |
|
1959 |
||
3810 | 1960 |
|types numTypes |
1961 |
type1 type2 type3 |
|
4206 | 1962 |
nm1 nm2 nm3 link stringForType| |
1963 |
||
1964 |
stringForType := |
|
1965 |
[:class | |
|
1966 |
class == UndefinedObject ifTrue:['nil'] |
|
1967 |
ifFalse:[ class == True ifTrue:['true'] |
|
1968 |
ifFalse:[ class == False ifTrue:['false'] |
|
1969 |
ifFalse:[ class == VoidObject ifTrue:['Void'] |
|
1970 |
ifFalse:[ class name ]]]] |
|
1971 |
]. |
|
1972 |
||
3810 | 1973 |
"/ reduce... |
1974 |
self compressSetOfTypes:setOfTypes. |
|
1975 |
setOfTypes isEmpty ifTrue:[^ nil]. |
|
1976 |
||
1977 |
types := setOfTypes asOrderedCollection. |
|
1978 |
types sortBySelector:#name. |
|
1979 |
||
1980 |
"/ now make this a nice string |
|
1981 |
numTypes := types size. |
|
1982 |
type1 := types first. |
|
4206 | 1983 |
|
1984 |
nm1 := self asLink:(stringForType value:type1) to:(self actionToBrowseClass:type1 selector:selectorOrNil). |
|
3810 | 1985 |
numTypes == 1 ifTrue:[ |
1986 |
^ nm1 |
|
1987 |
]. |
|
3842 | 1988 |
|
3810 | 1989 |
type2 := types second. |
4206 | 1990 |
nm2 := self asLink:(stringForType value:type2) to:(self actionToBrowseClass:type2 selector:selectorOrNil). |
3810 | 1991 |
numTypes == 2 ifTrue:[ |
3842 | 1992 |
^ nm1,' ',wordbetween,' ',nm2 |
3810 | 1993 |
]. |
1994 |
type3 := types third. |
|
4206 | 1995 |
nm3 := self asLink:(stringForType value:type3) to:(self actionToBrowseClass:type3 selector:selectorOrNil). |
3810 | 1996 |
numTypes == 3 ifTrue:[ |
3842 | 1997 |
^ nm1,', ',nm2,' ',wordbetween,' ',nm3 |
3810 | 1998 |
]. |
3855 | 1999 |
link := self actionToBrowseClasses:types. |
2000 |
"/ selectorOrNil notNil ifTrue:[ |
|
2001 |
"/ link := self actionToOpenMethodFinderFor:selectorOrNil. |
|
2002 |
"/ ]. |
|
3859 | 2003 |
^ self asLink:('%1 classes' bindWith:numTypes) to:link. |
4206 | 2004 |
|
2005 |
"Modified (format): / 11-11-2017 / 12:30:09 / cg" |
|
3810 | 2006 |
! |
2007 |
||
2214 | 2008 |
valueStringFor:aValue |
2009 |
|valString| |
|
2010 |
||
4287 | 2011 |
aValue isProtoObject ifTrue:[ |
2012 |
^ aValue printString |
|
2013 |
]. |
|
2014 |
||
2214 | 2015 |
"/ only show the value, if it is really short... |
3203 | 2016 |
(aValue isBoolean |
3708 | 2017 |
or:[aValue isNil |
2018 |
or:[aValue isString |
|
2019 |
or:[aValue isNumber |
|
2020 |
or:[aValue isPoint |
|
2021 |
or:[aValue isCharacter |
|
2022 |
]]]]]) ifTrue:[ |
|
2023 |
^ aValue storeString. |
|
2226 | 2024 |
]. |
2427 | 2025 |
|
2226 | 2026 |
(aValue isColor) ifTrue:[ |
3708 | 2027 |
^ 'Color: ',(' ' emphasizeAllWith:(#backgroundColor->aValue)). |
2226 | 2028 |
]. |
2029 |
||
3203 | 2030 |
((aValue isKindOf:GUID) |
2031 |
or:[aValue isUUID]) ifTrue:[ |
|
3708 | 2032 |
valString := aValue printString. |
2427 | 2033 |
]. |
2034 |
||
3203 | 2035 |
(valString isEmptyOrNil |
2899
8b8701a65441
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2828
diff
changeset
|
2036 |
or:[ valString size > 50 |
8b8701a65441
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2828
diff
changeset
|
2037 |
or:[ valString includes:Character cr ]]) ifTrue:[ |
3708 | 2038 |
valString := aValue classNameWithArticle. |
2214 | 2039 |
]. |
2040 |
||
2041 |
^ valString |
|
2427 | 2042 |
|
2043 |
"Modified: / 14-10-2010 / 11:57:52 / cg" |
|
4287 | 2044 |
"Modified: / 24-07-2018 / 12:08:55 / Claus Gittinger" |
141 | 2045 |
! ! |
49 | 2046 |
|
3798 | 2047 |
!Explainer class methodsFor:'naive type inferer'! |
2048 |
||
2049 |
addTypeOfExpressionNode:expr forAssignmentTo:varName to:setOfTypes |
|
3842 | 2050 |
"pick up low hanging type information. |
2051 |
This is far from being complete, but often gives a hint good enough for code completion |
|
2052 |
and info in the browser." |
|
2053 |
||
2054 |
|val valClass| |
|
3798 | 2055 |
|
2056 |
"/ only look for wellknown types on the right side. |
|
3810 | 2057 |
expr isLiteral ifTrue:[ |
2058 |
val := expr value. |
|
3801 | 2059 |
valClass := val class. |
3798 | 2060 |
val isImmutable ifTrue:[ |
3801 | 2061 |
valClass := [ valClass mutableClass ] on:Error do:[ valClass ]. |
3798 | 2062 |
]. |
2063 |
self rememberType:valClass in:setOfTypes. |
|
3826 | 2064 |
^ setOfTypes. |
3798 | 2065 |
]. |
2066 |
||
2067 |
expr isMessage ifTrue:[ |
|
3842 | 2068 |
self addTypeOfMessageNode:expr forAssignmentTo:varName to:setOfTypes. |
2069 |
^ setOfTypes. |
|
3798 | 2070 |
]. |
3855 | 2071 |
|
3826 | 2072 |
^ setOfTypes |
2073 |
||
3798 | 2074 |
"Created: / 30-04-2016 / 15:28:59 / cg" |
3801 | 2075 |
"Modified: / 30-04-2016 / 20:17:35 / cg" |
3798 | 2076 |
! |
2077 |
||
3842 | 2078 |
addTypeOfMessageNode:expr forAssignmentTo:varName to:setOfTypes |
2079 |
"pick up low hanging type information. |
|
2080 |
This is far from being complete, but often gives a hint good enough for code completion |
|
2081 |
and info in the browser." |
|
2082 |
||
2083 |
|valClass msgSelector msgReceiver| |
|
2084 |
||
2085 |
msgSelector := expr selector. |
|
2086 |
msgReceiver := expr receiver. |
|
2087 |
||
2088 |
msgSelector == #? ifTrue:[ |
|
2089 |
self addTypeOfExpressionNode:(expr arg1) forAssignmentTo:varName to:setOfTypes. |
|
2090 |
^ setOfTypes |
|
2091 |
]. |
|
2092 |
||
2093 |
"/ really really only very low hanging fruit... |
|
2094 |
"/ ignore #/ here, because of filename |
|
2095 |
( #(+ - *) includes:msgSelector ) ifTrue:[ |
|
3885 | 2096 |
true "(msgReceiver isLiteralNumber or:[expr arg1 isLiteralNumber])" ifTrue:[ |
2097 |
self rememberType:Number in:setOfTypes. |
|
2098 |
^ setOfTypes. |
|
2099 |
]. |
|
2100 |
"/ "/ ignore foo := foo OP expr |
|
2101 |
"/ "/ ignore foo := expr OP foo |
|
2102 |
"/ (msgReceiver isVariable and:[msgReceiver name = varName]) ifFalse:[ |
|
2103 |
"/ (expr arg1 isVariable and:[expr arg1 name = varName]) ifFalse:[ |
|
2104 |
"/ self rememberType:Number in:setOfTypes. |
|
2105 |
"/ ] |
|
2106 |
"/ ]. |
|
3842 | 2107 |
^ setOfTypes. |
2108 |
]. |
|
2109 |
||
2110 |
( #(// size hash identityHash) includes:msgSelector ) ifTrue:[ |
|
2111 |
self rememberType:Integer in:setOfTypes. |
|
2112 |
^ setOfTypes. |
|
2113 |
]. |
|
2114 |
||
2115 |
( #(next next:) includes:msgSelector ) ifTrue:[ |
|
2116 |
|rcvrTypes| |
|
2117 |
||
2118 |
rcvrTypes := self addTypeOfExpressionNode:msgReceiver forAssignmentTo:nil to:Set new. |
|
2119 |
rcvrTypes notEmpty ifTrue:[ |
|
3885 | 2120 |
self breakPoint:#cg. |
3842 | 2121 |
self rememberType:Character in:setOfTypes. |
2122 |
]. |
|
2123 |
^ setOfTypes. |
|
2124 |
]. |
|
2125 |
||
2126 |
( msgSelector startsWith:'as') ifTrue:[ |
|
2127 |
valClass := Smalltalk classNamed:(msgSelector copyFrom:3). |
|
2128 |
valClass notNil ifTrue:[ |
|
2129 |
self rememberType:valClass in:setOfTypes. |
|
2130 |
^ setOfTypes. |
|
2131 |
]. |
|
2132 |
]. |
|
2133 |
||
2134 |
( #(copy shallowCopy) includes:msgSelector ) ifTrue:[ |
|
2135 |
msgReceiver isLiteral ifTrue:[ |
|
2136 |
self addTypeOfExpressionNode:msgReceiver forAssignmentTo:varName to:setOfTypes. |
|
2137 |
]. |
|
2138 |
^ setOfTypes |
|
2139 |
]. |
|
2140 |
||
2141 |
msgReceiver isGlobal ifTrue:[ |
|
3853 | 2142 |
|instCreatorMessages globalValue implMethod| |
3842 | 2143 |
|
3853 | 2144 |
instCreatorMessages := #(new new: basicNew basicNew:). |
2145 |
||
3842 | 2146 |
globalValue := msgReceiver value. |
2147 |
globalValue isBehavior ifTrue:[ |
|
3853 | 2148 |
( instCreatorMessages includes:msgSelector ) ifTrue:[ |
3842 | 2149 |
self rememberType:globalValue in:setOfTypes. |
2150 |
^ setOfTypes. |
|
2151 |
]. |
|
3853 | 2152 |
implMethod := globalValue class lookupMethodFor:msgSelector. |
2153 |
"/ mhmh - fuzzy; if the implementing message sends any of the above to itself... |
|
2154 |
"/ assume it is returning it. |
|
2155 |
implMethod isNil ifTrue:[ |
|
2156 |
"/ will not be understood |
|
3857 | 2157 |
self breakPoint:#cg. |
3853 | 2158 |
^ setOfTypes. |
2159 |
]. |
|
2160 |
(implMethod messagesSentToSelf includesAny:instCreatorMessages) ifTrue:[ |
|
3857 | 2161 |
self breakPoint:#cg. |
3853 | 2162 |
self rememberType:globalValue in:setOfTypes. |
2163 |
^ setOfTypes. |
|
2164 |
]. |
|
2165 |
"/ very fuzzy - if the implementing method is in the "instance creation" category... |
|
2166 |
((implMethod category ? '') startsWith:'instance creation') ifTrue:[ |
|
3857 | 2167 |
self breakPoint:#cg. |
3853 | 2168 |
self rememberType:globalValue in:setOfTypes. |
2169 |
^ setOfTypes. |
|
2170 |
]. |
|
3842 | 2171 |
]. |
4197 | 2172 |
"/ self breakPoint:#cg. |
3842 | 2173 |
^ setOfTypes |
2174 |
]. |
|
2175 |
||
4197 | 2176 |
"/ self breakPoint:#cg. |
3842 | 2177 |
^ setOfTypes |
4197 | 2178 |
|
2179 |
"Modified: / 10-10-2017 / 16:57:09 / cg" |
|
3842 | 2180 |
! |
2181 |
||
3798 | 2182 |
addTypesAssignedToInstvar:instVarName inClass:aClass method:aMethod to:setOfTypes |
2183 |
"look to asssignments to an instance variable, and pick up low hanging class information. |
|
3842 | 2184 |
This is far from being complete, but often gives a hint good enough for code completion |
3798 | 2185 |
and info in the browser." |
2186 |
||
2187 |
| code | |
|
2188 |
||
3902 | 2189 |
SourceCodeManagerError handle:[:ex | |
2190 |
] do:[ |
|
2191 |
code := aMethod source. |
|
2192 |
]. |
|
3798 | 2193 |
(code notNil) ifTrue:[ |
2194 |
self addTypesAssignedToInstvar:instVarName inClass:aClass source:code to:setOfTypes |
|
2195 |
] |
|
2196 |
||
2197 |
"Created: / 30-04-2016 / 15:07:33 / cg" |
|
2198 |
! |
|
2199 |
||
2200 |
addTypesAssignedToInstvar:instVarName inClass:aClass source:code to:setOfTypes |
|
2201 |
"look to asssignments to an instance variable, and pick up low hanging class information. |
|
3842 | 2202 |
This is far from being complete, but often gives a hint good enough for code completion |
3798 | 2203 |
and info in the browser." |
2204 |
||
3810 | 2205 |
|tree| |
3798 | 2206 |
|
2207 |
"/ quick check (avoids expensive parse) |
|
2208 |
(code includesString:instVarName) ifFalse:[ ^ self ]. |
|
2209 |
||
2210 |
tree := Parser parse:code class:aClass. |
|
2211 |
(tree isNil or:[tree == #Error]) ifTrue:[ ^ self ]. "/ unparsable |
|
2212 |
||
3810 | 2213 |
self addTypesAssignedToInstvar:instVarName inTree:tree to:setOfTypes. |
2214 |
||
2215 |
"Created: / 30-04-2016 / 15:09:18 / cg" |
|
2216 |
! |
|
2217 |
||
2218 |
addTypesAssignedToInstvar:instVarName inClass:aClass to:setOfTypes |
|
2219 |
"look to asssignments to an instance variable, and pick up low hanging class information. |
|
3842 | 2220 |
This is far from being complete, but often gives a hint good enough for code completion |
3810 | 2221 |
and info in the browser." |
2222 |
||
2223 |
aClass methodDictionary do:[:m | |
|
2224 |
self addTypesAssignedToInstvar:instVarName inClass:aClass method:m to:setOfTypes |
|
2225 |
]. |
|
2226 |
||
2227 |
"Created: / 30-04-2016 / 14:52:56 / cg" |
|
2228 |
! |
|
2229 |
||
2230 |
addTypesAssignedToInstvar:instVarName inTree:tree to:setOfTypes |
|
2231 |
"look to asssignments to an instance variable, and pick up low hanging class information. |
|
3842 | 2232 |
This is far from being complete, but often gives a hint good enough for code completion |
3810 | 2233 |
and info in the browser." |
2234 |
||
2235 |
|visitor| |
|
2236 |
||
3798 | 2237 |
visitor := PluggableParseNodeVisitor new. |
2238 |
visitor |
|
2239 |
actionForNodeClass:AssignmentNode |
|
2240 |
put:[:node | |
|
3853 | 2241 |
(node variable isInstanceVariableNamed:instVarName) ifTrue:[ |
2242 |
self addTypeOfExpressionNode:(node expression) forAssignmentTo:instVarName to:setOfTypes |
|
3798 | 2243 |
]. |
2244 |
true "/ yes - visit subnodes |
|
2245 |
]. |
|
2246 |
visitor visit:tree. |
|
2247 |
! |
|
2248 |
||
3810 | 2249 |
addTypesAssignedToLocal:localName inTree:tree to:setOfTypes |
3842 | 2250 |
"look to asssignments to a local variable, and pick up low hanging class information. |
2251 |
This is far from being complete, but often gives a hint good enough for code completion |
|
3798 | 2252 |
and info in the browser." |
2253 |
||
3810 | 2254 |
|visitor| |
2255 |
||
2256 |
"/ hack, allowing to deal with both types of AST (sigh) |
|
2257 |
(tree isKindOf:RBProgramNode) ifTrue:[ |
|
2258 |
visitor := RBPluggableProgramNodeVisitor new. |
|
2259 |
visitor |
|
2260 |
actionForNodeClass:RBAssignmentNode |
|
2261 |
put:[:node | |
|
3853 | 2262 |
|leftSide| |
3798 | 2263 |
|
3810 | 2264 |
leftSide := node variable. |
2265 |
(leftSide isTemporary and:[ leftSide name = localName ]) ifTrue:[ |
|
3853 | 2266 |
self addTypeOfExpressionNode:(node value) forAssignmentTo:localName to:setOfTypes |
3810 | 2267 |
]. |
2268 |
true "/ yes - visit subnodes |
|
2269 |
]. |
|
2270 |
visitor visitNode:tree. |
|
2271 |
] ifFalse:[ |
|
2272 |
visitor := PluggableParseNodeVisitor new. |
|
2273 |
visitor |
|
2274 |
actionForNodeClass:AssignmentNode |
|
2275 |
put:[:node | |
|
2276 |
|leftSide expr| |
|
2277 |
||
2278 |
leftSide := node variable. |
|
2279 |
(leftSide isLocalVariable and:[ leftSide name = localName ]) ifTrue:[ |
|
2280 |
expr := node expression. |
|
2281 |
self addTypeOfExpressionNode:expr forAssignmentTo:localName to:setOfTypes |
|
2282 |
]. |
|
2283 |
true "/ yes - visit subnodes |
|
2284 |
]. |
|
2285 |
visitor visit:tree. |
|
2286 |
]. |
|
3798 | 2287 |
! |
2288 |
||
2289 |
addTypesOfInstvar:instVarName inClass:aClass fromExistingInstancesTo:setOfTypes |
|
2290 |
"look for existing instances and see that type is there" |
|
2291 |
||
2292 |
|instIndex| |
|
2293 |
||
2294 |
instIndex := aClass instVarIndexFor:instVarName. |
|
2295 |
aClass allSubInstancesDo:[:i | |
|
3801 | 2296 |
|val varClass| |
3798 | 2297 |
|
3801 | 2298 |
val := (i instVarAt:instIndex). |
2299 |
val notNil ifTrue:[ |
|
2300 |
varClass := val class. |
|
2301 |
self rememberType:varClass in:setOfTypes. |
|
2302 |
]. |
|
3798 | 2303 |
]. |
2304 |
||
2305 |
"Created: / 30-04-2016 / 14:56:11 / cg" |
|
3801 | 2306 |
"Modified: / 30-04-2016 / 20:05:03 / cg" |
3798 | 2307 |
! |
2308 |
||
2309 |
compressSetOfTypes:setOfTypes |
|
2310 |
|toAdd toRemove| |
|
2311 |
||
2312 |
"/ reduce by eliminating common superclasses... |
|
2313 |
||
2314 |
toAdd := Set new. |
|
2315 |
toRemove := Set new. |
|
2316 |
setOfTypes do:[:type1 | |
|
2317 |
setOfTypes do:[:type2 | |
|
2318 |
|common| |
|
2319 |
||
2320 |
type1 superclass == type2 ifTrue:[ |
|
2321 |
toRemove add:type1. |
|
2322 |
] ifFalse:[ |
|
2323 |
type2 superclass == type1 ifTrue:[ |
|
2324 |
toRemove add:type2. |
|
2325 |
] ifFalse:[ |
|
2326 |
common := type1 commonSuperclass:type2. |
|
2327 |
common ~~ Object ifTrue:[ |
|
2328 |
toRemove add:type1. |
|
2329 |
toRemove add:type2. |
|
2330 |
toAdd add:common. |
|
2331 |
]. |
|
2332 |
]. |
|
2333 |
]. |
|
2334 |
] |
|
2335 |
]. |
|
2336 |
setOfTypes removeAll:toRemove. |
|
2337 |
setOfTypes addAll:toRemove. |
|
2338 |
||
2339 |
"/ hack |
|
2340 |
setOfTypes size == 2 ifTrue:[ |
|
2341 |
((setOfTypes includes:True) and:[setOfTypes includes:False]) ifTrue:[ |
|
2342 |
setOfTypes removeAll; add:Boolean. |
|
2343 |
^ self. |
|
2344 |
]. |
|
2345 |
((setOfTypes includes:SmallInteger) and:[setOfTypes includes:LargeInteger]) ifTrue:[ |
|
2346 |
setOfTypes removeAll; add:Integer. |
|
2347 |
^ self. |
|
2348 |
] |
|
2349 |
]. |
|
2350 |
||
2351 |
"Created: / 30-04-2016 / 15:37:38 / cg" |
|
2352 |
! |
|
2353 |
||
2354 |
rememberType:aClass in:setOfTypes |
|
2355 |
setOfTypes add:aClass |
|
2356 |
||
2357 |
"Created: / 30-04-2016 / 15:35:44 / cg" |
|
3801 | 2358 |
"Modified: / 30-04-2016 / 20:05:09 / cg" |
3798 | 2359 |
! ! |
2360 |
||
3838 | 2361 |
!Explainer class methodsFor:'utilities'! |
2362 |
||
3842 | 2363 |
actionToBrowseClass:class |
2364 |
^ self actionToBrowseClass:class selector:nil. |
|
2365 |
! |
|
2366 |
||
3838 | 2367 |
actionToBrowseClass:class selector:selectorOrNil |
3885 | 2368 |
^ self actionToBrowseClass:class selector:selectorOrNil info:nil |
3866 | 2369 |
! |
2370 |
||
2371 |
actionToBrowseClass:class selector:selectorOrNil info:info |
|
3885 | 2372 |
self assert:class isBehavior. |
3866 | 2373 |
^ ActionWithInfo |
2374 |
block: |
|
2375 |
[ |
|
2376 |
self thisOrNewBrowserInto:[:browser :openHow | |
|
2377 |
browser |
|
2378 |
spawnFullBrowserInClass:class selector:selectorOrNil in:openHow |
|
2379 |
] |
|
2380 |
] |
|
2381 |
info:info |
|
3838 | 2382 |
! |
2383 |
||
2384 |
actionToBrowseClasses:classes |
|
3868 | 2385 |
^ ActionWithInfo |
2386 |
block:[ |
|
2387 |
"/ Tools::NewSystemBrowser browseClasses:classes |
|
2388 |
self thisOrNewBrowserInto:[:browser :openHow | |
|
2389 |
browser spawnClassBrowserFor:classes in:openHow |
|
2390 |
] |
|
3855 | 2391 |
] |
3868 | 2392 |
info:nil |
3838 | 2393 |
! |
2394 |
||
3855 | 2395 |
actionToBrowseImplementorsOf:selector |
4032 | 2396 |
^ self actionToBrowseImplementorsOf:selector in:[Smalltalk allClasses] |
3866 | 2397 |
! |
2398 |
||
2399 |
actionToBrowseImplementorsOf:selector in:classes |
|
3868 | 2400 |
^ ActionWithInfo |
2401 |
block:[ |
|
2402 |
self thisOrNewBrowserInto:[:browser :openHow | |
|
2403 |
browser |
|
2404 |
spawnMethodImplementorsBrowserFor:{ selector } |
|
2405 |
match:false |
|
2406 |
in:openHow |
|
4032 | 2407 |
classes:classes value |
3868 | 2408 |
label:('Implementors of %1' bindWith:selector) |
2409 |
] |
|
3855 | 2410 |
] |
4032 | 2411 |
info:('Click to browse implementors') |
3842 | 2412 |
! |
2413 |
||
3853 | 2414 |
actionToBrowseInstvarRefsTo:instVarName inClass:class |
3868 | 2415 |
^ ActionWithInfo |
2416 |
block:[ |
|
2417 |
self thisOrNewBrowserInto:[:browser :openHow | |
|
2418 |
browser |
|
2419 |
browseVarRefsToAny:{ instVarName } |
|
2420 |
classes:{ class } |
|
2421 |
variables:#instVarNames access:#readOrWrite all:true |
|
2422 |
title:'references to ',instVarName |
|
2423 |
in:openHow |
|
2424 |
] |
|
2425 |
] |
|
2426 |
info:nil |
|
3853 | 2427 |
! |
2428 |
||
3842 | 2429 |
actionToBrowseMethod:mthd |
3885 | 2430 |
self assert:mthd isMethod. |
3842 | 2431 |
^ self actionToBrowseClass:(mthd mclass) selector:(mthd selector). |
2432 |
! |
|
2433 |
||
2434 |
actionToOpenMethodFinderFor:selector |
|
3838 | 2435 |
MethodFinderWindow notNil ifTrue:[ |
3868 | 2436 |
^ ActionWithInfo |
2437 |
block:[ |
|
2438 |
MethodFinderWindow openOnSelectorPattern:selector |
|
2439 |
] |
|
2440 |
info:nil. |
|
3838 | 2441 |
]. |
3842 | 2442 |
^ self actionToBrowseImplementorsOf:selector |
2443 |
! |
|
2444 |
||
2445 |
asClassLink:nameOfClass |
|
2446 |
"return text with a hyperlink to browse a class by that name" |
|
3838 | 2447 |
|
3842 | 2448 |
|cls| |
2449 |
||
2450 |
cls := Smalltalk classNamed:nameOfClass string asUppercaseFirst. |
|
2451 |
cls isNil ifTrue:[^ nameOfClass]. |
|
3859 | 2452 |
|
3866 | 2453 |
^ self |
2454 |
asLink:nameOfClass |
|
3878 | 2455 |
info:('Click to browse %1' bindWith:nameOfClass) |
3866 | 2456 |
to:(self actionToBrowseClass:cls) |
2457 |
! |
|
2458 |
||
2459 |
asLink:aString info:info to:actionOrNil |
|
2460 |
actionOrNil isNil ifTrue:[^ aString]. |
|
2461 |
^ aString asActionLinkTo:(ActionWithInfo block:actionOrNil info:info) |
|
2462 |
! |
|
2463 |
||
2464 |
asLink:aString to:actionOrNil |
|
2465 |
actionOrNil isNil ifTrue:[^ aString]. |
|
2466 |
^ aString asActionLinkTo:actionOrNil |
|
2467 |
! |
|
2468 |
||
3872 | 2469 |
infoStringForClasses:aCollectionOfClasses withPrefix:prefix |
2470 |
"get a nice user readable list for some classes. |
|
2471 |
Up to 4 are named, otherwise the count is presented. |
|
2472 |
The prefix can be sth like ' other', ' sub', ' super', |
|
2473 |
' implementing' etc. Or it can be an empty string. |
|
2474 |
To be shown in the info line at the bottom." |
|
2475 |
||
3885 | 2476 |
|nClassNames sortedByName classNames link1 link2 link3 link4| |
3872 | 2477 |
|
2478 |
aCollectionOfClasses isEmpty ifTrue:[ |
|
2479 |
^ 'No %1classes' bindWith:prefix. |
|
2480 |
]. |
|
2481 |
||
4032 | 2482 |
classNames := aCollectionOfClasses asIdentitySet asOrderedCollection |
2483 |
collect:[:each | each theNonMetaclass name]. |
|
3872 | 2484 |
|
2485 |
nClassNames := classNames size. |
|
2486 |
||
2487 |
nClassNames <= 4 ifTrue:[ |
|
3885 | 2488 |
sortedByName := classNames sort. |
2489 |
link1 := self asClassLink:sortedByName first. |
|
3872 | 2490 |
nClassNames == 1 ifTrue:[ |
3885 | 2491 |
^ '%2' "'1 %1class: %2'" bindWith:prefix with:link1. |
3872 | 2492 |
]. |
3885 | 2493 |
link2 := self asClassLink:classNames second. |
3872 | 2494 |
nClassNames == 2 ifTrue:[ |
2495 |
^ '%2 and %3' "'2 %1classes: %2 and %3'" bindWith:prefix |
|
3885 | 2496 |
with:link1 |
2497 |
with:link2. |
|
3872 | 2498 |
]. |
3885 | 2499 |
link3 := self asClassLink:classNames third. |
3872 | 2500 |
nClassNames == 3 ifTrue:[ |
2501 |
^ '%2, %3 and %4' "'3 %1classes: %2, %3 and %4'" bindWith:prefix |
|
3885 | 2502 |
with:link1 |
2503 |
with:link2 |
|
2504 |
with:link3. |
|
3872 | 2505 |
]. |
3885 | 2506 |
link4 := self asClassLink:classNames fourth. |
3872 | 2507 |
nClassNames == 4 ifTrue:[ |
2508 |
^ '%2, %3, %4 and %5' "'4 %1classes: %2, %3, %4 and %5'" bindWith:prefix |
|
3885 | 2509 |
with:link1 |
2510 |
with:link2 |
|
2511 |
with:link3 |
|
2512 |
with:link4. |
|
3872 | 2513 |
]. |
2514 |
]. |
|
3885 | 2515 |
^ self |
2516 |
asLink:('%1 %2classes' bindWith:nClassNames printString with:prefix) |
|
2517 |
info:'Browse classes' |
|
2518 |
to:(self actionToBrowseClasses:aCollectionOfClasses) |
|
3872 | 2519 |
|
2520 |
"Modified: / 27-07-2006 / 10:09:02 / cg" |
|
2521 |
! |
|
2522 |
||
3866 | 2523 |
infoStringForClasses:aCollectionOfClasses withPrefix:prefix actionGenerator:actionGeneratorOrNil |
2524 |
"get a nice user readable list for some classes. |
|
2525 |
Up to 4 are named, otherwise the count is presented. |
|
2526 |
The prefix can be sth like ' other', ' sub', ' super', |
|
2527 |
' implementing' etc. Or it can be an empty string. |
|
2528 |
To be shown in the info line at the bottom." |
|
2529 |
||
2530 |
|nClassNames classes sortedByName classNames |
|
2531 |
link1 link2 link3 link4 actionGenerator| |
|
2532 |
||
2533 |
aCollectionOfClasses isEmpty ifTrue:[ |
|
2534 |
^ 'No %1classes' bindWith:prefix. |
|
2535 |
]. |
|
2536 |
||
2537 |
actionGenerator := actionGeneratorOrNil isNil |
|
2538 |
ifTrue:[ [:classes | self actionToBrowseClasses:classes] ] |
|
2539 |
ifFalse:[ actionGeneratorOrNil ]. |
|
2540 |
||
2541 |
classes := aCollectionOfClasses asIdentitySet asOrderedCollection. |
|
2542 |
classNames := classes collect:[:each | each theNonMetaclass name]. |
|
2543 |
||
2544 |
nClassNames := classNames size. |
|
2545 |
||
2546 |
nClassNames <= 4 ifTrue:[ |
|
2547 |
sortedByName := classNames sortWith:classes. |
|
2548 |
||
2549 |
link1 := self asLink:classNames first "allBold" |
|
2550 |
info:('Browse %1' bindWith:classNames first) |
|
2551 |
to:(actionGenerator value:{classes first}). |
|
2552 |
nClassNames == 1 ifTrue:[ |
|
2553 |
^ '%2' "'1 %1class: %2'" |
|
2554 |
bindWith:prefix |
|
2555 |
with:link1. |
|
2556 |
]. |
|
2557 |
link2 := self asLink:classNames second "allBold" to:(actionGenerator value:{classes second}). |
|
2558 |
nClassNames == 2 ifTrue:[ |
|
2559 |
^ '%2 and %3' "'2 %1classes: %2 and %3'" |
|
2560 |
bindWith:prefix |
|
2561 |
with:link1 |
|
2562 |
with:link2. |
|
2563 |
]. |
|
2564 |
link3 := self asLink:classNames third "allBold" to:(actionGenerator value:{classes third}). |
|
2565 |
nClassNames == 3 ifTrue:[ |
|
2566 |
^ '%2, %3 and %4' "'3 %1classes: %2, %3 and %4'" |
|
2567 |
bindWith:prefix |
|
2568 |
with:link1 |
|
2569 |
with:link2 |
|
2570 |
with:link3. |
|
2571 |
]. |
|
2572 |
link4 := self asLink:classNames fourth "allBold" to:(actionGenerator value:{classes fourth}). |
|
2573 |
nClassNames == 4 ifTrue:[ |
|
2574 |
^ '%2, %3, %4 and %5' "'4 %1classes: %2, %3, %4 and %5'" |
|
2575 |
bindWith:prefix |
|
2576 |
with:link1 |
|
2577 |
with:link2 |
|
2578 |
with:link3 |
|
2579 |
with:link4. |
|
2580 |
]. |
|
2581 |
]. |
|
2582 |
^ self |
|
2583 |
asLink:('%1 %2classes' bindWith:(nClassNames printString "allBold") with:prefix) |
|
2584 |
to:(actionGenerator value:classes) |
|
2585 |
||
2586 |
"Modified: / 27-07-2006 / 10:09:02 / cg" |
|
3842 | 2587 |
! |
2588 |
||
2589 |
infoStringForMethods:aCollectionOfMethods withPrefix:prefix |
|
2590 |
"get a nice user readable list for some methods. |
|
2591 |
Up to 3 are named, otherwise the count is presented. |
|
2592 |
The prefix can be sth like ' other', ' sender', ' implementor', |
|
2593 |
Or it can be an empty string. |
|
2594 |
Result is meant to be shown in the info line at the bottom of a browser." |
|
2595 |
||
2596 |
|nMethodNames sortedByName methodNames| |
|
2597 |
||
2598 |
aCollectionOfMethods isEmpty ifTrue:[ |
|
2599 |
^ 'No %1' bindWith:prefix. |
|
2600 |
]. |
|
2601 |
||
2602 |
methodNames := aCollectionOfMethods asOrderedCollection |
|
2603 |
collect:[:each | each whoString]. |
|
2604 |
||
2605 |
nMethodNames := methodNames size. |
|
2606 |
||
2607 |
nMethodNames <= 3 ifTrue:[ |
|
2608 |
nMethodNames == 1 ifTrue:[ |
|
2609 |
^ '%2' "'1 %1class: %2'" bindWith:prefix with:(methodNames first allBold). |
|
2610 |
]. |
|
2611 |
sortedByName := methodNames sort. |
|
2612 |
nMethodNames == 2 ifTrue:[ |
|
2613 |
^ '%2 and %3' "'2 %1classes: %2 and %3'" bindWith:prefix |
|
2614 |
with:(sortedByName first allBold) |
|
2615 |
with:(sortedByName second allBold). |
|
2616 |
]. |
|
2617 |
nMethodNames == 3 ifTrue:[ |
|
2618 |
^ '%2, %3 and %4' "'3 %1classes: %2, %3 and %4'" bindWith:prefix |
|
2619 |
with:(sortedByName first allBold) |
|
2620 |
with:(sortedByName second allBold) |
|
2621 |
with:(sortedByName third allBold). |
|
2622 |
]. |
|
2623 |
nMethodNames == 4 ifTrue:[ |
|
2624 |
^ '%2, %3, %4 and %5' "'4 %1classes: %2, %3, %4 and %5'" bindWith:prefix |
|
2625 |
with:(sortedByName first allBold) |
|
2626 |
with:(sortedByName second allBold) |
|
2627 |
with:(sortedByName third allBold) |
|
2628 |
with:(sortedByName fourth allBold). |
|
2629 |
]. |
|
2630 |
]. |
|
2631 |
^ '%1 %2methods' bindWith:nMethodNames printString allBold with:prefix. |
|
2632 |
||
2633 |
" |
|
2634 |
Time millisecondsToRun:[ |
|
2635 |
self infoStringForMethods:(SystemBrowser allCallsOn:#'at:put:') withPrefix:'' |
|
2636 |
]. |
|
2637 |
Time millisecondsToRun:[ |
|
2638 |
self infoStringForMethods:(SystemBrowser allCallsOn:#'actionToBrowseClasses:') withPrefix:'' |
|
2639 |
]. |
|
2640 |
" |
|
2641 |
! |
|
2642 |
||
3872 | 2643 |
methodImplementorsInfoFor:aMethod inEnvironment:environment |
2644 |
"get something about the implementors of aMethod |
|
2645 |
to be shown in the info line at the bottom" |
|
2646 |
||
2647 |
|implementors msg senders msg2| |
|
2648 |
||
2649 |
implementors := SystemBrowser |
|
2650 |
findImplementorsOf:aMethod selector |
|
2651 |
in:(environment allClasses) |
|
2652 |
ignoreCase:false. |
|
2653 |
||
2654 |
implementors notEmpty ifTrue:[ |
|
2655 |
msg := 'Only implemented here.'. |
|
2656 |
implementors remove:aMethod ifAbsent:nil. |
|
2657 |
implementors notEmpty ifTrue:[ |
|
2658 |
implementors := implementors collect:[:mthd | mthd mclass ? mthd getMclass]. |
|
2659 |
implementors notEmpty ifTrue:[ |
|
4032 | 2660 |
msg := 'Also ',(self asLink:'implemented' to:(self actionToBrowseImplementorsOf:aMethod selector)),' in '. |
3872 | 2661 |
msg := msg , (self infoStringForClasses:implementors withPrefix:'other '). |
2662 |
msg := msg , '.'. |
|
2663 |
] |
|
2664 |
]. |
|
2665 |
]. |
|
2666 |
||
2667 |
false ifTrue:[ "/ too slow |
|
2668 |
senders := SystemBrowser |
|
2669 |
findSendersOf:aMethod selector |
|
2670 |
in:(environment allClasses) |
|
2671 |
ignoreCase:false. |
|
2672 |
senders notEmpty ifTrue:[ |
|
2673 |
msg2 := 'Sent from ' , senders size printString, ' methods.'. |
|
2674 |
] ifFalse:[ |
|
2675 |
msg2 := 'No senders.'. |
|
2676 |
]. |
|
2677 |
msg := msg , '/' , msg2 |
|
2678 |
]. |
|
2679 |
||
2680 |
^ msg |
|
2681 |
! |
|
2682 |
||
3871 | 2683 |
methodInheritanceInfoFor:aMethod |
2684 |
|methodsSuperclass inheritedClass msg methodsClass sel mthd selectorString| |
|
2685 |
||
2686 |
methodsClass := aMethod mclass. |
|
2687 |
methodsClass isNil ifTrue:[^ nil]. |
|
2688 |
||
2689 |
methodsSuperclass := methodsClass superclass. |
|
2690 |
methodsSuperclass isNil ifTrue:[^ nil]. |
|
2691 |
||
2692 |
sel := aMethod selector. |
|
2693 |
inheritedClass := methodsSuperclass whichClassIncludesSelector:sel. |
|
2694 |
inheritedClass notNil ifTrue:[ |
|
2695 |
mthd := inheritedClass compiledMethodAt:sel. |
|
4110 | 2696 |
(mthd sendsSelector:#'subclassResponsibility') ifTrue:[ |
3871 | 2697 |
msg := '%1 overrides subclassResponsibility in %2'. |
2698 |
] ifFalse:[ |
|
2699 |
msg := '%1 overrides implementation in %2'. |
|
2700 |
]. |
|
2701 |
selectorString := sel contractTo:30. |
|
2702 |
^ msg |
|
2703 |
bindWith:(self |
|
2704 |
asLink:selectorString "allBold" |
|
2705 |
info:('Browse all implementors of %1' bindWith:selectorString) |
|
2706 |
to:(self actionToOpenMethodFinderFor:sel)) |
|
2707 |
with:(self |
|
2708 |
asLink:inheritedClass name "allBold" |
|
4287 | 2709 |
info:('Browse %1 » %2' bindWith:inheritedClass name with:sel) |
3871 | 2710 |
to:(self actionToBrowseClass:inheritedClass selector:sel)). |
2711 |
]. |
|
2712 |
||
2713 |
^ msg |
|
4110 | 2714 |
|
2715 |
"Modified: / 05-02-2017 / 01:24:25 / cg" |
|
3871 | 2716 |
! |
2717 |
||
2718 |
methodRedefinitionInfoFor:aMethod |
|
2719 |
"return a user readable string telling in how many subclasses |
|
2720 |
a method is redefined. |
|
2721 |
To be shown in the info line of a browser" |
|
2722 |
||
4060 | 2723 |
|redefiningClasses msg methodsClass| |
2724 |
||
2725 |
methodsClass := aMethod mclass. |
|
2726 |
methodsClass isNil ifTrue:[^ nil]. |
|
2727 |
||
2728 |
redefiningClasses := methodsClass allSubclasses select:[:eachClass | eachClass includesSelector:aMethod selector]. |
|
2729 |
redefiningClasses size ~~ 0 ifTrue:[ |
|
3871 | 2730 |
msg := 'redefined in '. |
2731 |
msg := msg , (self |
|
2732 |
infoStringForClasses:redefiningClasses |
|
2733 |
withPrefix:'sub' |
|
2734 |
actionGenerator:[:classes | |
|
3878 | 2735 |
classes size == 1 ifTrue:[ |
2736 |
|cls| |
|
4060 | 2737 |
|
3878 | 2738 |
cls := classes first. |
2739 |
self |
|
2740 |
actionToBrowseClass:cls |
|
2741 |
selector:aMethod selector |
|
2742 |
info:('Browse implementation in %1' bindWith:cls name) |
|
2743 |
] ifFalse:[ |
|
2744 |
self |
|
2745 |
actionToBrowseImplementorsOf:aMethod selector |
|
2746 |
in:classes |
|
2747 |
]. |
|
2748 |
]). |
|
3871 | 2749 |
msg := msg , '.'. |
2750 |
]. |
|
2751 |
||
2752 |
^ msg |
|
2753 |
! |
|
2754 |
||
3842 | 2755 |
methodSendersInfoFor:selector inEnvironment:environment |
2756 |
"get something about the senders of a message. |
|
2757 |
to be shown in the info line at the bottom. |
|
2758 |
This may be slow; so think about doing it in background..." |
|
2759 |
||
2760 |
|senders| |
|
2761 |
||
2762 |
senders := SystemBrowser |
|
2763 |
findSendersOf:selector |
|
2764 |
in:(environment allClasses) |
|
2765 |
ignoreCase:false |
|
2766 |
match:false. |
|
2767 |
||
2768 |
senders notEmpty ifTrue:[ |
|
2769 |
^ 'Sent from ' , senders size printString, ' methods.'. |
|
2770 |
] ifFalse:[ |
|
2771 |
^ 'No senders.'. |
|
2772 |
]. |
|
3859 | 2773 |
! |
2774 |
||
3872 | 2775 |
methodSpecialInfoFor:aMethod |
2776 |
"handles special cases - such as documentation methods" |
|
2777 |
||
2778 |
|cls sel| |
|
2779 |
||
2780 |
(cls := aMethod mclass) isNil ifTrue:[^ nil]. |
|
2781 |
(sel := aMethod selector) isNil ifTrue:[^ nil]. |
|
2782 |
||
2783 |
cls isMeta ifTrue:[ |
|
2784 |
(AbstractSourceCodeManager isVersionMethodSelector:sel) ifTrue:[ |
|
2785 |
^ 'The version method is required for the source code repository - do not modify.'. |
|
2786 |
]. |
|
2787 |
sel == #documentation ifTrue:[ |
|
2788 |
^ 'ST/X stores documentation in this method (not in comment slots)'. |
|
2789 |
]. |
|
2790 |
]. |
|
2791 |
^ nil |
|
2792 |
! |
|
2793 |
||
3859 | 2794 |
thisOrNewBrowserInto:aTwoArgBlock |
4269 | 2795 |
"I am inviked when user clicks on a link in the info line. |
2796 |
if I am invoked by a browser, |
|
4268 | 2797 |
invoke the twoArgBlock with it and a #newBuffer arg. |
3859 | 2798 |
Otherwise, create a new (invisible) browser and pass it to the block |
2799 |
with a #newBrowser arg." |
|
2800 |
||
2801 |
|windowGroupClass browserClass wg app| |
|
2802 |
||
2803 |
"/ stupid: I am in libcomp; should be in libtool |
|
4269 | 2804 |
"/ access by name, so we do not introduce new prerequisites on the package |
3859 | 2805 |
windowGroupClass := Smalltalk at:#WindowGroup. |
2806 |
windowGroupClass isNil ifTrue:[^ self]. |
|
4269 | 2807 |
browserClass := Smalltalk at:#'SystemBrowser'. |
2808 |
browserClass isNil ifTrue:[^ self]. |
|
2809 |
browserClass := browserClass default. |
|
3859 | 2810 |
browserClass isNil ifTrue:[^ self]. |
2811 |
||
2812 |
((wg := windowGroupClass activeGroup) notNil |
|
2813 |
and:[ (app := wg application) isKindOf:browserClass ] |
|
2814 |
) ifTrue:[ |
|
2815 |
^ aTwoArgBlock value:app value:#newBuffer |
|
2816 |
]. |
|
2817 |
^ aTwoArgBlock value:(browserClass basicNew) value:#newBrowser |
|
4268 | 2818 |
|
4269 | 2819 |
"Modified (comment): / 24-05-2018 / 15:01:01 / Claus Gittinger" |
3838 | 2820 |
! ! |
3826 | 2821 |
|
3866 | 2822 |
!Explainer::ActionWithInfo class methodsFor:'instance creation'! |
2823 |
||
2824 |
block:aBlock info:info |
|
2825 |
^ self new block:aBlock info:info |
|
2826 |
! ! |
|
2827 |
||
2828 |
!Explainer::ActionWithInfo methodsFor:'accessing'! |
|
2829 |
||
2830 |
block:blockArg info:infoArg |
|
2831 |
block := blockArg. |
|
2832 |
info := infoArg. |
|
2833 |
! |
|
2834 |
||
2835 |
info:something |
|
2836 |
info := something. |
|
2837 |
! ! |
|
2838 |
||
2839 |
!Explainer::ActionWithInfo methodsFor:'evaluation'! |
|
2840 |
||
2841 |
info |
|
2842 |
^ info |
|
2843 |
! |
|
2844 |
||
2845 |
value |
|
2846 |
^ block value |
|
2847 |
! |
|
2848 |
||
2849 |
value:arg |
|
2850 |
^ block value:arg |
|
2851 |
! ! |
|
2852 |
||
396 | 2853 |
!Explainer class methodsFor:'documentation'! |
146
3d407ab8ac44
suppress messages on transcript when explaining
Claus Gittinger <cg@exept.de>
parents:
141
diff
changeset
|
2854 |
|
3d407ab8ac44
suppress messages on transcript when explaining
Claus Gittinger <cg@exept.de>
parents:
141
diff
changeset
|
2855 |
version |
3697 | 2856 |
^ '$Header$' |
2214 | 2857 |
! |
2858 |
||
2859 |
version_CVS |
|
3697 | 2860 |
^ '$Header$' |
146
3d407ab8ac44
suppress messages on transcript when explaining
Claus Gittinger <cg@exept.de>
parents:
141
diff
changeset
|
2861 |
! ! |
3209 | 2862 |