title: How to determine if a class has an annotation using JDT, considering the type hierarchy
body: <p>There is a simple way to check if an annotation is present in a ICompilationUnit using Eclipse JDT?</p>
  
  <p>I tried to do the code below, but I will have to do the same thing for the super classes.</p>
  
  <pre><code>IResource resource = ...;
  
  ICompilationUnit cu = (ICompilationUnit) JavaCore.create(resource);
  
  // consider only the first class of the compilation unit
  IType firstClass = cu.getTypes()[0];
  
  // first check if the annotation is pressent by its full id
  if (firstClass.getAnnotation("java.lang.Deprecated").exists()) {
      return true;
  }
  
  // then, try to find the annotation by the simple name and confirms if the full name is in the imports 
  if (firstClass.getAnnotation("Deprecated").exists() &amp;&amp; //
      cu.getImport("java.lang.Deprecated").exists()) {
      return true;
  }
  </code></pre>
  
  <p>I know it is possible to resolve bindings with the ASTParser, but I didn't find a way to check if an annotation is present.
  Is there any simple API to do such thing?</p>