Skip to content

Modifcations

Shiblu edited this page Mar 24, 2021 · 2 revisions

AST Visitor not considering properties of anonymous classes as part of the statement

JavaScript module pattern technically contains the whole source code in a single statement. Therefore we cannot use the properties (a function name, variables, etc.) inside of anonymous classes / anonymous functions to use match the statement containing anonymous.

(function (global, factory) { // some 2 -3 lines definition }​
  (this, (function () { 'use strict';// Main code​
          var x = 1;
          function f1() {
           
           }
        })));

So in RM, the statement would contain the variable x in its list of variables. However, for JS we didn't include it.

Prevent Running String Edit Distance on Statement Containing Anonymous classes

Since the expensive String edit distance calculation runs many times during matching, we prevent this from running on a statement containing anonymous classes/ functions since it takes around 400s for 13KLOC in a single statement. For prevention -

  1. We did a check on LeafFragmentMapping for statements containing anonymous.
  2. Move anonymous class diff's code inside of findReplacementWithExactMapping() at the beginning

Issues: #80

Round based Anonymous matching

RM does not match further after matching one pair of anonymous classes in a statement. So refactorings happening inside statements with multiple anonymous classes are not reported. Therefore we match these pairs by using the Exact and Relaxed matching where we check for function declarations similarity up to certain depths (currently 3).

Treating statements directly inside of a file as lambda body
Fix bugs related to Overriden HashCode and Equals methods.