gumtree.spoon.diff.operations.AdditionOperation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gumtree-spoon-ast-diff Show documentation
Show all versions of gumtree-spoon-ast-diff Show documentation
Computes the AST difference between two Spoon abstract syntax trees using the Gumtree algorithm.
package gumtree.spoon.diff.operations;
import com.github.gumtreediff.actions.model.Addition;
import gumtree.spoon.builder.SpoonGumTreeBuilder;
import spoon.reflect.declaration.CtElement;
abstract class AdditionOperation extends Operation {
private final CtElement parent;
private final int position;
AdditionOperation(T action) {
super(action);
position = action.getPosition();
parent = (CtElement) action.getParent().getMetadata(SpoonGumTreeBuilder.SPOON_OBJECT);
}
public int getPosition() {
return position;
}
public CtElement getParent() {
return parent;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((parent == null) ? 0 : parent.hashCode());
result = prime * result + position;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
AdditionOperation other = (AdditionOperation) obj;
if (parent == null) {
if (other.parent != null)
return false;
} else if (!parent.equals(other.parent))
return false;
if (position != other.position)
return false;
return true;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy