author | Claus Gittinger <cg@exept.de> |
Wed, 12 Sep 2001 20:24:34 +0200 | |
changeset 1184 | b091e74f640f |
parent 1183 | 39f5ca4778d5 |
child 1185 | 7030f795b00d |
permissions | -rw-r--r-- |
2 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
49 | 3 |
All Rights Reserved |
2 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
1081 | 13 |
"{ Package: 'stx:libcomp' }" |
14 |
||
141 | 15 |
Parser subclass:#Explainer |
263 | 16 |
instanceVariableNames:'' |
17 |
classVariableNames:'' |
|
18 |
poolDictionaries:'' |
|
19 |
category:'System-Compiler' |
|
2 | 20 |
! |
21 |
||
396 | 22 |
!Explainer class methodsFor:'documentation'! |
2 | 23 |
|
20 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
49 | 27 |
All Rights Reserved |
20 | 28 |
|
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
2 | 38 |
documentation |
39 |
" |
|
20 | 40 |
a very simple explainer - much more should be added ... |
41 |
This one is involved, when the 'explain' function is used in a |
|
84 | 42 |
codeView (popup or via CMD-E). |
263 | 43 |
|
44 |
[author:] |
|
45 |
Claus Gittinger |
|
2 | 46 |
" |
47 |
! ! |
|
48 |
||
396 | 49 |
!Explainer class methodsFor:'explaining'! |
2 | 50 |
|
141 | 51 |
commonSuperClassOf:listOfClassNames |
52 |
|common found| |
|
53 |
||
54 |
listOfClassNames do:[:className | |
|
290
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
55 |
|class| |
141 | 56 |
|
336 | 57 |
class := Smalltalk classNamed:className. |
290
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
58 |
common isNil ifTrue:[ |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
59 |
common := class |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
60 |
] ifFalse:[ |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
61 |
(class isSubclassOf:common) ifTrue:[ |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
62 |
"keep common" |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
63 |
] ifFalse:[ |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
64 |
(common isSubclassOf:class) ifTrue:[ |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
65 |
common := class |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
66 |
] ifFalse:[ |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
67 |
"walk up, checking" |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
68 |
found := false. |
1151 | 69 |
|
290
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
70 |
common allSuperclassesDo:[:sup | |
1151 | 71 |
(found not and:[class isSubclassOf:sup]) ifTrue:[ |
72 |
common := sup. |
|
73 |
found := true. |
|
290
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
74 |
] |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
75 |
]. |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
76 |
found ifFalse:[ |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
77 |
class allSuperclassesDo:[:sup | |
1151 | 78 |
(found not and:[common isSubclassOf:sup]) ifTrue:[ |
79 |
common := sup. |
|
80 |
found := true. |
|
290
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
81 |
] |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
82 |
]. |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
83 |
]. |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
84 |
] |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
85 |
]. |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
86 |
]. |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
87 |
common == Object ifTrue:[^ common] |
141 | 88 |
]. |
89 |
^ common |
|
290
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
90 |
|
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
91 |
"Modified: 17.6.1996 / 17:09:21 / stefan" |
336 | 92 |
"Modified: 5.9.1996 / 19:34:41 / cg" |
141 | 93 |
! |
94 |
||
2 | 95 |
explain:someText in:source forClass:aClass |
6 | 96 |
"Given a source and a substring of it, return a string containing |
97 |
an explanation. |
|
49 | 98 |
This is just a q&d implementation - to be correct, it should use the parser, |
99 |
and explain from the parsetree (instead of doing string matches). |
|
100 |
This leads to some wrong explanations, for example if some string is |
|
839 | 101 |
used as selector within a string, or if a variable is named like a |
102 |
message selector. I.e. the explanation should be context sensitive. |
|
49 | 103 |
Also, there could be much more detailed explanations." |
2 | 104 |
|
1183 | 105 |
^ self |
106 |
explain:someText in:source forClass:aClass short:false |
|
107 |
! |
|
108 |
||
109 |
explain:someText in:source forClass:aClass short:shortText |
|
110 |
"Given a source and a substring of it, return a string containing |
|
111 |
an explanation. |
|
112 |
This is just a q&d implementation - to be correct, it should use the parser, |
|
113 |
and explain from the parsetree (instead of doing string matches). |
|
114 |
This leads to some wrong explanations, for example if some string is |
|
115 |
used as selector within a string, or if a variable is named like a |
|
116 |
message selector. I.e. the explanation should be context sensitive. |
|
117 |
Also, there could be much more detailed explanations." |
|
118 |
||
1159 | 119 |
|parser variables c string tmp |
839 | 120 |
spc sym sel stringText| |
2 | 121 |
|
675 | 122 |
string := someText string withoutSeparators. |
839 | 123 |
stringText := string asText allBold. |
49 | 124 |
|
125 |
" |
|
126 |
ask parser for variable names |
|
127 |
" |
|
146
3d407ab8ac44
suppress messages on transcript when explaining
Claus Gittinger <cg@exept.de>
parents:
141
diff
changeset
|
128 |
parser := self parseMethod:source in:aClass ignoreErrors:true ignoreWarnings:true. |
2 | 129 |
parser notNil ifTrue:[ |
146
3d407ab8ac44
suppress messages on transcript when explaining
Claus Gittinger <cg@exept.de>
parents:
141
diff
changeset
|
130 |
"look for variables" |
2 | 131 |
|
146
3d407ab8ac44
suppress messages on transcript when explaining
Claus Gittinger <cg@exept.de>
parents:
141
diff
changeset
|
132 |
variables := parser methodVars. |
3d407ab8ac44
suppress messages on transcript when explaining
Claus Gittinger <cg@exept.de>
parents:
141
diff
changeset
|
133 |
(variables notNil and:[variables includes:string]) ifTrue:[ |
1183 | 134 |
^ '''' , stringText , ''' is a method variable.' |
146
3d407ab8ac44
suppress messages on transcript when explaining
Claus Gittinger <cg@exept.de>
parents:
141
diff
changeset
|
135 |
]. |
3d407ab8ac44
suppress messages on transcript when explaining
Claus Gittinger <cg@exept.de>
parents:
141
diff
changeset
|
136 |
variables := parser methodArgs. |
3d407ab8ac44
suppress messages on transcript when explaining
Claus Gittinger <cg@exept.de>
parents:
141
diff
changeset
|
137 |
(variables notNil and:[variables includes:string]) ifTrue:[ |
1183 | 138 |
^ '''' , stringText , ''' is a method argument.' |
146
3d407ab8ac44
suppress messages on transcript when explaining
Claus Gittinger <cg@exept.de>
parents:
141
diff
changeset
|
139 |
] |
2 | 140 |
]. |
49 | 141 |
|
2 | 142 |
parser isNil ifTrue:[ |
146
3d407ab8ac44
suppress messages on transcript when explaining
Claus Gittinger <cg@exept.de>
parents:
141
diff
changeset
|
143 |
parser := self for:(ReadStream on:source) in:aClass |
2 | 144 |
]. |
145 |
||
146 |
"instvars" |
|
84 | 147 |
c := aClass whichClassDefinesInstVar:string. |
148 |
c notNil ifTrue:[ |
|
396 | 149 |
c isMeta ifTrue:[ |
1183 | 150 |
^ '''' , stringText , ''' is a class instance variable in ' , c soleInstance name , '.' |
396 | 151 |
]. |
152 |
||
1183 | 153 |
^ '''' , stringText , ''' is an instance variable in ' , c name , '.' |
2 | 154 |
]. |
155 |
||
84 | 156 |
"/ variables := aClass allInstVarNames. |
157 |
"/ (variables notNil and:[variables includes:string]) ifTrue:[ |
|
158 |
"/ "where is it" |
|
159 |
"/ c := aClass. |
|
1159 | 160 |
"/ [c notNil] whileTrue:[ |v| |
84 | 161 |
"/ v := c instVarNames. |
162 |
"/ (v notNil and:[v includes:string]) ifTrue:[ |
|
163 |
"/ ^ string , ' is an instance variable in ' , c name |
|
164 |
"/ ]. |
|
165 |
"/ c := c superclass |
|
166 |
"/ ]. |
|
167 |
"/ self error:'oops' |
|
168 |
"/ ]. |
|
169 |
||
442 | 170 |
"/ "class instvars" |
171 |
"/ variables := aClass class allInstVarNames. |
|
172 |
"/ (variables notNil and:[variables includes:string]) ifTrue:[ |
|
173 |
"/ "where is it" |
|
174 |
"/ c := aClass. |
|
1159 | 175 |
"/ [c notNil] whileTrue:[ |v| |
442 | 176 |
"/ v := c class instVarNames. |
177 |
"/ (v notNil and:[v includes:string]) ifTrue:[ |
|
178 |
"/ ^ string , ' is a class instance variable in ' , c name |
|
179 |
"/ ]. |
|
180 |
"/ c := c superclass |
|
181 |
"/ ]. |
|
182 |
"/ self error:'oops' |
|
183 |
"/ ]. |
|
2 | 184 |
|
185 |
"classvars" |
|
186 |
c := parser inWhichClassIsClassVar:string. |
|
187 |
c notNil ifTrue:[ |
|
1183 | 188 |
^ '''' , stringText , ''' is a class variable in ' , c name , '.' |
2 | 189 |
]. |
190 |
||
509
d8475399ca3e
Correct handling of private classes.
Stefan Vogel <sv@exept.de>
parents:
503
diff
changeset
|
191 |
aClass isMeta ifTrue:[ |
d8475399ca3e
Correct handling of private classes.
Stefan Vogel <sv@exept.de>
parents:
503
diff
changeset
|
192 |
c := aClass soleInstance. |
d8475399ca3e
Correct handling of private classes.
Stefan Vogel <sv@exept.de>
parents:
503
diff
changeset
|
193 |
] ifFalse:[ |
d8475399ca3e
Correct handling of private classes.
Stefan Vogel <sv@exept.de>
parents:
503
diff
changeset
|
194 |
c := aClass. |
d8475399ca3e
Correct handling of private classes.
Stefan Vogel <sv@exept.de>
parents:
503
diff
changeset
|
195 |
]. |
d8475399ca3e
Correct handling of private classes.
Stefan Vogel <sv@exept.de>
parents:
503
diff
changeset
|
196 |
c privateClasses do:[:pClass | |
d8475399ca3e
Correct handling of private classes.
Stefan Vogel <sv@exept.de>
parents:
503
diff
changeset
|
197 |
(pClass name = string |
d8475399ca3e
Correct handling of private classes.
Stefan Vogel <sv@exept.de>
parents:
503
diff
changeset
|
198 |
or:[pClass nameWithoutPrefix = string]) ifTrue:[ |
1183 | 199 |
string := '''' , stringText , ''' is a private class in ''' , c name , '''.'. |
200 |
shortText ifFalse:[ |
|
201 |
string := (string , '\\It is only visible locally.') withCRs |
|
202 |
]. |
|
203 |
^ string withCRs |
|
422 | 204 |
]. |
205 |
]. |
|
206 |
||
456 | 207 |
(spc := aClass nameSpace) notNil ifTrue:[ |
796 | 208 |
sym := (spc name , '::' , string) asSymbolIfInterned. |
209 |
sym notNil ifTrue:[ |
|
210 |
(Smalltalk at:sym) isBehavior ifTrue:[ |
|
1183 | 211 |
string := '''' , stringText , ''' is a class in the ''' , spc name , ''' nameSpace.'. |
212 |
shortText ifFalse:[ |
|
213 |
string := (string |
|
796 | 214 |
, '\\It is only visible within this nameSpace.' |
215 |
, '\Access from the outside is possible' |
|
216 |
, '\by the special name ''' , spc name , '::' , string , '''.') withCRs |
|
1183 | 217 |
]. |
218 |
^ string withCRs |
|
796 | 219 |
]. |
422 | 220 |
]. |
221 |
]. |
|
222 |
||
796 | 223 |
"/ string knownAsSymbol ifTrue:[ |
146
3d407ab8ac44
suppress messages on transcript when explaining
Claus Gittinger <cg@exept.de>
parents:
141
diff
changeset
|
224 |
"globals & symbols" |
2 | 225 |
|
1183 | 226 |
tmp := self explainKnownSymbol:string inClass:aClass short:shortText. |
146
3d407ab8ac44
suppress messages on transcript when explaining
Claus Gittinger <cg@exept.de>
parents:
141
diff
changeset
|
227 |
tmp notNil ifTrue:[ ^ tmp]. |
839 | 228 |
|
229 |
"/ try with added colon ... |
|
230 |
sel := string , ':'. |
|
231 |
Symbol allInstancesDo:[:sym | |
|
232 |
(sym startsWith:sel) ifTrue:[ |
|
1183 | 233 |
tmp := self explainKnownSymbol:sym inClass:aClass short:shortText. |
839 | 234 |
tmp notNil ifTrue:[ ^ tmp]. |
235 |
] |
|
236 |
]. |
|
796 | 237 |
"/ ]. |
2 | 238 |
|
239 |
"try for some obvious things" |
|
1183 | 240 |
tmp := self explainPseudoVariable:string in:aClass short:true. |
2 | 241 |
tmp notNil ifTrue:[ ^ tmp]. |
242 |
||
243 |
"try syntax ..." |
|
244 |
||
1183 | 245 |
tmp := self explainSyntax:string short:shortText. |
49 | 246 |
tmp notNil ifTrue:[ ^ tmp]. |
20 | 247 |
|
1183 | 248 |
shortText ifTrue:[ |
249 |
^ '' |
|
250 |
]. |
|
251 |
||
2 | 252 |
parser isNil ifTrue:[ |
146
3d407ab8ac44
suppress messages on transcript when explaining
Claus Gittinger <cg@exept.de>
parents:
141
diff
changeset
|
253 |
^ 'parse error - no explanation' |
2 | 254 |
]. |
796 | 255 |
^ 'cannot explain this (could not figure out what this is).' |
146
3d407ab8ac44
suppress messages on transcript when explaining
Claus Gittinger <cg@exept.de>
parents:
141
diff
changeset
|
256 |
|
675 | 257 |
"Created: / 3.12.1995 / 12:47:37 / cg" |
258 |
"Modified: / 16.4.1997 / 12:46:11 / stefan" |
|
835 | 259 |
"Modified: / 23.3.1999 / 13:29:56 / cg" |
2 | 260 |
! |
261 |
||
141 | 262 |
explainHereIn:aClass |
263 |
^ 'like self, here refers to the object which received the message. |
|
264 |
||
265 |
However, when sending a message to here the search for methods |
|
266 |
implementing this message will start in the defining class (' , aClass name , ') |
|
267 |
instead of the receivers class (' , aClass name , ' or subclass). |
|
268 |
Thus, using here, redefined methods will NOT be reached with a here-send.' |
|
269 |
! |
|
270 |
||
835 | 271 |
explainKnownSymbol:string inClass:aClass |
141 | 272 |
"return explanation or nil" |
273 |
||
1183 | 274 |
^ self explainKnownSymbol:string inClass:aClass short:false |
275 |
! |
|
276 |
||
277 |
explainKnownSymbol:string inClass:aClass short:shortText |
|
278 |
"return explanation or nil" |
|
279 |
||
911
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
280 |
|sym list count tmp commonSuperClass val s s2 |
1183 | 281 |
firstImplementingClass cm msg t| |
141 | 282 |
|
796 | 283 |
sym := string asSymbolIfInterned. |
284 |
sym isNil ifTrue:[^ nil]. |
|
141 | 285 |
|
286 |
"try globals" |
|
287 |
||
288 |
(Smalltalk includesKey:sym) ifTrue:[ |
|
839 | 289 |
tmp := '''' , string asText allBold , ''' is a global variable.'. |
290
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
290 |
val := Smalltalk at:sym. |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
291 |
val isBehavior ifTrue:[ |
1183 | 292 |
"/ a class |
293 |
shortText ifTrue:[ |
|
294 |
^ '''' , string , ''' is ' , (val isLoaded ifTrue:['a'] ifFalse:['an autoloaded']) |
|
295 |
, ' class in the ''' , val category , ''' category.'. |
|
296 |
]. |
|
297 |
||
290
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
298 |
val name = string ifTrue:[ |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
299 |
tmp := tmp , ' |
503
b0d10f53a820
show 'autoloaded' for classes
Claus Gittinger <cg@exept.de>
parents:
497
diff
changeset
|
300 |
' , string , ' is ' , (val isLoaded ifTrue:['a'] ifFalse:['an autoloaded']) |
b0d10f53a820
show 'autoloaded' for classes
Claus Gittinger <cg@exept.de>
parents:
497
diff
changeset
|
301 |
, ' class categorized as ' , val category , ' |
1183 | 302 |
in the ''' , val package , ''' package.'. |
303 |
^ tmp. |
|
304 |
]. |
|
305 |
tmp := tmp , ' |
|
141 | 306 |
|
307 |
' , string , ' is bound to the class ' , val name , |
|
1183 | 308 |
' in category ' , val category , '.'. |
309 |
^ tmp. |
|
310 |
]. |
|
311 |
shortText ifTrue:[ |
|
312 |
^ '''' , string , ''' is ' , ' a global, currently bound to ' , val classNameWithArticle , '.'. |
|
313 |
]. |
|
141 | 314 |
|
1183 | 315 |
tmp := tmp , ' |
316 |
||
317 |
Its current value is ' , val classNameWithArticle , '.'. |
|
290
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
318 |
^ tmp. |
141 | 319 |
]. |
320 |
||
321 |
" |
|
322 |
try selectors |
|
323 |
look who implements it |
|
324 |
" |
|
325 |
list := Set new. |
|
1081 | 326 |
Smalltalk allClassesDo:[:c| |
290
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
327 |
(c implements:sym) ifTrue:[ |
911
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
328 |
list add:(c name). |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
329 |
firstImplementingClass isNil ifTrue:[ |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
330 |
firstImplementingClass := c |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
331 |
] |
290
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
332 |
]. |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
333 |
(c class implements:sym) ifTrue:[ |
911
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
334 |
list add:(c name , ' class'). |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
335 |
firstImplementingClass isNil ifTrue:[ |
912 | 336 |
firstImplementingClass := c class |
911
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
337 |
] |
290
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
338 |
] |
141 | 339 |
]. |
340 |
||
835 | 341 |
(aClass canUnderstand:sym) ifTrue:[ |
1184 | 342 |
s2 := ('Instances of ''' , aClass name , ''' respond to #') , sym asText allBold , '.'. |
343 |
shortText ifFalse:[ |
|
344 |
s2 := '\\' , s2 |
|
345 |
, '\- inherited from ' withCRs |
|
346 |
, (aClass whichClassImplements:sym) name asText allBold. |
|
347 |
]. |
|
911
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
348 |
firstImplementingClass := (aClass whichClassImplements:sym) |
835 | 349 |
] ifFalse:[ |
350 |
s2 := ''. |
|
351 |
]. |
|
352 |
||
141 | 353 |
count := list size. |
354 |
(count ~~ 0) ifTrue:[ |
|
290
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
355 |
" |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
356 |
for up-to 4 implementing classes, |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
357 |
list them |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
358 |
" |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
359 |
list := list asOrderedCollection sort. |
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
360 |
tmp := ' is a selector implemented in '. |
835 | 361 |
s := '#' , string asText allBold. |
911
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
362 |
|
290
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
363 |
(count == 1) ifTrue:[ |
1183 | 364 |
(t := list first) isMeta ifTrue:[ |
365 |
t := 'the ' , t |
|
366 |
]. |
|
1184 | 367 |
msg := s , tmp , t , '.'. |
368 |
shortText ifFalse:[ |
|
369 |
msg := msg , s2. |
|
370 |
] |
|
911
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
371 |
] ifFalse:[ |
1183 | 372 |
shortText ifTrue:[ |
373 |
msg := s , tmp , count printString , ' classes.'. |
|
374 |
^ msg |
|
375 |
]. |
|
376 |
||
911
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
377 |
(count == 2) ifTrue:[ |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
378 |
msg := s , tmp , (list at:1) , ' and ' , (list at:2) , '.' , s2 |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
379 |
] ifFalse:[ |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
380 |
(count == 3) ifTrue:[ |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
381 |
msg := s , tmp , ' |
835 | 382 |
' , (list at:1) , ', ' , (list at:2) , ' and ' , (list at:3) , '.' , s2 |
911
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
383 |
] ifFalse:[ |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
384 |
(count == 4) ifTrue:[ |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
385 |
msg := s , tmp , ' |
835 | 386 |
' , (list at:1) , ', ' , (list at:2) , ', ' , (list at:3), ' and ' , (list at:4) , '.' , s2 |
911
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
387 |
] ifFalse:[ |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
388 |
" |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
389 |
if there are more, look for a common |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
390 |
superclass and show it ... |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
391 |
" |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
392 |
commonSuperClass := self commonSuperClassOf:list. |
913 | 393 |
(commonSuperClass ~~ Object |
394 |
and:[commonSuperClass ~~ Behavior |
|
395 |
and:[commonSuperClass ~~ Class |
|
396 |
and:[commonSuperClass ~~ ClassDescription]]]) ifTrue:[ |
|
911
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
397 |
(list includes:commonSuperClass) ifTrue:[ |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
398 |
msg := s . tmp , count printString , commonSuperClass name |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
399 |
, ' and redefined in ' , (count - 1) printString |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
400 |
, ' subclasses' |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
401 |
, s2. |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
402 |
firstImplementingClass := commonSuperClass |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
403 |
] ifFalse:[ |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
404 |
msg := s , tmp, count printString , ' subclasses of ' , commonSuperClass name , s2 |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
405 |
] |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
406 |
] ifFalse:[ |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
407 |
(commonSuperClass == Object |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
408 |
and:[commonSuperClass implements:sym]) ifTrue:[ |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
409 |
msg := s , tmp , count printString , ' classes. |
834 | 410 |
|
411 |
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
|
412 |
since there is an implementation in Object.' , s2. |
141 | 413 |
|
911
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
414 |
firstImplementingClass := Object |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
415 |
] ifFalse:[ |
913 | 416 |
((commonSuperClass == Behavior |
417 |
or:[commonSuperClass == Class |
|
418 |
or:[commonSuperClass == ClassDescription]]) |
|
419 |
and:[commonSuperClass implements:sym]) ifTrue:[ |
|
420 |
msg := s , tmp , count printString , ' classes. |
|
421 |
||
422 |
All classes seem to respond to that message, |
|
423 |
since there is an implementation in ' , commonSuperClass name , '.' , s2. |
|
424 |
||
425 |
firstImplementingClass := commonSuperClass |
|
426 |
] ifFalse:[ |
|
427 |
" |
|
428 |
otherwise just give the number. |
|
429 |
" |
|
430 |
msg := s , tmp , count printString , ' classes.' , s2 |
|
431 |
] |
|
911
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
432 |
] |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
433 |
] |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
434 |
] |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
435 |
] |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
436 |
]. |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
437 |
]. |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
438 |
firstImplementingClass notNil ifTrue:[ |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
439 |
WindowGroup activeGroup withWaitCursorDo:[ |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
440 |
cm := firstImplementingClass compiledMethodAt:sym. |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
441 |
cm notNil ifTrue:[ |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
442 |
cm := cm methodComment. |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
443 |
] |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
444 |
]. |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
445 |
cm notNil ifTrue:[ |
1168
6eea38689d4a
allItalic now understood by CharacterArray
Claus Gittinger <cg@exept.de>
parents:
1159
diff
changeset
|
446 |
msg := msg , '\\The comment in ' withCRs , firstImplementingClass name allBold , ' is:\' withCRs , cm allItalic. |
911
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
447 |
] |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
448 |
]. |
be6ce6482a7f
extract the methods comment and show it.
Claus Gittinger <cg@exept.de>
parents:
839
diff
changeset
|
449 |
^ msg |
141 | 450 |
]. |
451 |
||
452 |
^ nil |
|
290
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
263
diff
changeset
|
453 |
|
796 | 454 |
"Modified: / 17.6.1996 / 17:09:30 / stefan" |
835 | 455 |
"Created: / 23.3.1999 / 13:29:33 / cg" |
456 |
"Modified: / 23.3.1999 / 13:40:40 / cg" |
|
141 | 457 |
! |
458 |
||
2 | 459 |
explainPseudoVariable:string in:aClass |
460 |
"return explanation for the pseudoVariables self, super etc." |
|
461 |
||
1183 | 462 |
^ self explainPseudoVariable:string in:aClass short:false |
463 |
! |
|
464 |
||
465 |
explainPseudoVariable:string in:aClass short:shortText |
|
466 |
"return explanation for the pseudoVariables self, super etc." |
|
467 |
||
2 | 468 |
(string = 'self') ifTrue:[ |
1183 | 469 |
^ self explainSelfIn:aClass short:shortText |
2 | 470 |
]. |
471 |
||
472 |
(string = 'super') ifTrue:[ |
|
1183 | 473 |
shortText ifTrue:[ |
474 |
^ '''super'' - message lookup starts in superclass ''' , aClass superclass name , '''.' |
|
475 |
]. |
|
476 |
^ self explainSuperIn:aClass |
|
2 | 477 |
]. |
478 |
||
84 | 479 |
(string = 'here') ifTrue:[ |
1183 | 480 |
shortText ifTrue:[ |
481 |
^ '''here'' - message lookup always starts in ''' , aClass name , '''.' |
|
482 |
]. |
|
483 |
^ self explainHereIn:aClass |
|
84 | 484 |
]. |
485 |
||
2 | 486 |
(string = 'thisContext') ifTrue:[ |
1183 | 487 |
shortText ifTrue:[ |
488 |
^ '''thisContext'' - the current stack frame as an object.' |
|
489 |
]. |
|
490 |
^ 'thisContext is a pseudo variable (i.e. it is built in). |
|
2 | 491 |
|
49 | 492 |
ThisContext always refers to the context object for the currently executed method or |
493 |
block (an instance of Context or BlockContext respectively). The calling chain and calling |
|
6 | 494 |
receivers/selectors can be accessed via thisContext.' |
495 |
]. |
|
496 |
||
497 |
(string = 'true') ifTrue:[ |
|
1183 | 498 |
shortText ifTrue:[ |
499 |
^ '''true'' - the truth and nothing but the truth.' |
|
500 |
]. |
|
501 |
^ 'true is a pseudo variable (i.e. it is built in). |
|
6 | 502 |
|
503 |
True represents logical truth. It is the one and only instance of class True.' |
|
2 | 504 |
]. |
505 |
||
506 |
(string = 'false') ifTrue:[ |
|
1183 | 507 |
shortText ifTrue:[ |
508 |
^ '''false'' - obvisously not true.' |
|
509 |
]. |
|
510 |
^ 'false is a pseudo variable (i.e. it is built in). |
|
2 | 511 |
|
512 |
False represents logical falseness. It is the one and only instance of class False.' |
|
513 |
]. |
|
514 |
||
515 |
(string = 'nil') ifTrue:[ |
|
1183 | 516 |
shortText ifTrue:[ |
517 |
^ '''nil'' - undefined, unknown, void or dont care.' |
|
518 |
]. |
|
519 |
^ 'nil is a pseudo variable (i.e. it is built in). |
|
2 | 520 |
|
521 |
Nil is used for unitialized variables (among other uses). |
|
522 |
Nil is the one and only instance of class UndefinedObject.' |
|
523 |
]. |
|
524 |
^ nil |
|
525 |
! |
|
526 |
||
6 | 527 |
explainSelfIn:aClass |
1183 | 528 |
^ self explainSelfIn:aClass short:false |
529 |
! |
|
530 |
||
531 |
explainSelfIn:aClass short:shortText |
|
6 | 532 |
|sub| |
533 |
||
534 |
sub := aClass allSubclasses collect:[:c | c name]. |
|
535 |
sub size == 0 ifTrue:[ |
|
1183 | 536 |
shortText ifTrue:[ |
537 |
^ '''self'' - an instance of ''' , aClass name , '''.' |
|
538 |
]. |
|
539 |
^ 'self refers to the object which received the message. |
|
6 | 540 |
|
541 |
In this case, it will be an instance of ' , aClass name , '.' |
|
542 |
]. |
|
543 |
||
1183 | 544 |
shortText ifTrue:[ |
545 |
^ '''self'' - an instance of ''' , aClass name , ''' or one of its subclasses.' |
|
546 |
]. |
|
6 | 547 |
sub size <= 5 ifTrue:[ |
1183 | 548 |
^ 'self refers to the object which received the message. |
6 | 549 |
|
550 |
In this case, it will be an instance of ' , aClass name , ' |
|
551 |
or one of its subclasses: |
|
552 |
||
58 | 553 |
' , sub asStringCollection asString |
6 | 554 |
]. |
555 |
||
556 |
^ 'self refers to the object which received the message. |
|
557 |
||
558 |
In this case, it will be an instance of ' , aClass name , ' |
|
559 |
or one of its ' , sub size printString , ' subclasses.' |
|
560 |
! |
|
561 |
||
562 |
explainSuperIn:aClass |
|
563 |
^ 'like self, super refers to the object which received the message. |
|
564 |
||
565 |
However, when sending a message to super the search for methods |
|
566 |
implementing this message will start in the superclass (' , aClass superclass name , ') |
|
84 | 567 |
instead of the receivers class (' , aClass name , ' or subclass). |
49 | 568 |
Thus, using super, a redefined method can call the original method in its superclass.' |
6 | 569 |
! |
2 | 570 |
|
49 | 571 |
explainSyntax:string |
572 |
"try syntax ...; return explanation or nil" |
|
573 |
||
1183 | 574 |
^ self explainSyntax:string short:false |
575 |
! |
|
576 |
||
577 |
explainSyntax:string short:shortText |
|
578 |
"try syntax ...; return explanation or nil" |
|
579 |
||
49 | 580 |
((string = ':=') or:[string = '_']) ifTrue:[ |
1183 | 581 |
shortText ifTrue:[ |
582 |
^ 'Assign to variable on the left side.'. |
|
583 |
]. |
|
584 |
||
796 | 585 |
^ '<variable> := <expression> |
49 | 586 |
|
834 | 587 |
'':='' and ''_'' (which is left-arrow in some fonts) mean assignment. |
49 | 588 |
The variable is bound to (i.e. points to) the value of <expression>.' |
589 |
]. |
|
590 |
||
591 |
(string = '^') ifTrue:[ |
|
1183 | 592 |
shortText ifTrue:[ |
593 |
^ 'Return value from method.'. |
|
594 |
]. |
|
796 | 595 |
^ '^ <expression> |
49 | 596 |
|
834 | 597 |
returns the value of <expression> as value from the method. |
49 | 598 |
A return from within a block exits the method where the block is defined.' |
599 |
]. |
|
600 |
||
601 |
(string = ';') ifTrue:[ |
|
1183 | 602 |
shortText ifTrue:[ |
603 |
^ 'Cascade expression.'. |
|
604 |
]. |
|
796 | 605 |
^ '<expression> ; selector1 ; .... ; selectorN |
49 | 606 |
|
607 |
a cascade expression; evaluate expression, and send messages |
|
608 |
<selector1> ... <selectorN> to the first expressions receiver. |
|
609 |
Returns the value of the last send. The cascade sends may also have arguments.' |
|
610 |
]. |
|
611 |
||
612 |
(string = '|') ifTrue:[ |
|
1183 | 613 |
shortText ifTrue:[ |
614 |
^ ''. |
|
615 |
]. |
|
796 | 616 |
^ '| locals | or: [:arg | statements] |
49 | 617 |
|
834 | 618 |
''|'' is used to mark a local variable declaration or separates arguments |
49 | 619 |
from the statements in a block. Notice, that in a block-argument declaration |
620 |
these must be prefixed by a colon character. |
|
834 | 621 |
''|'' is also a selector understood by Booleans.' |
49 | 622 |
]. |
623 |
||
624 |
((string startsWith:'(') or:[string endsWith:')']) ifTrue:[ |
|
1183 | 625 |
shortText ifTrue:[ |
626 |
^ ''. |
|
627 |
]. |
|
796 | 628 |
^ '(<expression>) |
49 | 629 |
|
630 |
expression grouping.' |
|
631 |
]. |
|
632 |
||
633 |
((string startsWith:'[') or:[string endsWith:']']) ifTrue:[ |
|
1183 | 634 |
shortText ifTrue:[ |
635 |
^ ''. |
|
636 |
]. |
|
834 | 637 |
^ '[:arg1 .. :argN | statements] |
49 | 638 |
|
639 |
defines a block. |
|
640 |
Blocks represent pieces of executable code. Definition of a block does |
|
641 |
not evaluate it. The block is evaluated by sending it a value/value: |
|
642 |
message. |
|
643 |
Blocks are often passed as arguments to Booleans (i.e. ifTrue:[...]) or |
|
644 |
collections (i.e. do:[...]).' |
|
645 |
]. |
|
646 |
||
647 |
(string = ':') ifTrue:[ |
|
1183 | 648 |
shortText ifTrue:[ |
649 |
^ ''. |
|
650 |
]. |
|
796 | 651 |
^ 'colons have different meaning depending on context: |
49 | 652 |
|
653 |
1) they separate keyword-parts in symbols and keyword-messages as in: |
|
654 |
||
655 |
#at:put: a constant keyword symbol |
|
656 |
||
657 |
rec at:index put:value sends the #at:put: message to rec, |
|
796 | 658 |
passing index and value as arguments. |
49 | 659 |
|
660 |
2) within block-argument declarations as in: |
|
661 |
||
662 |
[:arg1 :arg2 | statements] |
|
834 | 663 |
|
664 |
3) within an identifier, they separate the nameSpace part from |
|
665 |
the name part; as in: |
|
666 |
||
667 |
Smalltalk::Array - the Array class in the Smalltalk nameSpace. |
|
668 |
Foo::Array - the Array class in the Foo nameSpace. |
|
49 | 669 |
' |
670 |
]. |
|
671 |
||
672 |
(string = '.') ifTrue:[ |
|
796 | 673 |
^ 'statement. "<- period here" |
49 | 674 |
statement |
675 |
||
676 |
within a method or block, individual statements are separated by periods. |
|
677 |
' |
|
678 |
]. |
|
679 |
||
680 |
(string startsWith:'#' ) ifTrue:[ |
|
796 | 681 |
(string startsWith:'#(' ) ifTrue:[ |
1183 | 682 |
shortText ifTrue:[ |
683 |
^ 'Array Literal.'. |
|
684 |
]. |
|
796 | 685 |
^ 'is a constant Array. |
49 | 686 |
|
687 |
The elements of a constant Array must be Number-constants, nil, true or false. |
|
688 |
(notice, that not all Smalltalk implementations allow true, false and nil as |
|
689 |
constant-Array elements).' |
|
796 | 690 |
]. |
49 | 691 |
|
796 | 692 |
(string startsWith:'#[') ifTrue:[ |
1183 | 693 |
shortText ifTrue:[ |
694 |
^ 'ByteArray Literal.'. |
|
695 |
]. |
|
796 | 696 |
^ 'is a constant ByteArray. |
49 | 697 |
|
698 |
The elements of a constant ByteArray must be Integer constants in the range |
|
699 |
0 .. 255. |
|
700 |
(notice, that not all Smalltalk implementations support constant ByteArrays).' |
|
796 | 701 |
]. |
49 | 702 |
|
796 | 703 |
(string startsWith:'#''') ifTrue:[ |
1183 | 704 |
shortText ifTrue:[ |
705 |
^ 'Symbol Literal.'. |
|
706 |
]. |
|
796 | 707 |
^ 'is a constant symbol containing non-alphanumeric characters. |
49 | 708 |
|
709 |
Symbols are unique strings, meaning that there exists |
|
710 |
exactly one instance of a given symbol. Therefore symbols can |
|
711 |
be compared using == (identity compare) in addition to = (contents compare). |
|
712 |
Beside this, Symbols behave mostly like Strings. |
|
713 |
||
714 |
Notice, that not all Smalltalk implementations support this kind of symbols.' |
|
796 | 715 |
]. |
49 | 716 |
|
796 | 717 |
^ 'is a symbol. |
49 | 718 |
|
719 |
Symbols are unique strings, meaning that there exists |
|
720 |
exactly one instance of a given symbol. Therefore symbols can |
|
721 |
be compared using == (identity compare) in addition to = (contents compare). |
|
722 |
Beside this, Symbols behave mostly like Strings.' |
|
723 |
]. |
|
724 |
||
725 |
"/ is it a symbol without hash-character ? |
|
726 |
"/ |
|
796 | 727 |
"/ string knownAsSymbol ifTrue:[ |
728 |
"/ ^ 'is nothing, but #' , string , ' is known as a symbol. |
|
729 |
"/ |
|
730 |
"/Symbols are unique strings, meaning that there exists |
|
731 |
"/exactly one instance of a given symbol. Therefore symbols can |
|
732 |
"/be compared using == (identity compare) in addition to = (contents compare). |
|
733 |
"/Beside this, Symbols behave mostly like Strings.' |
|
734 |
"/ ]. |
|
49 | 735 |
|
736 |
^ nil |
|
796 | 737 |
|
738 |
"Modified: / 31.10.1998 / 14:28:58 / cg" |
|
141 | 739 |
! ! |
49 | 740 |
|
396 | 741 |
!Explainer class methodsFor:'documentation'! |
146
3d407ab8ac44
suppress messages on transcript when explaining
Claus Gittinger <cg@exept.de>
parents:
141
diff
changeset
|
742 |
|
3d407ab8ac44
suppress messages on transcript when explaining
Claus Gittinger <cg@exept.de>
parents:
141
diff
changeset
|
743 |
version |
1184 | 744 |
^ '$Header: /cvs/stx/stx/libcomp/Explainer.st,v 1.41 2001-09-12 18:24:34 cg Exp $' |
146
3d407ab8ac44
suppress messages on transcript when explaining
Claus Gittinger <cg@exept.de>
parents:
141
diff
changeset
|
745 |
! ! |