gumtree icon indicating copy to clipboard operation
gumtree copied to clipboard

Suggestion for enhanching the edit script

Open algomaster99 opened this issue 2 years ago • 1 comments

Hi! I have a suggestion for an improvement in the edit script.

Consider these two files: left

import java.util.LinkedList;
import java.util.Queue;

class TreeTraversal {

    class TreeNode {
        public int val;
        public TreeNode left;
        public TreeNode right;

        public TreeNode(int val) {
            this.val = val;
        }
    }
}

right

import java.util.LinkedList;
import java.util.Queue;

class TreeTraversal {

    class TreeNode {
        public int val;
        public TreeNode left;
        public TreeNode right;

        public TreeNode(int val) {
            this.val = val;
            left = right = null;
        }

        public TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }
}

Its diff is shown as: Screenshot from 2022-02-18 15-23-12

I think the move operation of this.val = val; is not necessary. It should be kept as-is for the first constructor. Can this be improved by fixing the ChawatheScriptGenerator?

algomaster99 avatar Feb 18 '22 14:02 algomaster99

Hi!

Thanks for the case.

It's awkward that's it's matching with the statement from the second constructor. I will investigate why.

Cheers.

jrfaller avatar Feb 28 '22 08:02 jrfaller

Tried it with the latest version, but cannot reproduce it. Please reopen if it's still there.

jrfaller avatar Nov 27 '23 19:11 jrfaller