1 /*******************************************************************************
2 * Copyright (c) 2000, 2011 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.corext.dom;
13 import org.eclipse.core.runtime.Assert;
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;
20 public class JdtASTMatcher extends ASTMatcher {
23 public boolean match(SimpleName node, Object other) {
24 boolean isomorphic= super.match(node, other);
25 if (! isomorphic || !(other instanceof SimpleName))
27 SimpleName name= (SimpleName)other;
28 IBinding nodeBinding= node.resolveBinding();
29 IBinding otherBinding= name.resolveBinding();
30 if (nodeBinding == null) {
31 if (otherBinding != null) {
35 if (nodeBinding != otherBinding) {
39 if (node.resolveTypeBinding() != name.resolveTypeBinding())
44 public static boolean doNodesMatch(ASTNode one, ASTNode other) {
45 Assert.isNotNull(one);
46 Assert.isNotNull(other);
48 return one.subtreeMatch(new JdtASTMatcher(), other);