/* * Copyright (c) 2007 BUSINESS OBJECTS SOFTWARE LIMITED * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Business Objects nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * CompilerMessageLogger.java * Created: Apr 16, 2004 * By: Bo Ilic (extracted from original logging code in CALCompiler by Luke) */ package org.openquark.cal.compiler; import java.util.List; /** * Used by the compilation process (i.e. parsing, static analysis, type-checking, * code generation), to log messages of interest. * @author Luke Evans */ public interface CompilerMessageLogger { /** * Log the given compiler message. * If the message has severity FATAL, then an exception is raised to immediately halt * compilation. Otherwise, if the message has severity ERROR and the maximum number of * such errors has been reported then a 'too many errors' exception is raised. * * @param compilerMessage CompilerMessage the error/warning/info message * @throws CompilerMessage.AbortCompilation if a FATAL message is received or * too many ERROR messages are received */ public void logMessage(CompilerMessage compilerMessage); /** * Log compiler messages from another message logger. * * @param otherLogger the logger whose messages will be logged to this logger. */ public void logMessages(CompilerMessageLogger otherLogger); /** * Get all the compiler messages generated by a compile cycle. * * @return the error/warning/info messages */ public List<CompilerMessage> getCompilerMessages(); /** * Get all the compiler messages of the given severity and above, generated by a compile cycle. * * @param minSeverity * @return the error/warning/info messages */ public List<CompilerMessage> getCompilerMessages(CompilerMessage.Severity minSeverity); /** * @return the number of messages held onto by the logger. */ public int getNMessages(); /** * @return int the number of messages that are of severity error or more. */ public int getNErrors(); /** * Get the first error generated by the compile cycle, or null if there is none. * Note: this is an actual first error and doesn't include warnings or info messages. * @return CompilerMessage the first actual error */ public CompilerMessage getFirstError(); /** * Method getMaxSeverity. * @return CompilerMessage.Severity the maximum severity of a message encountered since the last * time compiler messages were cleared. */ public CompilerMessage.Severity getMaxSeverity(); }