code: public static DiagnosticPosition diagEndPos(final JCTree tree) {
          final int endPos = TreeInfo.endPos(tree);
          return new DiagnosticPosition() {
              public JCTree getTree() { return tree; }
              public int getStartPosition() { return TreeInfo.getStartPos(tree); }
              public int getPreferredPosition() { return endPos; }
              public int getEndPosition(EndPosTable endPosTable) {
                  return TreeInfo.getEndPos(tree, endPosTable);
              }
          };
      }
docs: A DiagnosticPosition with the preferred position set to the
  end position of given tree, if it is a block with
  defined endpos.