Path: blob/master/src/java.compiler/share/classes/javax/annotation/processing/Messager.java
41159 views
/*1* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.annotation.processing;2627import javax.tools.Diagnostic;28import javax.lang.model.element.*;2930/**31* A {@code Messager} provides the way for an annotation processor to32* report error messages, warnings, and other notices. Elements,33* annotations, and annotation values can be passed to provide a34* location hint for the message. However, such location hints may be35* unavailable or only approximate.36*37* <p>Printing a message with an {@linkplain38* javax.tools.Diagnostic.Kind#ERROR error kind} will {@linkplain39* RoundEnvironment#errorRaised raise an error}.40*41* <p>Note that the messages "printed" by methods in this42* interface may or may not appear as textual output to a location43* like {@link System#out} or {@link System#err}. Implementations may44* choose to present this information in a different fashion, such as45* messages in a window.46*47* @author Joseph D. Darcy48* @author Scott Seligman49* @author Peter von der Ahé50* @see ProcessingEnvironment#getLocale51* @since 1.652*/53public interface Messager {54/**55* Prints a message of the specified kind.56*57* @param kind the kind of message58* @param msg the message, or an empty string if none59*/60void printMessage(Diagnostic.Kind kind, CharSequence msg);6162/**63* Prints a message of the specified kind at the location of the64* element.65*66* @param kind the kind of message67* @param msg the message, or an empty string if none68* @param e the element to use as a position hint69*/70void printMessage(Diagnostic.Kind kind, CharSequence msg, Element e);7172/**73* Prints a message of the specified kind at the location of the74* annotation mirror of the annotated element.75*76* @param kind the kind of message77* @param msg the message, or an empty string if none78* @param e the annotated element79* @param a the annotation to use as a position hint80*/81void printMessage(Diagnostic.Kind kind, CharSequence msg, Element e, AnnotationMirror a);8283/**84* Prints a message of the specified kind at the location of the85* annotation value inside the annotation mirror of the annotated86* element.87*88* @param kind the kind of message89* @param msg the message, or an empty string if none90* @param e the annotated element91* @param a the annotation containing the annotation value92* @param v the annotation value to use as a position hint93*/94void printMessage(Diagnostic.Kind kind,95CharSequence msg,96Element e,97AnnotationMirror a,98AnnotationValue v);99}100101102