Search in sources :

Example 11 with CompilerMessageCategory

use of com.intellij.openapi.compiler.CompilerMessageCategory in project intellij-plugins by JetBrains.

the class FlexCompilerHandler method dispatchError.

private static void dispatchError(final String errLine, final CompilerMessagesBuffer messagesBuffer) {
    final Matcher matcher = FlexCommonUtils.ERROR_PATTERN.matcher(errLine);
    if (matcher.matches()) {
        final String file = matcher.group(1);
        final String additionalInfo = matcher.group(2);
        final String line = matcher.group(3);
        final String column = matcher.group(4);
        final String type = matcher.group(5);
        final String message = matcher.group(6);
        final CompilerMessageCategory messageCategory = "Warning".equals(type) ? CompilerMessageCategory.WARNING : CompilerMessageCategory.ERROR;
        final VirtualFile relativeFile = VfsUtil.findRelativeFile(file, null);
        final StringBuilder fullMessage = new StringBuilder();
        if (relativeFile == null)
            fullMessage.append(file).append(": ");
        if (additionalInfo != null)
            fullMessage.append(additionalInfo).append(' ');
        fullMessage.append(message);
        messagesBuffer.addMessage(messageCategory, fullMessage.toString(), relativeFile != null ? relativeFile.getUrl() : null, line != null ? Integer.parseInt(line) : 0, column != null ? Integer.parseInt(column) : 0);
    } else if (isErrorMessage(errLine)) {
        final String errorPrefix = "Error: ";
        final String errorText = errLine.startsWith(errorPrefix) ? errLine.substring(errorPrefix.length()) : errLine;
        messagesBuffer.addMessage(CompilerMessageCategory.ERROR, errorText, null, -1, -1);
    } else {
        messagesBuffer.addMessage(CompilerMessageCategory.INFORMATION, errLine, null, -1, -1);
    }
}
Also used : CompilerMessageCategory(com.intellij.openapi.compiler.CompilerMessageCategory) Matcher(java.util.regex.Matcher)

Example 12 with CompilerMessageCategory

use of com.intellij.openapi.compiler.CompilerMessageCategory in project intellij-plugins by JetBrains.

the class ASC20CompilationTask method handleCompilerMessage.

/**
   * @return <code>false</code> if error reported
   */
private boolean handleCompilerMessage(final FlexCompilationManager compilationManager, final String message) {
    if ("^".equals(message)) {
        // ignore this and previous line - no need to print source code in Messages tool window
        myPreviousUnreportedMessage = null;
        return true;
    }
    if ("command line".equals(message)) {
        // ignore this line and print previous if any
        printPreviousLine(compilationManager);
        return true;
    }
    if (message.startsWith("Exception in thread \"")) {
        printPreviousLine(compilationManager);
        compilationManager.addMessage(this, CompilerMessageCategory.ERROR, message, null, -1, -1);
        return false;
    }
    // see messages_en.properties from Falcon sources
    if (message.startsWith("Warning: ") || message.startsWith("Error: ") || message.startsWith("Syntax error: ") || message.startsWith("Internal error: ")) {
        final CompilerMessageCategory category = message.startsWith("Warning: ") ? CompilerMessageCategory.WARNING : CompilerMessageCategory.ERROR;
        final int index = message.indexOf(": ");
        final String usefulMessage = message.substring(index + ": ".length());
        final Pair<String, Integer> sourcePathAndLine = FlexCommonUtils.getSourcePathAndLineFromASC20Message(myPreviousUnreportedMessage);
        if (sourcePathAndLine == null) {
            printPreviousLine(compilationManager);
            compilationManager.addMessage(this, category, usefulMessage, null, -1, -1);
        } else {
            if (!isNotSupportedOptionFromGeneratedConfig(usefulMessage, sourcePathAndLine.first)) {
                compilationManager.addMessage(this, category, usefulMessage, VfsUtilCore.pathToUrl(sourcePathAndLine.first), sourcePathAndLine.second, -1);
            }
        }
        myPreviousUnreportedMessage = null;
        return category == CompilerMessageCategory.WARNING;
    }
    printPreviousLine(compilationManager);
    myPreviousUnreportedMessage = message;
    return true;
}
Also used : CompilerMessageCategory(com.intellij.openapi.compiler.CompilerMessageCategory)

Aggregations

CompilerMessageCategory (com.intellij.openapi.compiler.CompilerMessageCategory)12 Nullable (org.jetbrains.annotations.Nullable)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 File (java.io.File)3 Matcher (java.util.regex.Matcher)3 IAndroidTarget (com.android.sdklib.IAndroidTarget)2 ModuleCompileScope (com.intellij.compiler.impl.ModuleCompileScope)2 Module (com.intellij.openapi.module.Module)2 Navigatable (com.intellij.pom.Navigatable)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 JavacOutputParser (com.intellij.compiler.impl.javaCompiler.javac.JavacOutputParser)1 ExecutionException (com.intellij.execution.ExecutionException)1 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)1 JavaParameters (com.intellij.execution.configurations.JavaParameters)1 ModalityState (com.intellij.openapi.application.ModalityState)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 ToolWindow (com.intellij.openapi.wm.ToolWindow)1 Problem (com.intellij.problems.Problem)1 WolfTheProblemSolver (com.intellij.problems.WolfTheProblemSolver)1