當前位置: 首頁>>代碼示例>>Java>>正文


Java CompilerError類代碼示例

本文整理匯總了Java中org.codehaus.plexus.compiler.CompilerError的典型用法代碼示例。如果您正苦於以下問題:Java CompilerError類的具體用法?Java CompilerError怎麽用?Java CompilerError使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CompilerError類屬於org.codehaus.plexus.compiler包,在下文中一共展示了CompilerError類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: shortMessage

import org.codehaus.plexus.compiler.CompilerError; //導入依賴的package包/類
/**
 * Short message will have the error message if there's only one, useful for errors forking the compiler
 *
 * @param messages a {@link java.util.List} object.
 * @return the short error message
 * @since 2.0.2
 */
public static String shortMessage( List<CompilerError> messages )
{
    StringBuffer sb = new StringBuffer();

    sb.append( "Compilation failure" );

    if ( messages.size() == 1 )
    {
        sb.append( LS );

        CompilerError compilerError = (CompilerError) messages.get( 0 );

        sb.append( compilerError ).append( LS );
    }
    
    return sb.toString();
}
 
開發者ID:strator-dev,項目名稱:greenpepper,代碼行數:25,代碼來源:CompilationFailureException.java

示例2: logErrors

import org.codehaus.plexus.compiler.CompilerError; //導入依賴的package包/類
/**
 * Print a header with the given label and print all errors similar to the style
 * maven itself uses
 * @param errors Errors to print
 * @param label The label (usually ERRORS or WARNINGS) to head the error list
 * @param log The log to which the messages are printed
 */
private static final void logErrors(final List<CompilerError> errors, final String label,
                                    boolean warn, final Log log) {
    log.info("-------------------------------------------------------------");
    log.warn("CHECKER FRAMEWORK " + label.toUpperCase() + ": ");
    log.info("-------------------------------------------------------------");
    for (final CompilerError error : errors) {
        final String msg = error.toString().trim();
        if(warn) {
            log.warn(msg);
        } else {
            log.error(msg);
        }
    }

    final String labelLc = label.toLowerCase() + ((errors.size() == 1) ? "" : "s");
    log.info(errors.size() + " " + labelLc);
    log.info("-------------------------------------------------------------");
}
 
開發者ID:reprogrammer,項目名稱:checker-framework,代碼行數:26,代碼來源:MavenIOExecutor.java

示例3: longMessage

import org.codehaus.plexus.compiler.CompilerError; //導入依賴的package包/類
/**
 * <p>longMessage.</p>
 *
 * @param messages a {@link java.util.List} object.
 * @return a {@link java.lang.String} object.
 */
public static String longMessage( List<CompilerError> messages )
{
    StringBuffer sb = new StringBuffer();

    if ( messages != null )
    {
        for ( CompilerError compilerError : messages )
        {
            sb.append( compilerError ).append( LS );
        }
    }
    return sb.toString();
}
 
開發者ID:strator-dev,項目名稱:greenpepper,代碼行數:20,代碼來源:CompilationFailureException.java

示例4: parseMessages

import org.codehaus.plexus.compiler.CompilerError; //導入依賴的package包/類
/**
    * Parses the compiler error output into a list of {@code CompilerError} objects.
    *
    * @param input the compiler error output
    * @return the parsed error output
    */

    public static List<CompilerError> parseMessages(String input) {
        List<CompilerError> errors = new ArrayList<CompilerError>();

        try {
        final BufferedReader reader = new BufferedReader(new StringReader(input));
        try {
            final StringBuilder errorBuffer = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                if (line.isEmpty()) {
                    continue;
                }

                // Skip summary of warnings/errors
                if (Character.isDigit(line.charAt(0))) {
                    continue;
                }

                // Start of a new message?
                if (errorBuffer.length() > 0 && !Character.isWhitespace(line.charAt(0))) {
                    errors.add(parseMessage(errorBuffer.toString()));
                    errorBuffer.setLength(0);
                }
                errorBuffer.append(line).append(EOL);
            }

            // Handle the last message
            if (errorBuffer.length() > 0) {
                errors.add(parseMessage(errorBuffer.toString()));
            }

            return errors;
        } finally {
            reader.close();
        }
    } catch (IOException e) {
        // Should never happen
        throw new RuntimeException(e);
    }
}
 
開發者ID:reprogrammer,項目名稱:checker-framework,代碼行數:48,代碼來源:JavacErrorMessagesParser.java

示例5: CompilationFailureException

import org.codehaus.plexus.compiler.CompilerError; //導入依賴的package包/類
/**
 * <p>Constructor for CompilationFailureException.</p>
 *
 * @param messages a {@link java.util.List} object.
 */
public CompilationFailureException( List<CompilerError> messages )
{
    super( null, shortMessage( messages ), longMessage( messages ) );
}
 
開發者ID:strator-dev,項目名稱:greenpepper,代碼行數:10,代碼來源:CompilationFailureException.java


注:本文中的org.codehaus.plexus.compiler.CompilerError類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。