1 11 package org.eclipse.jdt.internal.corext.dom; 12 13 import org.eclipse.core.runtime.Assert; 14 15 import org.eclipse.jdt.core.dom.ASTMatcher; 16 import org.eclipse.jdt.core.dom.ASTNode; 17 import org.eclipse.jdt.core.dom.IBinding; 18 import org.eclipse.jdt.core.dom.SimpleName; 19 20 public class JdtASTMatcher extends ASTMatcher { 21 22 public boolean match(SimpleName node, Object other) { 23 boolean isomorphic= super.match(node, other); 24 if (! isomorphic || !(other instanceof SimpleName)) 25 return false; 26 SimpleName name= (SimpleName)other; 27 IBinding nodeBinding= node.resolveBinding(); 28 IBinding otherBinding= name.resolveBinding(); 29 if (nodeBinding == null) { 30 if (otherBinding != null) { 31 return false; 32 } 33 } else { 34 if (nodeBinding != otherBinding) { 35 return false; 36 } 37 } 38 if (node.resolveTypeBinding() != name.resolveTypeBinding()) 39 return false; 40 return true; 41 } 42 43 public static boolean doNodesMatch(ASTNode one, ASTNode other) { 44 Assert.isNotNull(one); 45 Assert.isNotNull(other); 46 47 return one.subtreeMatch(new JdtASTMatcher(), other); 48 } 49 } 50 | Popular Tags |