SourceCodeManagerUtilities.st
changeset 1994 eccaf18ff7a1
parent 1988 0294d9beb4c0
child 1995 f832f7ec6ccf
--- a/SourceCodeManagerUtilities.st	Thu May 08 13:45:05 2008 +0200
+++ b/SourceCodeManagerUtilities.st	Thu May 29 11:54:00 2008 +0200
@@ -2700,100 +2700,119 @@
         #error
         (and maybe more in the future)"
 
-    |badStuff whatIsBad msg answer labels values defaultAnswer dontShowAgain|
+    |badStuff whatIsBad msg answer labels values defaultAnswer dontShowAgain
+     methodsWithBadStuff resources|
+
+    resources := Dialog classResources.
 
     badStuff := #(
-        ( halt         'sent of #halt (use for debugging only) - better use #error:''some message''' )
-        ( halt:        'sent of #halt: (use for debugging only) - better use #error:' )
+        ( halt         'sent of #halt (use for debugging only) - better use #error:''some message'' or #breakPoint:')
+        ( halt:        'sent of #halt: (use for debugging only) - better use #error: or #breakPoint:')
         ( error        'sent of #error without descriptive message - better use #error:''some message''' )
     ).
 
+    methodsWithBadStuff := Set new.
     whatIsBad := Set new.
     aClass theNonMetaclass instAndClassSelectorsAndMethodsDo:[:sel :mthd |
-        |setOfLiterals setOfSentMessages|
+        |setOfLiterals setOfSentMessages methodIsBad|
+
+        methodIsBad := false.
 
         setOfLiterals := mthd literals.  "/ try without parsing first.
         (badStuff contains:[:eachEntry | setOfLiterals includes:eachEntry first]) ifTrue:[
             setOfSentMessages := mthd messagesSent.
-            badStuff do:[:eachEntry |
+            badStuff do:[:eachEntry | 
                 (setOfSentMessages includes:eachEntry first) ifTrue:[
-                    whatIsBad add:eachEntry second
+                    whatIsBad add:eachEntry second.
+                    methodsWithBadStuff add:mthd.
                 ]
             ].
         ].
     ].
-    whatIsBad notEmpty ifTrue:[
-        (YesToAllQuery notNil and:[YesToAllQuery isHandled]) ifTrue:[
-            answer := YesToAllQuery query.
-            answer notNil ifTrue:[ ^ answer ].
-        ].
-
-        msg := '%1 contains the following  (considered bad style) message sends:\\'.
-        whatIsBad do:[:each |
-            msg := msg , '   ' , each , '\'
-        ].
-        msg := msg , '\\' , 'Do you really want to checkIn the %1 class ?'.
-        msg := msg bindWith:aClass name.
-
-        (YesToAllNotification notNil and:[YesToAllNotification isHandled]) ifTrue:[
-            labels := #('Cancel All' 'Cancel' 'No to All' 'No' 'Yes to All' 'Yes') "#('Yes' 'Yes to All' 'No' 'No to All' 'Cancel')".
-            values := #(#cancelAll nil #noToAll false #yesToAll true) "#(true #yesToAll false #noToAll nil)".
-            defaultAnswer := #yesToAll.
-        ] ifFalse:[
-            labels := #('No' 'Yes').
-            values := #(false true).
-            defaultAnswer := true.
-        ].
+    whatIsBad isEmpty ifTrue:[^ true].
+
+    (YesToAllQuery notNil and:[YesToAllQuery isHandled]) ifTrue:[
+        answer := YesToAllQuery query.
+        answer notNil ifTrue:[ ^ answer ].
+    ].
+
+    msg := resources string:'%1 contains the following (considered bad style) message sends:' with:aClass name.
+    msg := msg , '\\'.
+    whatIsBad do:[:each |
+        msg := msg , '   ' , each , '\'
+    ].
+    msg := msg , '\'.
+    methodsWithBadStuff size == 1 ifTrue:[
+        msg := msg , (resources string:'In %1.' 
+                        with:methodsWithBadStuff anElement whoString allBold).
+    ] ifFalse:[
+        msg := msg , (resources string:'In %1 and %2 other methods.' 
+                        with:methodsWithBadStuff anElement whoString allBold 
+                        with:methodsWithBadStuff size-1).
+    ].
+    msg := msg , '\\' , (resources string:'Do you really want to checkIn the %1 class ?' with:aClass name).
+
+    (YesToAllNotification notNil and:[YesToAllNotification isHandled]) ifTrue:[
+        labels := #('Cancel All' 'Cancel' 'No to All' 'No' 'No, Browse' 'Yes to All' 'Yes') "#('Yes' 'Yes to All' 'No' 'No to All' 'Cancel')".
+        values := #(#cancelAll nil #noToAll #noBrowse false #yesToAll true) "#(true #yesToAll false #noToAll nil)".
+        defaultAnswer := #yesToAll.
+    ] ifFalse:[
+        labels := #('No' 'No, Browse' 'Yes').
+        values := #(false #noBrowse true).
+        defaultAnswer := true.
+    ].
 
 "/        AbortAllOperationRequest isHandled ifTrue:[
 "/            labels := #('Cancel All') , labels.
 "/            values := #(#cancelAll) , values.
 "/        ].
 
-        DialogBox aboutToOpenBoxNotificationSignal handle:[:ex |
-            |box|
-
-            checkAgainHolder isValueModel ifTrue:[
-                dontShowAgain := checkAgainHolder value not asValue.
-                box := ex parameter.
-                box verticalPanel 
-                    add:(CheckBox label:'Do not show this Dialog again.'
-                                  model:dontShowAgain).
-            ].
-            ex proceed.
-        ] do:[
-            answer := OptionBox 
-                          request:msg withCRs
-                          label:'Really checkIn ?'
-                          image:(InfoBox iconBitmap)
-                          buttonLabels:labels
-                          values:values
-                          default:defaultAnswer
-                          onCancel:nil.
+    DialogBox aboutToOpenBoxNotificationSignal handle:[:ex |
+        |box|
+
+        checkAgainHolder isValueModel ifTrue:[
+            dontShowAgain := checkAgainHolder value not asValue.
+            box := ex parameter.
+            box verticalPanel 
+                add:(CheckBox label:(resources string:'Do not show this Dialog again.')
+                              model:dontShowAgain).
         ].
-        answer isNil ifTrue:[
-            AbortSignal raise.
-        ].
-
-        dontShowAgain notNil ifTrue:[
-            checkAgainHolder value:dontShowAgain value not 
-        ].
-
-        answer == #cancelAll ifTrue:[
-            AbortAllSignal raise.
-        ].
-
-        answer == #yesToAll ifTrue:[
-            YesToAllNotification queryWith:true.
-            ^ true
-        ].
-        answer == #noToAll ifTrue:[
-            YesToAllNotification queryWith:false.
-            ^ false
-        ].
-        ^ answer
+        ex proceed.
+    ] do:[
+        answer := OptionBox 
+                      request:msg withCRs
+                      label:(resources string:'Really CheckIn ?')
+                      image:(InfoBox iconBitmap)
+                      buttonLabels:(resources array:labels)
+                      values:values
+                      default:defaultAnswer
+                      onCancel:nil.
+    ].
+    answer isNil ifTrue:[
+        AbortSignal raise.
+    ].
+
+    dontShowAgain notNil ifTrue:[
+        checkAgainHolder value:dontShowAgain value not 
     ].
-    ^ true.
+
+    answer == #noBrowse ifTrue:[
+        UserPreferences browserClass browseMethods:methodsWithBadStuff title:'Methods with Bad Stuff'.
+        YesToAllNotification queryWith:false.
+        ^ false
+    ].
+    answer == #cancelAll ifTrue:[
+        AbortAllSignal raise.
+    ].
+    answer == #yesToAll ifTrue:[
+        YesToAllNotification queryWith:true.
+        ^ true
+    ].
+    answer == #noToAll ifTrue:[
+        YesToAllNotification queryWith:false.
+        ^ false
+    ].
+    ^ answer
 
     "
      self checkAndWarnAboutBadMessagesInClass:(SourceCodeManagerUtilities)  
@@ -2893,5 +2912,5 @@
 !SourceCodeManagerUtilities class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic3/SourceCodeManagerUtilities.st,v 1.164 2008-02-04 12:22:47 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/SourceCodeManagerUtilities.st,v 1.165 2008-05-29 09:54:00 cg Exp $'
 ! !