List of usage examples for org.eclipse.jdt.core.dom MethodDeclaration subtreeMatch
public final boolean subtreeMatch(ASTMatcher matcher, Object other)
From source file:changenodes.matching.BestLeafTreeMatcher.java
License:Apache License
private void matchIdenticalMethods(ASTNode left, ASTNode right) { //fix in which some methods got pretty bad matches //feels pretty dirty though (but so does this whole file) for (Iterator<ASTNode> iterator = new BreadthFirstNodeIterator(left); iterator.hasNext();) { ASTNode n = iterator.next();/*w w w .j ava 2s .co m*/ ASTNode bestMatch = null; if (n.getNodeType() == ASTNode.METHOD_DECLARATION) { MethodDeclaration x = (MethodDeclaration) n; if (!leftMatching.containsKey(x)) { for (Iterator<ASTNode> rightIterator = new BreadthFirstNodeIterator(right); rightIterator .hasNext();) { ASTNode y = rightIterator.next(); if (y.getNodeType() == x.getNodeType() && x.subtreeMatch(new ASTMatcher(), y)) { bestMatch = y; break; } } } //we have found the best node, lets now match them together //afaik this is also not in the original paper, but we sometimes got some weird matches if (bestMatch != null) { markMatchedNode(x, bestMatch); } } } }