mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
jdk 6+: do not swallow error message endings
This commit is contained in:
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
package com.intellij.compiler;
|
||||
|
||||
import com.intellij.compiler.impl.javaCompiler.FileObject;
|
||||
import com.intellij.openapi.compiler.CompilerMessageCategory;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.compiler.impl.javaCompiler.FileObject;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -29,6 +29,7 @@ public abstract class OutputParser {
|
||||
public interface Callback {
|
||||
@NonNls String getNextLine();
|
||||
@NonNls String getCurrentLine();
|
||||
void pushBack(String line);
|
||||
void setProgressText(String text);
|
||||
void fileProcessed(@NonNls String path);
|
||||
void fileGenerated(@NonNls FileObject path);
|
||||
|
||||
+13
@@ -44,6 +44,7 @@ public class CompilerParsingThread implements Runnable, OutputParser.Callback {
|
||||
private final boolean myIsUnitTestMode;
|
||||
private FileObject myClassFileToProcess = null;
|
||||
private String myLastReadLine = null;
|
||||
private String myPushBackLine = null;
|
||||
private volatile boolean myProcessExited = false;
|
||||
private final CompileContext myContext;
|
||||
|
||||
@@ -104,6 +105,12 @@ public class CompilerParsingThread implements Runnable, OutputParser.Callback {
|
||||
}
|
||||
|
||||
public final String getNextLine() {
|
||||
final String pushBack = myPushBackLine;
|
||||
if (pushBack != null) {
|
||||
myPushBackLine = null;
|
||||
myLastReadLine = pushBack;
|
||||
return pushBack;
|
||||
}
|
||||
final String line = readLine(myCompilerOutStreamReader);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("LIne read: #" + line + "#");
|
||||
@@ -120,6 +127,12 @@ public class CompilerParsingThread implements Runnable, OutputParser.Callback {
|
||||
return myLastReadLine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pushBack(String line) {
|
||||
myLastReadLine = null;
|
||||
myPushBackLine = line;
|
||||
}
|
||||
|
||||
public final void fileGenerated(FileObject path) {
|
||||
// javac first logs file generated, then starts to write the file to disk,
|
||||
// so this thread sometimes can stumble on not yet existing file,
|
||||
|
||||
+12
@@ -127,6 +127,14 @@ public class JavacOutputParser extends OutputParser {
|
||||
final CharSequence chars = prevLine == null ? line : prevLine;
|
||||
final int offset = Math.max(0, Math.min(chars.length(), nextLine.indexOf('^')));
|
||||
colNum = EditorUtil.calcColumnNumber(null, chars,0, offset, myTabSize);
|
||||
String messageEnd = callback.getNextLine();
|
||||
while (isMessageEnd(messageEnd)) {
|
||||
messages.add(messageEnd.trim());
|
||||
messageEnd = callback.getNextLine();
|
||||
}
|
||||
if (messageEnd != null) {
|
||||
callback.pushBack(messageEnd);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (prevLine != null) {
|
||||
@@ -168,6 +176,10 @@ public class JavacOutputParser extends OutputParser {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isMessageEnd(String line) {
|
||||
return line != null && line.length() > 0 && Character.isWhitespace(line.charAt(0));
|
||||
}
|
||||
|
||||
|
||||
private static List<String> convertMessages(List<String> messages) {
|
||||
if(messages.size() <= 1) {
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
package com.intellij.lang.ant.config.execution;
|
||||
|
||||
import com.intellij.compiler.impl.javaCompiler.FileObject;
|
||||
import com.intellij.compiler.impl.javaCompiler.javac.JavacOutputParser;
|
||||
import com.intellij.compiler.impl.javaCompiler.jikes.JikesOutputParser;
|
||||
import com.intellij.compiler.impl.javaCompiler.FileObject;
|
||||
import com.intellij.execution.process.OSProcessHandler;
|
||||
import com.intellij.lang.ant.AntBundle;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -240,7 +240,7 @@ public class OutputParser{
|
||||
}
|
||||
|
||||
com.intellij.compiler.OutputParser.Callback callback = new com.intellij.compiler.OutputParser.Callback() {
|
||||
private int myIndex = 0;
|
||||
private int myIndex = -1;
|
||||
|
||||
@Nullable
|
||||
public String getCurrentLine() {
|
||||
@@ -251,7 +251,16 @@ public class OutputParser{
|
||||
}
|
||||
|
||||
public String getNextLine() {
|
||||
return javacMessages.get(myIndex++);
|
||||
final int next = myIndex + 1;
|
||||
if (next >= javacMessages.size()) {
|
||||
return null;
|
||||
}
|
||||
return javacMessages.get(myIndex = next);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pushBack(String line) {
|
||||
myIndex--;
|
||||
}
|
||||
|
||||
public void message(final CompilerMessageCategory category,
|
||||
|
||||
Reference in New Issue
Block a user