checkin from browser
authorClaus Gittinger <cg@exept.de>
Tue, 30 Mar 1999 19:45:36 +0200
changeset 839 021af12ebd18
parent 838 fd3286584da6
child 840 838c7bb1bbcf
checkin from browser
Explainer.st
--- a/Explainer.st	Mon Mar 29 12:06:47 1999 +0200
+++ b/Explainer.st	Tue Mar 30 19:45:36 1999 +0200
@@ -93,13 +93,15 @@
      This is just a q&d implementation - to be correct, it should use the parser,
      and explain from the parsetree (instead of doing string matches).
      This leads to some wrong explanations, for example if some string is
-     used as selector within a string.
+     used as selector within a string, or if a variable is named like a
+     message selector. I.e. the explanation should be context sensitive.
      Also, there could be much more detailed explanations."
 
     |parser variables v c string tmp
-     spc sym|
+     spc sym sel stringText|
 
     string := someText string withoutSeparators.
+    stringText := string asText allBold.
 
     "
      ask parser for variable names
@@ -110,11 +112,11 @@
 
         variables := parser methodVars.
         (variables notNil and:[variables includes:string]) ifTrue:[
-            ^ '''' , string , ''' is a method variable'
+            ^ '''' , stringText , ''' is a method variable'
         ].
         variables := parser methodArgs.
         (variables notNil and:[variables includes:string]) ifTrue:[
-            ^ '''' , string , ''' is a method argument'
+            ^ '''' , stringText , ''' is a method argument'
         ]
     ].
 
@@ -126,10 +128,10 @@
     c := aClass whichClassDefinesInstVar:string.
     c notNil ifTrue:[
         c isMeta ifTrue:[
-            ^ '''' , string , ''' is a class instance variable in ' , c soleInstance name
+            ^ '''' , stringText , ''' is a class instance variable in ' , c soleInstance name
         ].
 
-        ^ '''' , string , ''' is an instance variable in ' , c name
+        ^ '''' , stringText , ''' is an instance variable in ' , c name
     ].
 
 "/    variables := aClass allInstVarNames.
@@ -164,7 +166,7 @@
     "classvars"
     c := parser inWhichClassIsClassVar:string.
     c notNil ifTrue:[
-        ^ '''' , string , ''' is a class variable in ' , c name
+        ^ '''' , stringText , ''' is a class variable in ' , c name
     ].
 
     aClass isMeta ifTrue:[
@@ -175,7 +177,7 @@
     c privateClasses do:[:pClass |
         (pClass name = string 
          or:[pClass nameWithoutPrefix = string]) ifTrue:[
-            ^ ('''' , string , ''' is a private class in ''' , c name , '''.'
+            ^ ('''' , stringText , ''' is a private class in ''' , c name , '''.'
                      , '\\It is only visible locally.') withCRs
         ].
     ].
@@ -184,7 +186,7 @@
         sym := (spc name , '::' , string) asSymbolIfInterned.
         sym notNil ifTrue:[
             (Smalltalk at:sym) isBehavior ifTrue:[
-                ^ ('''' , string , ''' is a class in the ''' , spc name , ''' nameSpace.'
+                ^ ('''' , stringText , ''' is a class in the ''' , spc name , ''' nameSpace.'
                          , '\\It is only visible within this nameSpace.'
                          , '\Access from the outside is possible'
                          , '\by the special name ''' , spc name , '::' , string , '''.') withCRs
@@ -197,6 +199,15 @@
 
         tmp := self explainKnownSymbol:string inClass:aClass.
         tmp notNil ifTrue:[ ^ tmp].
+
+        "/ try with added colon ...
+        sel := string , ':'.
+        Symbol allInstancesDo:[:sym |
+            (sym startsWith:sel) ifTrue:[
+                tmp := self explainKnownSymbol:sym inClass:aClass.
+                tmp notNil ifTrue:[ ^ tmp].
+            ]
+        ].
 "/    ].
 
     "try for some obvious things"
@@ -238,7 +249,7 @@
     "try globals"
 
     (Smalltalk includesKey:sym) ifTrue:[
-        tmp := '''' , string , ''' is a global variable.'.
+        tmp := '''' , string asText allBold , ''' is a global variable.'.
         val := Smalltalk at:sym.
         val isBehavior ifTrue:[
             val name = string ifTrue:[
@@ -557,5 +568,5 @@
 !Explainer class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/Explainer.st,v 1.31 1999-03-23 12:34:15 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Explainer.st,v 1.32 1999-03-30 17:45:36 cg Exp $'
 ! !