public void printMessage(Diagnostic.Kind kind, CharSequence msg,
Element e, AnnotationMirror a, AnnotationValue v) {
JavaFileObject oldSource = null;
JavaFileObject newSource = null;
JCDiagnostic.DiagnosticPosition pos = null;
JavacElements elemUtils = processingEnv.getElementUtils();
Pair<JCTree, JCCompilationUnit> treeTop = elemUtils.getTreeAndTopLevel(e, a, v);
if (treeTop != null) {
newSource = treeTop.snd.sourcefile;
if (newSource != null) {
oldSource = log.useSource(newSource);
pos = treeTop.fst.pos();