QwalKeko,
a History Querying Tool
         Reinout Stevens
       resteven@vub.ac.be
        @ReinoutStevens
Context




  Program
Comprehension

                2
Was this method pulled up?
Who introduced
  this class?
                                  Who has made changes to
                                        my classes?

         History Questions
                                   How often is this method
Why were these changes                    changed?
     introduced?         Template-based Reconstruction of Complex Refactorings
                         Kyle Prete, Napol Rachatasumrit, Nikita Sudan, Miryung Kim
                         International Conference on Software Maintenance (ICSM), p.1--10, 2010

                         Using Information Fragments to Answer the Questions Developers Ask
                         Thomas Fritz and Gail C. Murphy
                         International Conference on Software Engineering (ICSE), p.175--184, 2010
                                3
Was this method pulled up?
Who introduced
  this class?
                                  Who has made changes to
                                        my classes?

         History Questions
                                   How often is this method
Why were these changes                    changed?
     introduced?         Template-based Reconstruction of Complex Refactorings
                         Kyle Prete, Napol Rachatasumrit, Nikita Sudan, Miryung Kim
                         International Conference on Software Maintenance (ICSM), p.1--10, 2010

                         Using Information Fragments to Answer the Questions Developers Ask
                         Thomas Fritz and Gail C. Murphy
                         International Conference on Software Engineering (ICSE), p.175--184, 2010
                                3
Pulled up Method
1   pull_up_method(fShortName, tChildFullName, tParentFullName) :-
2     move_method(fShortName, tChildFullName, tParentFullName) ^
3     before_subtype(tParentFullName, tChildFullName)




                               Template-based Reconstruction of Complex Refactorings
                               Kyle Prete, Napol Rachatasumrit, Nikita Sudan, Miryung Kim
                               International Conference on Software Maintenance (ICSM), p.1--10, 2010

                                      4
Pulled up Method
1   pull_up_method(fShortName, tChildFullName, tParentFullName) :-
2     move_method(fShortName, tChildFullName, tParentFullName) ^
3     before_subtype(tParentFullName, tChildFullName)




1   move_method(mShortName, t1Fullname, t2FullName) :-
2     deleted_method(mFullName, mShortName, t1FullName) ^
3     added_method(newmName, mShortName, t2FullName) ^
4     similarbody(newmName, newmBody, mFullName, mBody)




                               Template-based Reconstruction of Complex Refactorings
                               Kyle Prete, Napol Rachatasumrit, Nikita Sudan, Miryung Kim
                               International Conference on Software Maintenance (ICSM), p.1--10, 2010

                                      4
Version Control Systems
                          Version   Version
                            3a        4a




                                              Version
  Version 1   Version 2                          5




                          Version   Version
                            3b        4b




                          5
History Query Tool
        Pr                Graph Query
          og                Language
            ra
         La m




                                                     od ry
           ng Q           Move through the




                                                       sto
                                                       el
             ua ue        version graph




                                                  Hi
               ge ry




                                                    M
                                             Source code of each version
Specify characteristics                      Commit information
in a single version                          Entity tracking
                                             ...




                                 6
QwalKeko
Pr             Graph Query
  og             Language
    ra
 La m




                              od ry
   ng Q           Qwal




                                sto
                                el
     ua ue




                             Hi
       ge ry




                             M
 Ekeko                        +




                    7
Applicative LMP
... specify code characteristics through Ekeko relations,
leave search to core.logic
                            collection of all substitutions for ?s and ?e


       (run* [?s ?e]
           (ast :ReturnStatement ?s)
           (has :expression ?s ?e)
           (ast :NullLiteral ?e))


                             such that the following Ekeko relations hold:
                                  ast/2 holds for :ReturnStatement, ?s        ?e is the value of the
                                                                                     property
                                  has/3 holds for :expression, ?s, and ?e
                                                                              named :expression of
([?s1 ?e2] ... [?sn ?en])         ast/2 holds for :NullLiteral, ?e                 ASTNode ?s


                ([#<ReturnStatement return null;
                  #<NullLiteral null>]
                 ...
                                                                        actual search performed by
                 [#<ReturnStatement return null;                        core.logic
                  #<NullLiteral null>])     8
Qwal
               foo       bar      baz




1   (run* [?end]
2     (qwal graph :foo ?end
3       []
4       (qcurrent [curr] (has-info curr :foo))




                         9
Qwal
               foo       bar      baz




1   (run* [?end]
2     (qwal graph :foo ?end
3       []
4       (qcurrent [curr] (has-info curr :foo))
5       q=>
6       (qcurrent [curr] (has-info curr :bar))




                         9
Qwal
               foo          bar      baz




1   (run* [?end]
2     (qwal graph    :foo ?end
3       []
4       (qcurrent    [curr] (has-info curr :foo))
5       q=>
6       (qcurrent    [curr] (has-info curr :bar))
7       q=>
8       (qcurrent    [curr] (has-info curr :baz)))




                            9
Introduced Subclasses
  1   (qwal graph start ?end [?parent ?child]
  2     (qin-current
  3       (ast :TypeDeclaration ?parent))
  4     (q=>+) ;;skip >= 1 versions
  5     (qin-current
  6       (subclass ?parent ?child)
  7       (introduced ?child)))




                      10
Same Predicate
(defn same [?entity ?other-entity]
  ...)

       Ground in a previous version

                   Ground in current version



                   11
Same Predicate
(defn same [?entity ?other-entity]
  ...)


       1   (defn introduced [?entity]
       2     (fresh [?same]
       3       q<=
       4       (not (same ?entity ?same)))




                         12
Recall...
1   pull_up_method(fShortName, tChildFullName, tParentFullName) :-
2     move_method(fShortName, tChildFullName, tParentFullName) ^
3     before_subtype(tParentFullName, tChildFullName)




1   move_method(mShortName, t1Fullname, t2FullName) :-
2     deleted_method(mFullName, mShortName, t1FullName) ^
3     added_method(newmName, mShortName, t2FullName) ^
4     similarbody(newmName, newmBody, mFullName, mBody)




                                   13
Pulled up Method
1       (defn pulled-up [?method ?pulled]
2         (fresh [?m-class ?p-class]
3           (method-moved ?method ?pulled)
4           (declaring-class ?method ?m-class)
5           (declaring-class ?pulled ?p-class)
6           (superclass ?m-class ?p-class)))


    1   (defn method-moved [?moved ?to]
    2     (removed ?moved) ;;implemented using same
    3     (ast :MethodDeclaration ?to)
    4     (== ?moved ?to) ;;unify when same signature
    5     (has-similar-body ?moved ?to)))




                           14
Pulled up Method

1 (qwal graph root ?end [?method ?pulled]
2   (qin-current
3     (ast :MethodDeclaration ?method))
4   q=> ;;go to next version
5   (qin-current
6     (pulled-up ?method ?pulled)))




                     15
Generalized Rule

1 (qwal graph root ?end [?method ?pulled]
2   (qin-current
3     (ast :MethodDeclaration ?method))
4   (q=>+) ;;skip >=1 versions
5   (qin-current
6     (pulled-up ?method ?pulled)))




                     16
Questions

               Reinout Stevens
             resteven@vub.ac.be
               @ReinoutStevens
http://github.com/ReinoutStevens/damp.qwal
  http://github.com/cderoove/damp.ekeko




                    17

QwalKeko, a History Querying Tool

  • 1.
    QwalKeko, a History QueryingTool Reinout Stevens resteven@vub.ac.be @ReinoutStevens
  • 2.
  • 3.
    Was this methodpulled up? Who introduced this class? Who has made changes to my classes? History Questions How often is this method Why were these changes changed? introduced? Template-based Reconstruction of Complex Refactorings Kyle Prete, Napol Rachatasumrit, Nikita Sudan, Miryung Kim International Conference on Software Maintenance (ICSM), p.1--10, 2010 Using Information Fragments to Answer the Questions Developers Ask Thomas Fritz and Gail C. Murphy International Conference on Software Engineering (ICSE), p.175--184, 2010 3
  • 4.
    Was this methodpulled up? Who introduced this class? Who has made changes to my classes? History Questions How often is this method Why were these changes changed? introduced? Template-based Reconstruction of Complex Refactorings Kyle Prete, Napol Rachatasumrit, Nikita Sudan, Miryung Kim International Conference on Software Maintenance (ICSM), p.1--10, 2010 Using Information Fragments to Answer the Questions Developers Ask Thomas Fritz and Gail C. Murphy International Conference on Software Engineering (ICSE), p.175--184, 2010 3
  • 5.
    Pulled up Method 1 pull_up_method(fShortName, tChildFullName, tParentFullName) :- 2 move_method(fShortName, tChildFullName, tParentFullName) ^ 3 before_subtype(tParentFullName, tChildFullName) Template-based Reconstruction of Complex Refactorings Kyle Prete, Napol Rachatasumrit, Nikita Sudan, Miryung Kim International Conference on Software Maintenance (ICSM), p.1--10, 2010 4
  • 6.
    Pulled up Method 1 pull_up_method(fShortName, tChildFullName, tParentFullName) :- 2 move_method(fShortName, tChildFullName, tParentFullName) ^ 3 before_subtype(tParentFullName, tChildFullName) 1 move_method(mShortName, t1Fullname, t2FullName) :- 2 deleted_method(mFullName, mShortName, t1FullName) ^ 3 added_method(newmName, mShortName, t2FullName) ^ 4 similarbody(newmName, newmBody, mFullName, mBody) Template-based Reconstruction of Complex Refactorings Kyle Prete, Napol Rachatasumrit, Nikita Sudan, Miryung Kim International Conference on Software Maintenance (ICSM), p.1--10, 2010 4
  • 7.
    Version Control Systems Version Version 3a 4a Version Version 1 Version 2 5 Version Version 3b 4b 5
  • 8.
    History Query Tool Pr Graph Query og Language ra La m od ry ng Q Move through the sto el ua ue version graph Hi ge ry M Source code of each version Specify characteristics Commit information in a single version Entity tracking ... 6
  • 9.
    QwalKeko Pr Graph Query og Language ra La m od ry ng Q Qwal sto el ua ue Hi ge ry M Ekeko + 7
  • 10.
    Applicative LMP ... specifycode characteristics through Ekeko relations, leave search to core.logic collection of all substitutions for ?s and ?e (run* [?s ?e] (ast :ReturnStatement ?s) (has :expression ?s ?e) (ast :NullLiteral ?e)) such that the following Ekeko relations hold: ast/2 holds for :ReturnStatement, ?s ?e is the value of the property has/3 holds for :expression, ?s, and ?e named :expression of ([?s1 ?e2] ... [?sn ?en]) ast/2 holds for :NullLiteral, ?e ASTNode ?s ([#<ReturnStatement return null; #<NullLiteral null>] ... actual search performed by [#<ReturnStatement return null; core.logic #<NullLiteral null>]) 8
  • 11.
    Qwal foo bar baz 1 (run* [?end] 2 (qwal graph :foo ?end 3 [] 4 (qcurrent [curr] (has-info curr :foo)) 9
  • 12.
    Qwal foo bar baz 1 (run* [?end] 2 (qwal graph :foo ?end 3 [] 4 (qcurrent [curr] (has-info curr :foo)) 5 q=> 6 (qcurrent [curr] (has-info curr :bar)) 9
  • 13.
    Qwal foo bar baz 1 (run* [?end] 2 (qwal graph :foo ?end 3 [] 4 (qcurrent [curr] (has-info curr :foo)) 5 q=> 6 (qcurrent [curr] (has-info curr :bar)) 7 q=> 8 (qcurrent [curr] (has-info curr :baz))) 9
  • 14.
    Introduced Subclasses 1 (qwal graph start ?end [?parent ?child] 2 (qin-current 3 (ast :TypeDeclaration ?parent)) 4 (q=>+) ;;skip >= 1 versions 5 (qin-current 6 (subclass ?parent ?child) 7 (introduced ?child))) 10
  • 15.
    Same Predicate (defn same[?entity ?other-entity] ...) Ground in a previous version Ground in current version 11
  • 16.
    Same Predicate (defn same[?entity ?other-entity] ...) 1 (defn introduced [?entity] 2 (fresh [?same] 3 q<= 4 (not (same ?entity ?same))) 12
  • 17.
    Recall... 1 pull_up_method(fShortName, tChildFullName, tParentFullName) :- 2 move_method(fShortName, tChildFullName, tParentFullName) ^ 3 before_subtype(tParentFullName, tChildFullName) 1 move_method(mShortName, t1Fullname, t2FullName) :- 2 deleted_method(mFullName, mShortName, t1FullName) ^ 3 added_method(newmName, mShortName, t2FullName) ^ 4 similarbody(newmName, newmBody, mFullName, mBody) 13
  • 18.
    Pulled up Method 1 (defn pulled-up [?method ?pulled] 2 (fresh [?m-class ?p-class] 3 (method-moved ?method ?pulled) 4 (declaring-class ?method ?m-class) 5 (declaring-class ?pulled ?p-class) 6 (superclass ?m-class ?p-class))) 1 (defn method-moved [?moved ?to] 2 (removed ?moved) ;;implemented using same 3 (ast :MethodDeclaration ?to) 4 (== ?moved ?to) ;;unify when same signature 5 (has-similar-body ?moved ?to))) 14
  • 19.
    Pulled up Method 1(qwal graph root ?end [?method ?pulled] 2 (qin-current 3 (ast :MethodDeclaration ?method)) 4 q=> ;;go to next version 5 (qin-current 6 (pulled-up ?method ?pulled))) 15
  • 20.
    Generalized Rule 1 (qwalgraph root ?end [?method ?pulled] 2 (qin-current 3 (ast :MethodDeclaration ?method)) 4 (q=>+) ;;skip >=1 versions 5 (qin-current 6 (pulled-up ?method ?pulled))) 16
  • 21.
    Questions Reinout Stevens resteven@vub.ac.be @ReinoutStevens http://github.com/ReinoutStevens/damp.qwal http://github.com/cderoove/damp.ekeko 17

Editor's Notes