All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gumtree.spoon.builder.jsonsupport.OperationNodePainter Maven / Gradle / Ivy

Go to download

Computes the AST difference between two Spoon abstract syntax trees using the Gumtree algorithm.

There is a newer version: 1.92
Show newest version
package gumtree.spoon.builder.jsonsupport;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.github.gumtreediff.actions.model.Action;
import com.github.gumtreediff.tree.Tree;
import com.google.gson.JsonObject;

import gumtree.spoon.builder.Json4SpoonGenerator.JSON_PROPERTIES;
import gumtree.spoon.diff.operations.Operation;

/**
 * 
 * @author Matias Martinez
 *
 */
public class OperationNodePainter implements NodePainter {

	private Map nodesAffectedByOps = new HashMap<>();

	public OperationNodePainter(List operations) {
		// Collect all nodes and get the operator
		for (Operation operation : operations) {
			nodesAffectedByOps.put(operation.getAction().getNode(), operation);
		}
	}

	@Override
	public void paint(Tree tree, JsonObject jsontree) {

		if (nodesAffectedByOps.containsKey(tree)) {

			Operation operationOverTree = nodesAffectedByOps.get(tree);
			jsontree.addProperty(JSON_PROPERTIES.op.toString(), operationOverTree.getAction().getName());
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy