Class TypeAnnotationMover

java.lang.Object
com.github.javaparser.ast.visitor.VoidVisitorAdapter<Void>
org.checkerframework.framework.ajava.TypeAnnotationMover
All Implemented Interfaces:
com.github.javaparser.ast.visitor.VoidVisitor<Void>

public class TypeAnnotationMover extends com.github.javaparser.ast.visitor.VoidVisitorAdapter<Void>
Moves annotations in a JavaParser AST from declaration position onto the types they correspond to.

When parsing a method or field such as @Tainted String myField, JavaParser puts all annotations on the declaration.

For each non-declaration annotation on a method or field declaration, this class moves it to the type position. A non-declaration annotation is one with a TYPE_USE target but no declaration target.

  • Constructor Summary

    Constructors
    Constructor
    Description
    TypeAnnotationMover(Map<String,TypeElement> allAnnotations, Elements elements)
    Constructs a TypeAnnotationMover.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    visit(com.github.javaparser.ast.body.FieldDeclaration node, Void p)
     
    void
    visit(com.github.javaparser.ast.body.MethodDeclaration node, Void p)
     

    Methods inherited from class com.github.javaparser.ast.visitor.VoidVisitorAdapter

    visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TypeAnnotationMover

      public TypeAnnotationMover(Map<String,TypeElement> allAnnotations, Elements elements)
      Constructs a TypeAnnotationMover.
      Parameters:
      allAnnotations - the annotations imported by the file, as a mapping from annotation name to TypeElement. There should be two entries for each annotation: the annotation's simple name and its fully-qualified name both mapped to its TypeElement.
      elements - the Element utilities
  • Method Details

    • visit

      public void visit(com.github.javaparser.ast.body.FieldDeclaration node, Void p)
      Specified by:
      visit in interface com.github.javaparser.ast.visitor.VoidVisitor<Void>
      Overrides:
      visit in class com.github.javaparser.ast.visitor.VoidVisitorAdapter<Void>
    • visit

      public void visit(com.github.javaparser.ast.body.MethodDeclaration node, Void p)
      Specified by:
      visit in interface com.github.javaparser.ast.visitor.VoidVisitor<Void>
      Overrides:
      visit in class com.github.javaparser.ast.visitor.VoidVisitorAdapter<Void>