SourceCodeManagerUtilities.st
changeset 3327 a3200580a76f
parent 3325 944f6a6e66ff
child 3329 a4cbc797038b
child 3332 bc7ab41bb5bb
--- a/SourceCodeManagerUtilities.st	Sun Jun 30 10:11:02 2013 +0200
+++ b/SourceCodeManagerUtilities.st	Sun Jun 30 11:12:26 2013 +0200
@@ -3704,24 +3704,40 @@
      classChanges changesForThisClass definitionChangesForThisClass methodChangesForThisClass 
      allMethodChangesForThisClass modifiedMethodsForThisClass newMethodsForThisClass removedMethodsForThisClass
      initialLogStream printSelectors selectorsWithCommentOrFormattingChangeOnly
-     selectorsWithVariableChangeOnly 
-     removedSelectors categoryChanges categoryChangeSelectors|
+     selectorsWithVariableChangeOnly newSelectorsRemoved
+     removedSelectors categoryChanges categoryChangeSelectors additionalInfoPerChangedSelector|
 
     "/ a helper function
     printSelectors := 
-        [:what :selectors |
+        [:what :selectors :more |
+            |sel moreInfo|
+
             initialLogStream nextPutAll:(what,':').
             selectors size < 5 ifTrue:[
                 selectors size == 1 ifTrue:[
-                    initialLogStream 
-                        print: ' #'; printCR:(selectors first).
+                    sel := selectors first.
+                    initialLogStream nextPutAll: ' #'; nextPutAll:sel.
+                    more ifTrue:[
+                        (moreInfo := additionalInfoPerChangedSelector at:sel ifAbsent:nil) notNil ifTrue:[
+                            initialLogStream space; nextPutAll:moreInfo.
+                        ]
+                    ].
+                    initialLogStream cr.
                 ] ifFalse:[
                     initialLogStream cr.
-                    selectors asSortedCollection do:[:sel | initialLogStream tab; nextPutAll:'#'; nextPutLine:sel].
-                ]
+                    selectors asSortedCollection do:[:sel | 
+                        initialLogStream tab; nextPutAll:'#'; nextPutAll:sel. 
+                        more ifTrue:[
+                            (moreInfo := additionalInfoPerChangedSelector at:sel ifAbsent:nil) notNil ifTrue:[
+                                initialLogStream space; nextPutAll:moreInfo.
+                            ].
+                        ].
+                        initialLogStream cr
+                    ].
+                ].
             ] ifFalse:[
                 initialLogStream 
-                    print: (selectors size); printCR: ' methods'.
+                    print: (selectors size); nextPutAll: ' methods'.
             ].
         ].
 
@@ -3731,6 +3747,7 @@
                                 select:[:aChange | aChange className = aClass theNonMetaclass name
                                                    or:[aChange className = aClass theMetaclass name] ].
 
+    additionalInfoPerChangedSelector := Dictionary new.
     definitionChangesForThisClass := changesForThisClass reject:[:aChange | aChange isMethodChange].
     categoryChanges := changesForThisClass select:[:aChange | aChange isMethodCategoryChange]. 
     categoryChangeSelectors := categoryChanges collect:[:aChange | aChange changeSelector] as:Set.
@@ -3747,8 +3764,8 @@
                                 select:[:aChange | aChange previousVersion isNil].
     newSelectors := newMethodsForThisClass collect:[:aChange | aChange changeSelector] as:Set.
     
-    removedMethodsForThisClass := allMethodChangesForThisClass 
-                                select:[:aChange | aChange isMethodRemoveChange].
+    removedMethodsForThisClass := changesForThisClass 
+                                select:[:aChange | aChange isMethodRemoveChange and:[ aChange changeMethod isNil ]].
     removedSelectors := removedMethodsForThisClass collect:[:aChange | aChange changeSelector] as:Set.
 
     initialLogStream := '' writeStream.
@@ -3765,15 +3782,19 @@
     ].
 
     "/ added selectors?
+    newSelectorsRemoved := newSelectors select:[:sel | removedSelectors includes:sel].
+
+    newSelectors removeAllFoundIn:removedSelectors.
     newSelectors notEmpty ifTrue:[
-        printSelectors value:'added' value:newSelectors.
+        printSelectors value:'added' value:newSelectors value:false.
     ].
     modifiedSelectors removeAllFoundIn:newSelectors.
     categoryChangeSelectors removeAllFoundIn:newSelectors.
 
     "/ removed selectors?
+    removedSelectors removeAllFoundIn:newSelectorsRemoved.
     removedSelectors notEmpty ifTrue:[
-        printSelectors value:'removed' value:removedSelectors.
+        printSelectors value:'removed' value:removedSelectors value:false.
     ].
     modifiedSelectors removeAllFoundIn:removedSelectors.
     categoryChangeSelectors removeAllFoundIn:removedSelectors.
@@ -3786,7 +3807,8 @@
         "/ check for format/comment change
         RBParser notNil ifTrue:[
             modifiedSelectors do:[:eachSelector |
-                |oldest newest oldMethod newMethod oldTree newTree variableMapping unchangedVariables|
+                |oldest newest oldMethod newMethod oldTree newTree 
+                 variableMapping selectorMapping unchangedVariables unchangedSelectors|
 
                 (newSelectors includes:eachSelector) ifFalse:[
                     oldest := allMethodChangesForThisClass detect:[:change | change changeSelector = eachSelector].
@@ -3807,13 +3829,34 @@
                                 ((variableMapping associations count:[:assoc | assoc key ~= assoc value]) == 0) ifTrue:[
                                     selectorsWithCommentOrFormattingChangeOnly add:eachSelector.
                                 ] ifFalse:[
-                                    "/ check, if a global has changed
+                                    "/ check, if a global has changed (aka sends to another global)
                                     ((variableMapping keys contains:[:var | var first isUppercase])
                                     or:[ (variableMapping values contains:[:var | var first isUppercase]) ]) ifFalse:[
                                         selectorsWithVariableChangeOnly add:eachSelector.
                                     ].
                                 ].
                             ].
+                        ] ifFalse:[
+                            selectorMapping := Dictionary new.
+                            (oldTree equalTo:newTree withSelectorMapping: selectorMapping) ifTrue:[
+                                unchangedSelectors := selectorMapping keys select:[:k | (selectorMapping at:k) = k].
+                                selectorMapping removeAllKeys:unchangedSelectors.
+                                (selectorMapping notEmpty and:[selectorMapping size <= 2]) ifTrue:[
+                                    additionalInfoPerChangedSelector at:eachSelector put:(
+                                        String streamContents:[:s |
+                                            |first|
+                        
+                                            s nextPutAll:'('.
+                                            first := true.
+                                            selectorMapping keysAndValuesDo:[:selOld :selNew | 
+                                                first ifFalse:[s nextPutAll:', '].
+                                                s print:('send #',selNew,' instead of #',selOld).
+                                                first := false.
+                                            ].
+                                            s nextPutAll:')'.
+                                        ]).
+                                ]
+                            ]
                         ].
                     ].
                 ]
@@ -3824,17 +3867,17 @@
         modifiedSelectors removeAllFoundIn:selectorsWithVariableChangeOnly.
 
         (selectorsWithCommentOrFormattingChangeOnly notEmpty) ifTrue:[
-            printSelectors value:'comment/format in' value:selectorsWithCommentOrFormattingChangeOnly.
+            printSelectors value:'comment/format in' value:selectorsWithCommentOrFormattingChangeOnly value:false.
         ].
         (selectorsWithVariableChangeOnly notEmpty) ifTrue:[
-            printSelectors value:'variable renamed in' value:selectorsWithVariableChangeOnly.
+            printSelectors value:'variable renamed in' value:selectorsWithVariableChangeOnly value:false.
         ].
         (modifiedSelectors notEmpty) ifTrue:[
-            printSelectors value:'changed' value:modifiedSelectors.
+            printSelectors value:'changed' value:modifiedSelectors value:true.
         ].
     ].
     categoryChanges notEmpty ifTrue:[
-        printSelectors value:'category of' value:categoryChangeSelectors.
+        printSelectors value:'category of' value:categoryChangeSelectors value:false.
     ].
     ^ initialLogStream contents
 
@@ -3881,10 +3924,10 @@
 !SourceCodeManagerUtilities class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic3/SourceCodeManagerUtilities.st,v 1.284 2013-06-29 11:27:38 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/SourceCodeManagerUtilities.st,v 1.285 2013-06-30 09:12:26 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic3/SourceCodeManagerUtilities.st,v 1.284 2013-06-29 11:27:38 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/SourceCodeManagerUtilities.st,v 1.285 2013-06-30 09:12:26 cg Exp $'
 ! !