815N/A * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 82N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 82N/A * This code is free software; you can redistribute it and/or modify it 82N/A * under the terms of the GNU General Public License version 2 only, as 553N/A * published by the Free Software Foundation. Oracle designates this 82N/A * particular file as subject to the "Classpath" exception as provided 553N/A * by Oracle in the LICENSE file that accompanied this code. 82N/A * This code is distributed in the hope that it will be useful, but WITHOUT 82N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 82N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 82N/A * version 2 for more details (a copy is included in the LICENSE file that 82N/A * accompanied this code). 82N/A * You should have received a copy of the GNU General Public License version 82N/A * 2 along with this work; if not, write to the Free Software Foundation, 82N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 553N/A * or visit www.oracle.com if you need additional information or have any 82N/A * This abstract class provides a basic implementation of the functionalities that should be provided 82N/A * by any formatter used by javac. Among the main features provided by AbstractDiagnosticFormatter are: 82N/A * <li> Provides a standard implementation of the visitor-like methods defined in the interface DiagnisticFormatter. 82N/A * Those implementations are specifically targeting JCDiagnostic objects. 82N/A * <li> Provides basic support for i18n and a method for executing all locale-dependent conversions 82N/A * <li> Provides the formatting logic for rendering the arguments of a JCDiagnostic object. 580N/A * <p><b>This is NOT part of any supported API. 332N/A * If you write code that depends on this, you do so at your own risk. 332N/A * This code and its internal interfaces are subject to change or 332N/A * deletion without notice.</b> 220N/A * JavacMessages object used by this formatter for i18n. 237N/A * Configuration object used by this formatter 237N/A * Current depth level of the disgnostic being formatted 237N/A * (!= 0 for subdiagnostics) 287N/A * All captured types that have been encountered during diagnostic formatting. 287N/A * This info is used by the FormatterPrinter in order to print friendly unique 287N/A * ids for captured types 220N/A * Initialize an AbstractDiagnosticFormatter by setting its JavacMessages object. 82N/A * Format the arguments of a given diagnostic. 82N/A * @param d diagnostic whose arguments are to be formatted 82N/A * @param l locale object to be used for i18n 82N/A * @return a Collection whose elements are the formatted arguments of the diagnostic 82N/A * Format a single argument of a given diagnostic. 82N/A * @param d diagnostic whose argument is to be formatted 82N/A * @param arg argument to be formatted 82N/A * @param l locale object to be used for i18n 82N/A * @return string representation of the diagnostic argument 82N/A * Format an iterable argument of a given diagnostic. 82N/A * @param d diagnostic whose argument is to be formatted 82N/A * @param it iterable argument to be formatted 82N/A * @param l locale object to be used for i18n 82N/A * @return string representation of the diagnostic iterable argument 220N/A * Format all the subdiagnostics attached to a given diagnostic. 167N/A * @param d diagnostic whose subdiagnostics are to be formatted 167N/A * @param l locale object to be used for i18n 220N/A * @return list of all string representations of the subdiagnostics 220N/A * Format a subdiagnostics attached to a given diagnostic. 220N/A * @param parent multiline diagnostic whose subdiagnostics is to be formatted 220N/A * @param sub subdiagnostic to be formatted 220N/A * @param l locale object to be used for i18n 167N/A * @return string representation of the subdiagnostics 136N/A /** Format the faulty source code line and point to the error. 136N/A * @param d The diagnostic for which the error line should be printed 220N/A * Converts a String into a locale-dependent representation accordingly to a given locale. 82N/A * @param l locale object to be used for i18n 82N/A * @param key locale-independent key used for looking up in a resource file 82N/A * @param args localization arguments 82N/A * @return a locale-dependent string 167N/A * Creates a string with a given amount of empty spaces. Useful for 167N/A * indenting the text of a diagnostic message. 167N/A * @param nSpaces the amount of spaces to be added to the result string 167N/A * @return the indentation string 167N/A * Indent a string by prepending a given amount of empty spaces to each line 167N/A * @param s the string to be indented 167N/A * @param nSpaces the amount of spaces that should be prepended to each line 167N/A * @return an indented string 220N/A * Shows a '^' sign under the source line displayed by the formatter 220N/A * @param caretEnabled if true enables caret 220N/A * Tells whether the caret display is active or not. 220N/A * @param caretEnabled if true the caret is enabled 237N/A * AbstractDiagnosticFormatter. Provides alternate numbering of captured 237N/A * types (they are numbered starting from 1 on each new diagnostic, instead 237N/A * of relying on the underlying hashcode() method which generates unstable 237N/A * output). Also detects cycles in wildcard messages (e.g. if the wildcard 237N/A * type referred by a given captured type C contains C itself) which might 237N/A * lead to infinite loops.