// Path: jsonedit-model/src/main/java/com/boothen/jsonedit/antlr/JSONParser.java
// public static class JsonContext extends ParserRuleContext {
//     public ValueContext value() {
//         return getRuleContext(ValueContext.class,0);
//     }
//     public JsonContext(ParserRuleContext parent, int invokingState) {
//         super(parent, invokingState);
//     }
//     @Override public int getRuleIndex() { return RULE_json; }
//     @Override
//     public void enterRule(ParseTreeListener listener) {
//         if ( listener instanceof JSONListener ) ((JSONListener)listener).enterJson(this);
//     }
//     @Override
//     public void exitRule(ParseTreeListener listener) {
//         if ( listener instanceof JSONListener ) ((JSONListener)listener).exitJson(this);
//     }
//     @Override
//     public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
//         if ( visitor instanceof JSONVisitor ) return ((JSONVisitor<? extends T>)visitor).visitJson(this);
//         else return visitor.visitChildren(this);
//     }
// }


import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import org.antlr.v4.runtime.tree.ParseTree;
import org.eclipse.jface.text.Position;
import com.boothen.jsonedit.antlr.JSONParser.JsonContext;
package com.boothen.jsonedit.editor.model;




/**
 * Compares two parse trees.
 */
public class ParseTreeComparator {

    private JsonContext oldRoot;
    private Map<ParseTree, Position> oldPositions = Collections.emptyMap();

    /**
     * Requires the positions map to by ordered as they are found in the tree.
     * An alternative implementation could iterate over the new syntrax tree to avoid that.
     * @param syntaxTree the syntax tree
     * @param positions an <b>ordered</b> map.
     * @return a mapping from old to new tree elements
     */
// Path: jsonedit-model/src/main/java/com/boothen/jsonedit/antlr/JSONParser.java
// public static class JsonContext extends ParserRuleContext {
//     public ValueContext value() {
//         return getRuleContext(ValueContext.class,0);
//     }
//     public JsonContext(ParserRuleContext parent, int invokingState) {
//         super(parent, invokingState);
//     }
//     @Override public int getRuleIndex() { return RULE_json; }
//     @Override
//     public void enterRule(ParseTreeListener listener) {
//         if ( listener instanceof JSONListener ) ((JSONListener)listener).enterJson(this);
//     }
//     @Override
//     public void exitRule(ParseTreeListener listener) {
//         if ( listener instanceof JSONListener ) ((JSONListener)listener).exitJson(this);
//     }
//     @Override
//     public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
//         if ( visitor instanceof JSONVisitor ) return ((JSONVisitor<? extends T>)visitor).visitJson(this);
//         else return visitor.visitChildren(this);
//     }
// }


// Path: jsonedit-editor/src/main/java/com/boothen/jsonedit/editor/model/ParseTreeComparator.java
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import org.antlr.v4.runtime.tree.ParseTree;
import org.eclipse.jface.text.Position;
import com.boothen.jsonedit.antlr.JSONParser.JsonContext;

package com.boothen.jsonedit.editor.model;




/**
 * Compares two parse trees.
 */
public class ParseTreeComparator {

    private JsonContext oldRoot;
    private Map<ParseTree, Position> oldPositions = Collections.emptyMap();

    /**
     * Requires the positions map to by ordered as they are found in the tree.
     * An alternative implementation could iterate over the new syntrax tree to avoid that.
     * @param syntaxTree the syntax tree
     * @param positions an <b>ordered</b> map.
     * @return a mapping from old to new tree elements
     */
    public Map<ParseTree, ParseTree> update(JsonContext syntaxTree, LinkedHashMap<ParseTree, Position> positions) {