Skip to content

Incorrect edit script #165

Open
Open
@algomaster99

Description

@algomaster99

left.java

class Invocation {
    int a = 1;
    void checkForSign() {
        if (a > 0) {
            System.out.println("y");
        } else if (a < 0) {
            System.out.println("z");
        } else {
            System.out.println("x");
        }
    }
}

right.java

class Invocation {
    int a = 1;
    void checkForSign() {
        if (a > 0) {
            System.out.println("x");
        } else if (a < 0) {
            System.out.println("y");
        } else {
            System.out.println("z");
        }
    }
}

EDIT SCRIPT

  1. Delete Block at Invocation:6
     {
     
     }
  2. Insert Block at Invocation:4
     {
     
     }
  3. Move Invocation from Invocation:9 to Invocation:5
     System.out.println("x")
  4.  Move Block from Invocation:4 to Invocation:6
     {
         System.out.println("y");
     }
  5.  Move Invocation from Invocation:7 to Invocation:9
     System.out.println("z")

Ideally, three move operations were enough but an optimum edit script is not guaranteed but a correct one should be. The edit script produced for this case has one major problem - the second operation inserts a block into an already existing block (if block is already there at 4). This could be a consequence of the absence of CtBlock concept in spoon but I am not sure. However, if this is the case, convertToSpoon needs to be fixed.

Using this edit script in diffmin also throws an error as elaborated here. This could be an issue with the mapping as THEN block in else-if in left.java should have been mapped to THEN block in if in right.java. However, GumTree matchers are based on heuristics so we cannot expect the matcher to give accurate mappings every time as it is an NP-hard problem as argued by @slarse.

tree

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions