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