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

Wed, 27 Apr 2016 01:34:52 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:34:52 +0800
changeset 0
959103a6100f
child 2525
2eb010b6cb22
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/langtools/
changeset: 2573:53ca196be1ae
tag: jdk8u25-b17

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

mercurial