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

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