Explainer.st
changeset 4187 a315b2137a68
parent 4177 43a98615134a
child 4197 3ea2e07f886c
equal deleted inserted replaced
4186:1a3f5a9938fa 4187:a315b2137a68
   774      used as selector within a string, or if a variable is named like a
   774      used as selector within a string, or if a variable is named like a
   775      message selector. I.e. the explanation should be context sensitive.
   775      message selector. I.e. the explanation should be context sensitive.
   776      Also, there could be much more detailed explanations."
   776      Also, there could be much more detailed explanations."
   777 
   777 
   778     |explainer variables c string explanation tmp1
   778     |explainer variables c string explanation tmp1
   779      spc sym sel stringText cls clsName val valString|
   779      spc sym sel stringText cls clsName val valString color|
   780 
   780 
   781     string := someText string withoutSeparators.
   781     string := someText string withoutSeparators.
   782     string isEmpty ifTrue:[ ^ nil ].
   782     string isEmpty ifTrue:[ ^ nil ].
   783 
   783 
   784     stringText := string allBold.
   784     stringText := string allBold.
   830 
   830 
   831     string isWideString ifFalse:[
   831     string isWideString ifFalse:[
   832         "classvars"
   832         "classvars"
   833         c := explainer inWhichClassIsClassVar:string.
   833         c := explainer inWhichClassIsClassVar:string.
   834         c notNil ifTrue:[
   834         c notNil ifTrue:[
       
   835             val := c theNonMetaclass classVarAt:string. "/ Smalltalk at:(clsName , ':' , string) asSymbol.
       
   836             valString := self valueStringFor:val.
       
   837 
       
   838             val == true ifTrue:[
       
   839                 color := Color green darkened.
       
   840             ] ifFalse:[
       
   841                 val == false ifTrue:[
       
   842                     color := Color red darkened
       
   843                 ] ifFalse:[
       
   844                     val == nil ifTrue:[
       
   845                         color := Color darkGrey
       
   846                     ].    
       
   847                 ].    
       
   848             ].    
       
   849             color notNil ifTrue:[
       
   850                 stringText := stringText withColor:color.
       
   851                 valString := valString withColor:color. 
       
   852             ].
       
   853             
   835             clsName := c name.
   854             clsName := c name.
   836             shortText ifTrue:[
   855             shortText ifTrue:[
   837                 clsName := self asClassLink:clsName.
   856                 clsName := self asClassLink:clsName.
   838                 stringText := stringText , ': a classVar in ' , clsName
   857                 stringText := stringText , ': a classVar in ' , clsName
   839             ] ifFalse:[
   858             ] ifFalse:[
   840                 stringText := stringText , ': a class variable in ' , clsName
   859                 stringText := stringText , ': a class variable in ' , clsName
   841             ].
   860             ].
   842 
   861 
   843             val := c theNonMetaclass classVarAt:string. "/ Smalltalk at:(clsName , ':' , string) asSymbol.
       
   844             valString := self valueStringFor:val.
       
   845             ^ stringText , ' (' , valString , ').'
   862             ^ stringText , ' (' , valString , ').'
   846         ].
   863         ].
   847 
   864 
   848         "private classes"
   865         "private classes"
   849         c := aClass theNonMetaclass.
   866         c := aClass theNonMetaclass.
   967     ^ 'Sorry, I cannot explain this (could not figure out what this is).
   984     ^ 'Sorry, I cannot explain this (could not figure out what this is).
   968 Please try again with an individual token selected.'
   985 Please try again with an individual token selected.'
   969 
   986 
   970     "Created: / 03-12-1995 / 12:47:37 / cg"
   987     "Created: / 03-12-1995 / 12:47:37 / cg"
   971     "Modified: / 16-04-1997 / 12:46:11 / stefan"
   988     "Modified: / 16-04-1997 / 12:46:11 / stefan"
   972     "Modified: / 28-07-2017 / 10:46:51 / cg"
   989     "Modified: / 23-08-2017 / 12:44:12 / cg"
   973 !
   990 !
   974 
   991 
   975 explainGlobal:string inClass:aClass short:shortText
   992 explainGlobal:string inClass:aClass short:shortText
   976     "return an explanation or nil"
   993     "return an explanation or nil"
   977 
   994