# HG changeset patch # User Claus Gittinger # Date 1582634850 -3600 # Node ID 023f2d14b83dd5d5f74aaba499dae69d574cb7b5 # Parent 593fe39d4cf1416fe06139e2104a1b0eee1e9386 #REFACTORING by cg class: Explainer class withCRs eliminated hanged: #explain:in:forClass:short: #explainGlobalOrPoolVariable:inClass:short: #explainSelector:inClass:short: #fetchCommentOfMethod: diff -r 593fe39d4cf1 -r 023f2d14b83d Explainer.st --- a/Explainer.st Tue Feb 25 13:41:08 2020 +0100 +++ b/Explainer.st Tue Feb 25 13:47:30 2020 +0100 @@ -1,3 +1,5 @@ +"{ Encoding: utf8 }" + " COPYRIGHT (c) 1993 by Claus Gittinger All Rights Reserved @@ -290,7 +292,7 @@ implMethod := implClass compiledMethodAt:selector. clsName := implClass name. clsName := self asLink:clsName to:(self actionToBrowseClass:implClass selector:selector). - "/ info := '%1 » %2' bindWith:clsName "allBold" with:selectorString. + "/ info := '%1 » %2' bindWith:clsName "allBold" with:selectorString. info := '%1 %2' bindWith:clsName with:(implMethod methodDefinitionTemplateForSelector:selector). info := self asLink:info to:(action1 := self actionToBrowseClass:implClass selector:selector info:nil). @@ -573,12 +575,11 @@ "retrieve the comment of a method (if possible and there is one; otherwise, return nil)" - |methodSource methodComment lines maxNumLines| + |methodComment lines maxNumLines| self withWaitCursorDo:[ SourceCodeManagerError handle:[:ex | ] do:[ - methodSource := mthd source. methodComment := mthd comment ]. ]. @@ -587,17 +588,12 @@ lines := methodComment asStringCollection. maxNumLines := 1. -true ifTrue:[ + methodComment := (lines copyToMax:maxNumLines) asString. maxNumLines := 5. -] ifFalse:[ - methodComment := lines first. - methodComment := methodComment withoutSeparators. - (methodComment endsWith:',') ifTrue:[ methodComment := methodComment copyButLast:1]. - methodComment := methodComment withoutSeparators. -]. + (lines size > maxNumLines) ifTrue:[ - methodComment := methodComment , '\...' withCRs + methodComment := methodComment , c'\n...' ]. ^ (methodComment) withColor:(UserPreferences current commentColor). @@ -1015,7 +1011,7 @@ "/ some are both known as syntax AND as selector (for example: #| ) tmp1 := self explainSyntax:string short:shortText. tmp1 notNil ifTrue:[ - ^ tmp1 , '\\also:\\' withCRs , explanation + ^ tmp1 , c'\n\nalso:\n\n' , explanation ]. ]. ^ explanation @@ -1163,7 +1159,7 @@ explanation := explanation , (val isLoaded ifTrue:['a'] ifFalse:['an autoloaded']). explanation := explanation , (val isSharedPool ifTrue:[' sharedPool'] ifFalse:[' class']). explanation := explanation , ' categorized as "' , val category , '"'. - explanation := explanation , '\' withCRs , 'in the "' , val package , '" package.'. + explanation := explanation , c'\n' , 'in the "' , val package , '" package.'. (doc := val commentOrDocumentationString) notEmptyOrNil ifTrue:[ doc := doc asStringCollection. doc size > 25 ifTrue:[ @@ -1171,7 +1167,7 @@ doc add:''; add:' ... '. ]. doc := doc asString withColor:(UserPreferences current commentColor). - explanation := explanation,'\\' withCRs,val name,'''s documentation:\'withCRs, doc + explanation := explanation,'\n\n',val name,'''s documentation:\n', doc ]. ^ explanation. ]. @@ -1421,7 +1417,7 @@ s2 := ('Instances of ''' , aClassOrNil name , ''' respond to #') , selector "allBold" , '.'. shortText ifFalse:[ s2 := '\\' , s2 - , '\- inherited from ' withCRs + , c'\n- inherited from ' , (aClassOrNil whichClassIncludesSelector:selector) name "allBold". ]. firstImplementingClass := (aClassOrNil whichClassIncludesSelector:selector) @@ -1612,7 +1608,7 @@ ]. ]. cm notNil ifTrue:[ - cm := ('%1 says:\' withCRs bindWith:(self asClassLink:classProvidingComment name)),cm. + cm := (c'%1 says:\n' bindWith:(self asClassLink:classProvidingComment name)),cm. "/ msg := msg,(msg last isSeparator ifTrue:[''] ifFalse:[' ']),cm msg := msg,(Character cr),cm @@ -2863,7 +2859,7 @@ to:(self actionToOpenMethodFinderFor:sel)) with:(self asLink:inheritedClass name "allBold" - info:('Browse %1 » %2' bindWith:inheritedClass name with:sel) + info:('Browse %1 » %2' bindWith:inheritedClass name with:sel) to:(self actionToBrowseClass:inheritedClass selector:sel)). ].