// no need to do a search if this is the same AST.
if (compilationUnit.getAST() == searchDeclaration.getAST()) {
return searchDeclaration;
}
IBinding binding = null;
if (searchDeclaration instanceof MethodDeclaration) {
binding = ((MethodDeclaration)searchDeclaration).resolveBinding();
}
if (searchDeclaration instanceof TypeDeclaration) {
binding = ((TypeDeclaration)searchDeclaration).resolveBinding();
}
if (searchDeclaration instanceof SingleVariableDeclaration) {
binding = ((SingleVariableDeclaration)searchDeclaration).resolveBinding();
}
return Generics.asT(
binding != null?
findDeclaration(compilationUnit, binding.getKey()):
null);
}