Issue 3238 in pharo: Use Class instead of TextDiffBuilder in changelist

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Issue 3238 in pharo: Use Class instead of TextDiffBuilder in changelist

pharo
Status: Accepted
Owner: stephane.ducasse
Labels: Type-Squeak

New issue 3238 by stephane.ducasse: Use Class instead of TextDiffBuilder in  
changelist
http://code.google.com/p/pharo/issues/detail?id=3238

Should check how to invoke this method


- use ClassDiffBuilder for diffing class definitions and comments in  
ChangeList

=============== Diff against Tools-ul.275 ===============

Item was changed:
  ----- Method: ChangeList>>contentsDiffedFromCurrent (in category 'viewing  
access') -----
  contentsDiffedFromCurrent
        "Answer the contents diffed forward from current (in-memory) method  
version"

        | aChange aClass |
        listIndex = 0
                ifTrue: [^ ''].
        aChange := changeList at: listIndex.
         (aChange type == #method
         and: [(aClass := aChange methodClass) notNil
         and: [aClass includesSelector: aChange methodSelector]]) ifTrue:
                [^Utilities
                        methodDiffFor: aChange text
                        class: aClass
                        selector: aChange methodSelector
                        prettyDiffs: self showingPrettyDiffs].

        aChange type == #doIt ifTrue:
                [| tokens |
                 tokens := Scanner new scanTokens: aChange string.
                 ((tokens select:
                                [:substr| #(subclass: variableByteSubclass:  
variableWordSubclass:
                                                         
instanceVariableNames: classVariableNames: ) includes: substr])
                                        asSet size >= 3
                  and: [(aClass := Smalltalk at: tokens third ifAbsent: [])  
notNil
                  and: [aClass isBehavior]]) ifTrue:
+                       [^ClassDiffBuilder buildDisplayPatchFrom: aClass  
definition to: aChange string].
-                       [^TextDiffBuilder buildDisplayPatchFrom: aClass  
definition to: aChange string].

                (tokens size = 4
                 and: [tokens second == #class
                 and: [tokens third == #instanceVariableNames:
                 and: [(aClass := Smalltalk at: tokens first ifAbsent: [])  
notNil
                 and: [aClass isBehavior]]]]) ifTrue:
+                       [^ClassDiffBuilder buildDisplayPatchFrom: aClass  
class definition to: aChange string]].
-                       [^TextDiffBuilder buildDisplayPatchFrom: aClass  
class definition to: aChange string]].

        (aChange type == #classComment
        and: [(aClass := aChange commentClass) notNil]) ifTrue:
+               [^ClassDiffBuilder buildDisplayPatchFrom: aClass comment  
asString to: aChange string].
-               [^TextDiffBuilder buildDisplayPatchFrom: aClass comment  
asString to: aChange string].

        ^(changeList at: listIndex) text!