src/share/classes/com/sun/tools/javac/api/DiagnosticFormatter.java

Tue, 16 Jun 2009 10:46:37 +0100

author
mcimadamore
date
Tue, 16 Jun 2009 10:46:37 +0100
changeset 299
22872b24d38c
parent 229
03bcd66bd8e7
child 333
7c2d6da61646
permissions
-rw-r--r--

6638712: Inference with wildcard types causes selection of inapplicable method
Summary: Added global sanity check in order to make sure that return type inference does not violate bounds constraints
Reviewed-by: jjg

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

mercurial