Created
July 31, 2015 07:17
-
-
Save sebastianmonte/f47325df5750c519b877 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gofore.fixme.processor; | |
import com.gofore.fixme.annotation.Fixme; | |
import javax.annotation.processing.*; | |
import javax.lang.model.SourceVersion; | |
import javax.lang.model.element.Element; | |
import javax.lang.model.element.TypeElement; | |
import javax.tools.Diagnostic; | |
import java.util.Set; | |
@SupportedSourceVersion(SourceVersion.RELEASE_8) | |
@SupportedAnnotationTypes("com.gofore.fixme.annotation.Fixme") | |
public class FixmeProcessor extends AbstractProcessor { | |
private ProcessingEnvironment env; | |
@Override | |
public synchronized void init(ProcessingEnvironment env) { | |
this.env = env; | |
} | |
@Override | |
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { | |
if (!roundEnv.processingOver()) { | |
annotations.forEach(annotation -> { | |
roundEnv.getElementsAnnotatedWith(annotation).forEach(element -> env.getMessager().printMessage( | |
Diagnostic.Kind.WARNING, | |
String.format("@%s: %s", annotation.getSimpleName(), getSummary(element)), | |
element)); | |
}); | |
} | |
return true; | |
} | |
private String getSummary(Element element) { | |
return element.getAnnotation(Fixme.class).summary(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment