Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anonymous pairs are not matched because of unavailable variable replacement map #103

Open
mkshiblu opened this issue Apr 8, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@mkshiblu
Copy link
Owner

mkshiblu commented Apr 8, 2021

In body mapper, we try to match anonymous classes appearing in a pair of statements based on the texts without the anonymous classes.

image

The text without anonymous for the following snippet will be let x = "

//v1
let x = function f() { };
//v2
let y = function f() { };

However, when we moved the anonymous matching logic at the top of the findReplacementWithExactMapping, to prevent passing it to SED, we do not do any replacements. Therefore the replacements passed to the argument of identicalAfterVariableAndTypeReplacements is empty.

identicalAfterVariableAndTypeReplacements(statementWithoutAnonymous1, statementWithoutAnonymous2, replacementInfo.getReplacements())

So even though the statements without Anonymus are identical with the replacement of variable x with y, the method does not return true and therefore it does not match the pairs.

@mkshiblu mkshiblu added the bug Something isn't working label Apr 8, 2021
@mkshiblu mkshiblu self-assigned this Apr 8, 2021
@mkshiblu mkshiblu added this to the MILESTONE_APR_15 milestone Apr 8, 2021
@mkshiblu mkshiblu added In progress Currently doing and removed In progress Currently doing labels Apr 8, 2021
@mkshiblu
Copy link
Owner Author

mkshiblu commented Apr 16, 2021

Looks like we can explore observations here.

  • We can duplicate the code in findReplacementWithExactMatching up to variablesAndMethodInvocation replacement to run on the statement with anonymous
  • We can create replacement info with the text of the statement without anonymous.
  • We need to decide whether to exclude all or only the current pairs anonymous from the text. Perhaps better we could do a round-based match?
    For example:
let  x = m1(function a1(){}, function a2() {});

Here if we do round system text without anonymous would be

  1. Round 1:
let x = m1(, function a2())  // a1 pairs removed
  1. Round 2:
let x = m2(function a1(), )  // a2 pairs removed
  1. Round 3:
let x = // all anonymous removed

mkshiblu added a commit that referenced this issue Apr 20, 2021
@mkshiblu mkshiblu added the In progress Currently doing label Jun 10, 2021
@mkshiblu mkshiblu removed the In progress Currently doing label Jun 18, 2021
@mkshiblu mkshiblu added the In progress Currently doing label Aug 2, 2021
@mkshiblu mkshiblu removed the In progress Currently doing label Sep 4, 2021
@mkshiblu mkshiblu removed this from the MILESTONE_20201_AUG_15 milestone Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant