mcimadamore@83: /* ohair@554: * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. mcimadamore@83: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. mcimadamore@83: * mcimadamore@83: * This code is free software; you can redistribute it and/or modify it mcimadamore@83: * under the terms of the GNU General Public License version 2 only, as ohair@554: * published by the Free Software Foundation. Oracle designates this mcimadamore@83: * particular file as subject to the "Classpath" exception as provided ohair@554: * by Oracle in the LICENSE file that accompanied this code. mcimadamore@83: * mcimadamore@83: * This code is distributed in the hope that it will be useful, but WITHOUT mcimadamore@83: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or mcimadamore@83: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License mcimadamore@83: * version 2 for more details (a copy is included in the LICENSE file that mcimadamore@83: * accompanied this code). mcimadamore@83: * mcimadamore@83: * You should have received a copy of the GNU General Public License version mcimadamore@83: * 2 along with this work; if not, write to the Free Software Foundation, mcimadamore@83: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. mcimadamore@83: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. mcimadamore@83: */ mcimadamore@83: package com.sun.tools.javac.api; mcimadamore@83: mcimadamore@83: import java.util.Locale; mcimadamore@221: import java.util.Set; mcimadamore@83: import javax.tools.Diagnostic; mcimadamore@221: import com.sun.tools.javac.api.DiagnosticFormatter.*; mcimadamore@83: mcimadamore@83: /** mcimadamore@221: * Provides simple functionalities for javac diagnostic formatting. mcimadamore@83: * @param type of diagnostic handled by this formatter jjg@333: * jjg@581: *

This is NOT part of any supported API. jjg@333: * If you write code that depends on this, you do so at your own risk. jjg@333: * This code and its internal interfaces are subject to change or jjg@333: * deletion without notice. mcimadamore@83: */ mcimadamore@83: public interface DiagnosticFormatter> { mcimadamore@83: mcimadamore@83: /** mcimadamore@221: * Whether the source code output for this diagnostic is to be displayed. mcimadamore@83: * mcimadamore@83: * @param diag diagnostic to be formatted mcimadamore@83: * @return true if the source line this diagnostic refers to is to be displayed mcimadamore@83: */ mcimadamore@83: boolean displaySource(D diag); mcimadamore@83: mcimadamore@83: /** mcimadamore@221: * Format the contents of a diagnostics. mcimadamore@83: * mcimadamore@83: * @param diag the diagnostic to be formatted mcimadamore@83: * @param l locale object to be used for i18n mcimadamore@83: * @return a string representing the diagnostic mcimadamore@83: */ mcimadamore@83: public String format(D diag, Locale l); mcimadamore@83: mcimadamore@83: /** mcimadamore@83: * Controls the way in which a diagnostic message is displayed. mcimadamore@83: * mcimadamore@83: * @param diag diagnostic to be formatted mcimadamore@83: * @param l locale object to be used for i18n mcimadamore@83: * @return string representation of the diagnostic message mcimadamore@83: */ mcimadamore@83: public String formatMessage(D diag,Locale l); mcimadamore@83: mcimadamore@83: /** mcimadamore@83: * Controls the way in which a diagnostic kind is displayed. mcimadamore@83: * mcimadamore@83: * @param diag diagnostic to be formatted mcimadamore@83: * @param l locale object to be used for i18n mcimadamore@83: * @return string representation of the diagnostic prefix mcimadamore@83: */ mcimadamore@83: public String formatKind(D diag, Locale l); mcimadamore@83: mcimadamore@83: /** mcimadamore@83: * Controls the way in which a diagnostic source is displayed. mcimadamore@83: * mcimadamore@83: * @param diag diagnostic to be formatted mcimadamore@83: * @param l locale object to be used for i18n mcimadamore@100: * @param fullname whether the source fullname should be printed mcimadamore@83: * @return string representation of the diagnostic source mcimadamore@83: */ mcimadamore@100: public String formatSource(D diag, boolean fullname, Locale l); mcimadamore@83: mcimadamore@83: /** mcimadamore@83: * Controls the way in which a diagnostic position is displayed. mcimadamore@83: * mcimadamore@83: * @param diag diagnostic to be formatted mcimadamore@83: * @param pk enum constant representing the position kind mcimadamore@83: * @param l locale object to be used for i18n mcimadamore@83: * @return string representation of the diagnostic position mcimadamore@83: */ mcimadamore@83: public String formatPosition(D diag, PositionKind pk, Locale l); mcimadamore@83: //where mcimadamore@83: /** mcimadamore@83: * This enum defines a set of constants for all the kinds of position mcimadamore@83: * that a diagnostic can be asked for. All positions are intended to be mcimadamore@83: * relative to a given diagnostic source. mcimadamore@83: */ mcimadamore@83: public enum PositionKind { mcimadamore@83: /** mcimadamore@83: * Start position mcimadamore@83: */ mcimadamore@83: START, mcimadamore@83: /** mcimadamore@83: * End position mcimadamore@83: */ mcimadamore@83: END, mcimadamore@83: /** mcimadamore@83: * Line number mcimadamore@83: */ mcimadamore@83: LINE, mcimadamore@83: /** mcimadamore@83: * Column number mcimadamore@83: */ mcimadamore@83: COLUMN, mcimadamore@83: /** mcimadamore@83: * Offset position mcimadamore@83: */ mcimadamore@83: OFFSET mcimadamore@83: } mcimadamore@221: mcimadamore@221: /** mcimadamore@221: * Get a list of all the enabled verbosity options. mcimadamore@221: * @return verbosity options mcimadamore@221: */ mcimadamore@221: public Configuration getConfiguration(); mcimadamore@221: //where mcimadamore@221: mcimadamore@221: /** mcimadamore@221: * This interface provides functionalities for tuning the output of a mcimadamore@221: * diagnostic formatter in multiple ways. mcimadamore@221: */ mcimadamore@221: interface Configuration { mcimadamore@221: /** mcimadamore@221: * Configure the set of diagnostic parts that should be displayed mcimadamore@221: * by the formatter. mcimadamore@221: * @param options options to set mcimadamore@221: */ mcimadamore@221: public void setVisible(Set visibleParts); mcimadamore@221: mcimadamore@221: /** mcimadamore@221: * Retrieve the set of diagnostic parts that should be displayed mcimadamore@221: * by the formatter. mcimadamore@221: * @return verbosity options mcimadamore@221: */ mcimadamore@221: public Set getVisible(); mcimadamore@221: mcimadamore@221: //where mcimadamore@221: /** mcimadamore@221: * A given diagnostic message can be divided into sub-parts each of which mcimadamore@221: * might/might not be displayed by the formatter, according to the mcimadamore@221: * current configuration settings. mcimadamore@221: */ mcimadamore@221: public enum DiagnosticPart { mcimadamore@221: /** mcimadamore@221: * Short description of the diagnostic - usually one line long. mcimadamore@221: */ mcimadamore@221: SUMMARY, mcimadamore@221: /** mcimadamore@221: * Longer description that provides additional details w.r.t. the ones mcimadamore@221: * in the diagnostic's description. mcimadamore@221: */ mcimadamore@221: DETAILS, mcimadamore@221: /** mcimadamore@221: * Source line the diagnostic refers to (if applicable). mcimadamore@221: */ mcimadamore@221: SOURCE, mcimadamore@221: /** mcimadamore@221: * Subdiagnostics attached to a given multiline diagnostic. mcimadamore@221: */ mcimadamore@221: SUBDIAGNOSTICS, mcimadamore@221: /** mcimadamore@221: * JLS paragraph this diagnostic might refer to (if applicable). mcimadamore@221: */ mcimadamore@221: JLS; mcimadamore@221: } mcimadamore@221: mcimadamore@221: /** mcimadamore@221: * Set a limit for multiline diagnostics. mcimadamore@221: * Note: Setting a limit has no effect if multiline diagnostics are either mcimadamore@221: * fully enabled or disabled. mcimadamore@221: * mcimadamore@221: * @param limit the kind of limit to be set mcimadamore@221: * @param value the limit value mcimadamore@221: */ mcimadamore@221: public void setMultilineLimit(MultilineLimit limit, int value); mcimadamore@221: mcimadamore@221: /** mcimadamore@221: * Get a multiline diagnostic limit. mcimadamore@221: * mcimadamore@221: * @param limit the kind of limit to be retrieved mcimadamore@221: * @return limit value or -1 if no limit is set mcimadamore@221: */ mcimadamore@221: public int getMultilineLimit(MultilineLimit limit); mcimadamore@221: //where mcimadamore@221: /** mcimadamore@221: * A multiline limit control the verbosity of multiline diagnostics mcimadamore@221: * either by setting a maximum depth of nested multidiagnostics, mcimadamore@221: * or by limiting the amount of subdiagnostics attached to a given mcimadamore@221: * diagnostic (or both). mcimadamore@221: */ mcimadamore@221: public enum MultilineLimit { mcimadamore@221: /** mcimadamore@221: * Controls the maximum depth of nested multiline diagnostics. mcimadamore@221: */ mcimadamore@221: DEPTH, mcimadamore@221: /** mcimadamore@221: * Controls the maximum amount of subdiagnostics that are part of a mcimadamore@221: * given multiline diagnostic. mcimadamore@221: */ mcimadamore@221: LENGTH; mcimadamore@221: } mcimadamore@221: } mcimadamore@83: }