Browser support: method now show its namespace jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Thu, 01 Jul 2010 17:54:44 +0100
branchjv
changeset 17771 d6d2b68253cf
parent 17770 60bc0bab4e10
child 17772 6e0b3c06c364
Browser support: method now show its namespace
Method.st
UserPreferences.st
--- a/Method.st	Sat Jun 19 14:38:38 2010 +0100
+++ b/Method.st	Thu Jul 01 17:54:44 2010 +0100
@@ -1701,6 +1701,130 @@
     "Modified: / 12-10-2006 / 20:32:22 / cg"
 !
 
+printStringForBrowserWithSelector:selector inClass:aClass
+    "return a printString to represent myself to the user in a browser.
+     Defined here to allow for browsers to deal with nonStandard pseudoMethods"
+
+    |s privInfo moreInfo p info n cls ns currentChangeSet isInChangeSet mthdPackage
+     userPreferences shownSelector suppressPackage timeRounded|
+
+    moreInfo := ''.
+    privInfo := ''.
+    userPreferences := UserPreferences current.
+
+    ns := self nameSpace.
+    (ns notNil and:[ns isNameSpace]) ifTrue:[
+        moreInfo := moreInfo , 
+            ((' (* %1 *)' bindWith: ns name) asText emphasisAllAdd:
+                userPreferences emphasisForNamespacedCode)
+
+    ].
+
+    self isWrapped ifTrue:[
+        (MessageTracer isCounting:self) ifTrue:[
+            (MessageTracer isCountingMemoryUsage:self) ifTrue:[
+                moreInfo := moreInfo , (' (mem usage avg: %1 bytes)' bindWith:(MessageTracer memoryUsageOfMethod:self) printString allBold).
+            ] ifFalse:[
+                moreInfo := moreInfo , (' (called %1 times)' bindWith:(MessageTracer executionCountOfMethod:self) printString allBold).
+            ]
+        ] ifFalse:[
+            (MessageTracer isTiming:self) ifTrue:[
+                info := MessageTracer executionTimesOfMethod:self.
+                ((n := info count) == 0) ifTrue:[
+                    moreInfo := moreInfo , (' (cnt: %1)' bindWith:n)
+                ] ifFalse:[
+                    timeRounded := [:millis |
+                        |rnd|
+                        rnd := (millis > 100)
+                                 ifTrue:[ 1 ]
+                                 ifFalse:[
+                                     (millis > 10)
+                                        ifTrue:[ 0.1 ]
+                                        ifFalse:[
+                                            (millis > 1)
+                                                ifTrue:[ 0.01 ]
+                                                ifFalse:[ 0.001 ]]].
+                        millis roundTo:rnd
+                    ].
+
+                    (n == 1 or:[ info avgTimeRounded = info minTimeRounded  ]) ifTrue:[
+                        moreInfo := moreInfo ,
+                                    (' (t: %1ms cnt: %2)'
+                                        bindWith:((timeRounded value:info avgTimeRounded) printString allBold)
+                                        with:n)
+                    ] ifFalse:[
+                        moreInfo := moreInfo ,
+                                    (' (avg: %1ms min: %2 max: %3 cnt: %4)'
+                                        bindWith:((timeRounded value:info avgTimeRounded) printString allBold)
+                                        with:((timeRounded value:info minTimeRounded) printString)
+                                        with:((timeRounded value:info maxTimeRounded) printString)
+                                        with:n)
+                    ].
+                ].
+            ] ifFalse:[
+                moreInfo := ' !!'
+            ]
+        ].
+    ].
+    p := self privacy.
+
+    p ~~ #public ifTrue:[
+        privInfo := (' (* ' , p , ' *)') allItalic.
+    ].
+
+"/    self isInvalid ifTrue:[
+"/        moreInfo := ' (** not executable **)'.
+"/    ].
+
+    (self isLazyMethod not and:[self isUnloaded]) ifTrue:[
+        moreInfo := ' (** unloaded **)'
+    ].
+
+    privInfo size ~~ 0 ifTrue:[
+        moreInfo := privInfo , ' ' , moreInfo
+    ].
+
+    s := shownSelector := (self selectorPrintStringInBrowserFor:selector class:aClass).
+
+    (cls := aClass) isNil ifTrue:[
+        cls := self containingClass
+    ].
+
+    currentChangeSet := ChangeSet current.
+    isInChangeSet := currentChangeSet includesChangeForClass:cls selector:selector.
+
+    isInChangeSet ifTrue:[
+        s := s asText emphasisAllAdd:(userPreferences emphasisForChangedCode)
+    ].
+
+    (cls isNil or:[(mthdPackage := self package) ~= cls package]) ifTrue:[
+        suppressPackage := false.
+        mthdPackage = PackageId noProjectID ifTrue:[
+            mthdPackage := '+'.
+            "/ suppressPackage := true
+        ].
+        suppressPackage ifFalse:[
+            p := ' [' , (mthdPackage ? '?') allItalic , '] '.
+            p := p asText emphasisAllAdd:(userPreferences emphasisForDifferentPackage).
+            s := s , ' ' , p
+        ].
+    ].
+
+    moreInfo size == 0 ifTrue:[^ s].
+
+    s := shownSelector , moreInfo.
+
+    self isInvalid ifTrue:[
+        s := s asText emphasizeAllWith:(userPreferences emphasisForObsoleteCode).
+    ].
+    ^ s
+
+    "Modified: / 23-01-1998 / 13:15:15 / stefan"
+    "Created: / 05-02-2000 / 22:55:56 / cg"
+    "Modified: / 05-03-2007 / 16:18:53 / cg"
+    "Modified: / 01-07-2010 / 18:40:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 whoString
     "return a string as className>>selector, if this is not an unbound
      method. Otherwise return 'unbound'. Used with debugging."
@@ -3179,16 +3303,15 @@
 !Method class methodsFor:'documentation'!
 
 version
-    ^ '$Id: Method.st 10527 2010-06-16 20:12:05Z vranyj1 $'
+    ^ '$Id: Method.st 10533 2010-07-01 16:54:44Z vranyj1 $'
 !
 
 version_CVS
-    ^ 'Header: /cvs/stx/stx/libbasic/Method.st,v 1.350 2010-05-04 15:49:48 cg Exp §'
+    ^ 'Header: /cvs/stx/stx/libbasic/Method.st,v 1.350 2010/05/04 15:49:48 cg Exp §'
 !
 
 version_SVN
-    ^ '$Id: Method.st 10527 2010-06-16 20:12:05Z vranyj1 $'
+    ^ '$Id: Method.st 10533 2010-07-01 16:54:44Z vranyj1 $'
 ! !
 
 Method initialize!
-
--- a/UserPreferences.st	Sat Jun 19 14:38:38 2010 +0100
+++ b/UserPreferences.st	Thu Jul 01 17:54:44 2010 +0100
@@ -1706,6 +1706,29 @@
     "
 !
 
+emphasisForNamespacedCode
+    "the emphasis for changed code (in changeSet) in the browser"
+
+    |emp|
+
+    emp := self at:#emphasisForNamespacedCode ifAbsent:nil.
+    emp isNil ifTrue:[
+        emp := #color->Color green darkened.
+        "/ emp := Array with:#bold with:emp.
+        "/ emp := #color->Color blue darkened.
+        self at:#emphasisForNamespacedCode put:emp.
+    ].
+    ^ emp
+
+    "
+     self allInstancesDo:[:pref |pref at:#emphasisForNamespacedCode put:nil]. 
+     UserPreferences current emphasisForNamespacedCode. 
+     UserPreferences current at:#emphasisForNamespacedCode put:nil.
+    "
+
+    "Created: / 01-07-2010 / 18:39:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 emphasisForObsoleteCode
     |emp|
 
@@ -3245,15 +3268,13 @@
 !UserPreferences class methodsFor:'documentation'!
 
 version
-    ^ '$Id: UserPreferences.st 10527 2010-06-16 20:12:05Z vranyj1 $'
+    ^ '$Id: UserPreferences.st 10533 2010-07-01 16:54:44Z vranyj1 $'
 !
 
 version_CVS
-    ^ '§Header: /cvs/stx/stx/libbasic/UserPreferences.st,v 1.249 2010-06-11 14:33:14 cg Exp §'
+    ^ '§Header: /cvs/stx/stx/libbasic/UserPreferences.st,v 1.249 2010/06/11 14:33:14 cg Exp §'
 !
 
 version_SVN
-    ^ '$Id: UserPreferences.st 10527 2010-06-16 20:12:05Z vranyj1 $'
+    ^ '$Id: UserPreferences.st 10533 2010-07-01 16:54:44Z vranyj1 $'
 ! !
-
-