I have a basic Annotation Processor
@SupportedAnnotationTypes("example.Annotation")
public class Processor extends AbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
for (TypeElement annotation : annotations) {
Set<? extends Element> elementsAnnotatedWith = roundEnv.getElementsAnnotatedWith(annotation);
for (Element element : elementsAnnotatedWith) {
TypeElement typeElement = (TypeElement) element;
// Here, typeElement.getQualifiedName() is accessible, but not the code nor file path.
}
}
return false;
}
}
This annotation can only be used on classes. I know the target class is not compiled so reflective access is not possible but I would like to get the class code as String to parse in my own way instead of using this API.
Is it possible? I know I can get qualified name but where to look for the file?
processingEnv.getElementUtils()).