Mon, 09 Mar 2009 13:29:06 -0700
6814575: Update copyright year
Summary: Update copyright for files that have been modified in 2009, up to 03/09
Reviewed-by: katleman, tbell, ohair
1 /*
2 * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25 package com.sun.tools.javac.api;
27 import java.util.Locale;
28 import java.util.Set;
29 import javax.tools.Diagnostic;
30 import com.sun.tools.javac.api.DiagnosticFormatter.*;
32 /**
33 * Provides simple functionalities for javac diagnostic formatting.
34 * @param <D> type of diagnostic handled by this formatter
35 */
36 public interface DiagnosticFormatter<D extends Diagnostic<?>> {
38 /**
39 * Whether the source code output for this diagnostic is to be displayed.
40 *
41 * @param diag diagnostic to be formatted
42 * @return true if the source line this diagnostic refers to is to be displayed
43 */
44 boolean displaySource(D diag);
46 /**
47 * Format the contents of a diagnostics.
48 *
49 * @param diag the diagnostic to be formatted
50 * @param l locale object to be used for i18n
51 * @return a string representing the diagnostic
52 */
53 public String format(D diag, Locale l);
55 /**
56 * Controls the way in which a diagnostic message is displayed.
57 *
58 * @param diag diagnostic to be formatted
59 * @param l locale object to be used for i18n
60 * @return string representation of the diagnostic message
61 */
62 public String formatMessage(D diag,Locale l);
64 /**
65 * Controls the way in which a diagnostic kind is displayed.
66 *
67 * @param diag diagnostic to be formatted
68 * @param l locale object to be used for i18n
69 * @return string representation of the diagnostic prefix
70 */
71 public String formatKind(D diag, Locale l);
73 /**
74 * Controls the way in which a diagnostic source is displayed.
75 *
76 * @param diag diagnostic to be formatted
77 * @param l locale object to be used for i18n
78 * @param fullname whether the source fullname should be printed
79 * @return string representation of the diagnostic source
80 */
81 public String formatSource(D diag, boolean fullname, Locale l);
83 /**
84 * Controls the way in which a diagnostic position is displayed.
85 *
86 * @param diag diagnostic to be formatted
87 * @param pk enum constant representing the position kind
88 * @param l locale object to be used for i18n
89 * @return string representation of the diagnostic position
90 */
91 public String formatPosition(D diag, PositionKind pk, Locale l);
92 //where
93 /**
94 * This enum defines a set of constants for all the kinds of position
95 * that a diagnostic can be asked for. All positions are intended to be
96 * relative to a given diagnostic source.
97 */
98 public enum PositionKind {
99 /**
100 * Start position
101 */
102 START,
103 /**
104 * End position
105 */
106 END,
107 /**
108 * Line number
109 */
110 LINE,
111 /**
112 * Column number
113 */
114 COLUMN,
115 /**
116 * Offset position
117 */
118 OFFSET
119 }
121 /**
122 * Get a list of all the enabled verbosity options.
123 * @return verbosity options
124 */
125 public Configuration getConfiguration();
126 //where
128 /**
129 * This interface provides functionalities for tuning the output of a
130 * diagnostic formatter in multiple ways.
131 */
132 interface Configuration {
133 /**
134 * Configure the set of diagnostic parts that should be displayed
135 * by the formatter.
136 * @param options options to set
137 */
138 public void setVisible(Set<DiagnosticPart> visibleParts);
140 /**
141 * Retrieve the set of diagnostic parts that should be displayed
142 * by the formatter.
143 * @return verbosity options
144 */
145 public Set<DiagnosticPart> getVisible();
147 //where
148 /**
149 * A given diagnostic message can be divided into sub-parts each of which
150 * might/might not be displayed by the formatter, according to the
151 * current configuration settings.
152 */
153 public enum DiagnosticPart {
154 /**
155 * Short description of the diagnostic - usually one line long.
156 */
157 SUMMARY,
158 /**
159 * Longer description that provides additional details w.r.t. the ones
160 * in the diagnostic's description.
161 */
162 DETAILS,
163 /**
164 * Source line the diagnostic refers to (if applicable).
165 */
166 SOURCE,
167 /**
168 * Subdiagnostics attached to a given multiline diagnostic.
169 */
170 SUBDIAGNOSTICS,
171 /**
172 * JLS paragraph this diagnostic might refer to (if applicable).
173 */
174 JLS;
175 }
177 /**
178 * Set a limit for multiline diagnostics.
179 * Note: Setting a limit has no effect if multiline diagnostics are either
180 * fully enabled or disabled.
181 *
182 * @param limit the kind of limit to be set
183 * @param value the limit value
184 */
185 public void setMultilineLimit(MultilineLimit limit, int value);
187 /**
188 * Get a multiline diagnostic limit.
189 *
190 * @param limit the kind of limit to be retrieved
191 * @return limit value or -1 if no limit is set
192 */
193 public int getMultilineLimit(MultilineLimit limit);
194 //where
195 /**
196 * A multiline limit control the verbosity of multiline diagnostics
197 * either by setting a maximum depth of nested multidiagnostics,
198 * or by limiting the amount of subdiagnostics attached to a given
199 * diagnostic (or both).
200 */
201 public enum MultilineLimit {
202 /**
203 * Controls the maximum depth of nested multiline diagnostics.
204 */
205 DEPTH,
206 /**
207 * Controls the maximum amount of subdiagnostics that are part of a
208 * given multiline diagnostic.
209 */
210 LENGTH;
211 }
212 }
213 }