Tue, 25 Sep 2012 13:11:05 -0700
7196464: upgrade JavaCompiler.shouldStopPolicy to accomodate policies in face of error and no error
Reviewed-by: mcimadamore
mcimadamore@83 | 1 | /* |
ohair@554 | 2 | * Copyright (c) 2008, 2009, Oracle and/or its affiliates. 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 |
ohair@554 | 7 | * published by the Free Software Foundation. Oracle designates this |
mcimadamore@83 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@554 | 9 | * by Oracle 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 | * |
ohair@554 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 23 | * 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 |
jjg@333 | 35 | * |
jjg@581 | 36 | * <p><b>This is NOT part of any supported API. |
jjg@333 | 37 | * If you write code that depends on this, you do so at your own risk. |
jjg@333 | 38 | * This code and its internal interfaces are subject to change or |
jjg@333 | 39 | * deletion without notice.</b> |
mcimadamore@83 | 40 | */ |
mcimadamore@83 | 41 | public interface DiagnosticFormatter<D extends Diagnostic<?>> { |
mcimadamore@83 | 42 | |
mcimadamore@83 | 43 | /** |
mcimadamore@221 | 44 | * Whether the source code output for this diagnostic is to be displayed. |
mcimadamore@83 | 45 | * |
mcimadamore@83 | 46 | * @param diag diagnostic to be formatted |
mcimadamore@83 | 47 | * @return true if the source line this diagnostic refers to is to be displayed |
mcimadamore@83 | 48 | */ |
mcimadamore@83 | 49 | boolean displaySource(D diag); |
mcimadamore@83 | 50 | |
mcimadamore@83 | 51 | /** |
mcimadamore@221 | 52 | * Format the contents of a diagnostics. |
mcimadamore@83 | 53 | * |
mcimadamore@83 | 54 | * @param diag the diagnostic to be formatted |
mcimadamore@83 | 55 | * @param l locale object to be used for i18n |
mcimadamore@83 | 56 | * @return a string representing the diagnostic |
mcimadamore@83 | 57 | */ |
mcimadamore@83 | 58 | public String format(D diag, Locale l); |
mcimadamore@83 | 59 | |
mcimadamore@83 | 60 | /** |
mcimadamore@83 | 61 | * Controls the way in which a diagnostic message is displayed. |
mcimadamore@83 | 62 | * |
mcimadamore@83 | 63 | * @param diag diagnostic to be formatted |
mcimadamore@83 | 64 | * @param l locale object to be used for i18n |
mcimadamore@83 | 65 | * @return string representation of the diagnostic message |
mcimadamore@83 | 66 | */ |
mcimadamore@83 | 67 | public String formatMessage(D diag,Locale l); |
mcimadamore@83 | 68 | |
mcimadamore@83 | 69 | /** |
mcimadamore@83 | 70 | * Controls the way in which a diagnostic kind is displayed. |
mcimadamore@83 | 71 | * |
mcimadamore@83 | 72 | * @param diag diagnostic to be formatted |
mcimadamore@83 | 73 | * @param l locale object to be used for i18n |
mcimadamore@83 | 74 | * @return string representation of the diagnostic prefix |
mcimadamore@83 | 75 | */ |
mcimadamore@83 | 76 | public String formatKind(D diag, Locale l); |
mcimadamore@83 | 77 | |
mcimadamore@83 | 78 | /** |
mcimadamore@83 | 79 | * Controls the way in which a diagnostic source is displayed. |
mcimadamore@83 | 80 | * |
mcimadamore@83 | 81 | * @param diag diagnostic to be formatted |
mcimadamore@83 | 82 | * @param l locale object to be used for i18n |
mcimadamore@100 | 83 | * @param fullname whether the source fullname should be printed |
mcimadamore@83 | 84 | * @return string representation of the diagnostic source |
mcimadamore@83 | 85 | */ |
mcimadamore@100 | 86 | public String formatSource(D diag, boolean fullname, Locale l); |
mcimadamore@83 | 87 | |
mcimadamore@83 | 88 | /** |
mcimadamore@83 | 89 | * Controls the way in which a diagnostic position is displayed. |
mcimadamore@83 | 90 | * |
mcimadamore@83 | 91 | * @param diag diagnostic to be formatted |
mcimadamore@83 | 92 | * @param pk enum constant representing the position kind |
mcimadamore@83 | 93 | * @param l locale object to be used for i18n |
mcimadamore@83 | 94 | * @return string representation of the diagnostic position |
mcimadamore@83 | 95 | */ |
mcimadamore@83 | 96 | public String formatPosition(D diag, PositionKind pk, Locale l); |
mcimadamore@83 | 97 | //where |
mcimadamore@83 | 98 | /** |
mcimadamore@83 | 99 | * This enum defines a set of constants for all the kinds of position |
mcimadamore@83 | 100 | * that a diagnostic can be asked for. All positions are intended to be |
mcimadamore@83 | 101 | * relative to a given diagnostic source. |
mcimadamore@83 | 102 | */ |
mcimadamore@83 | 103 | public enum PositionKind { |
mcimadamore@83 | 104 | /** |
mcimadamore@83 | 105 | * Start position |
mcimadamore@83 | 106 | */ |
mcimadamore@83 | 107 | START, |
mcimadamore@83 | 108 | /** |
mcimadamore@83 | 109 | * End position |
mcimadamore@83 | 110 | */ |
mcimadamore@83 | 111 | END, |
mcimadamore@83 | 112 | /** |
mcimadamore@83 | 113 | * Line number |
mcimadamore@83 | 114 | */ |
mcimadamore@83 | 115 | LINE, |
mcimadamore@83 | 116 | /** |
mcimadamore@83 | 117 | * Column number |
mcimadamore@83 | 118 | */ |
mcimadamore@83 | 119 | COLUMN, |
mcimadamore@83 | 120 | /** |
mcimadamore@83 | 121 | * Offset position |
mcimadamore@83 | 122 | */ |
mcimadamore@83 | 123 | OFFSET |
mcimadamore@83 | 124 | } |
mcimadamore@221 | 125 | |
mcimadamore@221 | 126 | /** |
mcimadamore@221 | 127 | * Get a list of all the enabled verbosity options. |
mcimadamore@221 | 128 | * @return verbosity options |
mcimadamore@221 | 129 | */ |
mcimadamore@221 | 130 | public Configuration getConfiguration(); |
mcimadamore@221 | 131 | //where |
mcimadamore@221 | 132 | |
mcimadamore@221 | 133 | /** |
mcimadamore@221 | 134 | * This interface provides functionalities for tuning the output of a |
mcimadamore@221 | 135 | * diagnostic formatter in multiple ways. |
mcimadamore@221 | 136 | */ |
mcimadamore@221 | 137 | interface Configuration { |
mcimadamore@221 | 138 | /** |
mcimadamore@221 | 139 | * Configure the set of diagnostic parts that should be displayed |
mcimadamore@221 | 140 | * by the formatter. |
mcimadamore@221 | 141 | * @param options options to set |
mcimadamore@221 | 142 | */ |
mcimadamore@221 | 143 | public void setVisible(Set<DiagnosticPart> visibleParts); |
mcimadamore@221 | 144 | |
mcimadamore@221 | 145 | /** |
mcimadamore@221 | 146 | * Retrieve the set of diagnostic parts that should be displayed |
mcimadamore@221 | 147 | * by the formatter. |
mcimadamore@221 | 148 | * @return verbosity options |
mcimadamore@221 | 149 | */ |
mcimadamore@221 | 150 | public Set<DiagnosticPart> getVisible(); |
mcimadamore@221 | 151 | |
mcimadamore@221 | 152 | //where |
mcimadamore@221 | 153 | /** |
mcimadamore@221 | 154 | * A given diagnostic message can be divided into sub-parts each of which |
mcimadamore@221 | 155 | * might/might not be displayed by the formatter, according to the |
mcimadamore@221 | 156 | * current configuration settings. |
mcimadamore@221 | 157 | */ |
mcimadamore@221 | 158 | public enum DiagnosticPart { |
mcimadamore@221 | 159 | /** |
mcimadamore@221 | 160 | * Short description of the diagnostic - usually one line long. |
mcimadamore@221 | 161 | */ |
mcimadamore@221 | 162 | SUMMARY, |
mcimadamore@221 | 163 | /** |
mcimadamore@221 | 164 | * Longer description that provides additional details w.r.t. the ones |
mcimadamore@221 | 165 | * in the diagnostic's description. |
mcimadamore@221 | 166 | */ |
mcimadamore@221 | 167 | DETAILS, |
mcimadamore@221 | 168 | /** |
mcimadamore@221 | 169 | * Source line the diagnostic refers to (if applicable). |
mcimadamore@221 | 170 | */ |
mcimadamore@221 | 171 | SOURCE, |
mcimadamore@221 | 172 | /** |
mcimadamore@221 | 173 | * Subdiagnostics attached to a given multiline diagnostic. |
mcimadamore@221 | 174 | */ |
mcimadamore@221 | 175 | SUBDIAGNOSTICS, |
mcimadamore@221 | 176 | /** |
mcimadamore@221 | 177 | * JLS paragraph this diagnostic might refer to (if applicable). |
mcimadamore@221 | 178 | */ |
mcimadamore@221 | 179 | JLS; |
mcimadamore@221 | 180 | } |
mcimadamore@221 | 181 | |
mcimadamore@221 | 182 | /** |
mcimadamore@221 | 183 | * Set a limit for multiline diagnostics. |
mcimadamore@221 | 184 | * Note: Setting a limit has no effect if multiline diagnostics are either |
mcimadamore@221 | 185 | * fully enabled or disabled. |
mcimadamore@221 | 186 | * |
mcimadamore@221 | 187 | * @param limit the kind of limit to be set |
mcimadamore@221 | 188 | * @param value the limit value |
mcimadamore@221 | 189 | */ |
mcimadamore@221 | 190 | public void setMultilineLimit(MultilineLimit limit, int value); |
mcimadamore@221 | 191 | |
mcimadamore@221 | 192 | /** |
mcimadamore@221 | 193 | * Get a multiline diagnostic limit. |
mcimadamore@221 | 194 | * |
mcimadamore@221 | 195 | * @param limit the kind of limit to be retrieved |
mcimadamore@221 | 196 | * @return limit value or -1 if no limit is set |
mcimadamore@221 | 197 | */ |
mcimadamore@221 | 198 | public int getMultilineLimit(MultilineLimit limit); |
mcimadamore@221 | 199 | //where |
mcimadamore@221 | 200 | /** |
mcimadamore@221 | 201 | * A multiline limit control the verbosity of multiline diagnostics |
mcimadamore@221 | 202 | * either by setting a maximum depth of nested multidiagnostics, |
mcimadamore@221 | 203 | * or by limiting the amount of subdiagnostics attached to a given |
mcimadamore@221 | 204 | * diagnostic (or both). |
mcimadamore@221 | 205 | */ |
mcimadamore@221 | 206 | public enum MultilineLimit { |
mcimadamore@221 | 207 | /** |
mcimadamore@221 | 208 | * Controls the maximum depth of nested multiline diagnostics. |
mcimadamore@221 | 209 | */ |
mcimadamore@221 | 210 | DEPTH, |
mcimadamore@221 | 211 | /** |
mcimadamore@221 | 212 | * Controls the maximum amount of subdiagnostics that are part of a |
mcimadamore@221 | 213 | * given multiline diagnostic. |
mcimadamore@221 | 214 | */ |
mcimadamore@221 | 215 | LENGTH; |
mcimadamore@221 | 216 | } |
mcimadamore@221 | 217 | } |
mcimadamore@83 | 218 | } |