package org.jetbrains.jps.incremental.messages;
import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.util.Function;
-import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.PrintStream;
-import java.util.Collection;
-import java.util.Collections;
/**
* @author Eugene Zhuravlev
private final long myProblemBeginOffset;
private final long myProblemEndOffset;
private final long myProblemLocationOffset;
- private final Collection<String> mySourcePaths;
+ private final String mySourcePath;
private final long myLine;
private final long myColumn;
public CompilerMessage(@NotNull String compilerName, @NotNull Throwable internalError) {
- this(compilerName, Kind.ERROR, getTextFromThrowable(internalError));
+ this(compilerName, Kind.ERROR, getTextFromThrowable(internalError), null, -1L, -1L, -1L, -1L, -1L);
}
public CompilerMessage(@NotNull String compilerName, Kind kind, String messageText) {
- this(compilerName, kind, messageText, (String)null, -1L, -1L, -1L, -1L, -1L);
- }
-
- public CompilerMessage(@NotNull String compilerName, String messageText, Collection<String> sourcePaths, Kind kind) {
- this(compilerName, kind, messageText, sourcePaths, -1L, -1L, -1L, -1L, -1L);
+ this(compilerName, kind, messageText, null, -1L, -1L, -1L, -1L, -1L);
}
public CompilerMessage(@NotNull String compilerName, Kind kind, String messageText, String sourcePath) {
- this(compilerName, messageText, sourcePath == null ? Collections.<String>emptyList() : Collections.singleton(sourcePath), kind);
+ this(compilerName, kind, messageText, sourcePath, -1L, -1L, -1L, -1L, -1L);
}
public CompilerMessage(@NotNull String compilerName, Kind kind, String messageText,
- @NotNull Collection<String> sourcePaths,
+ @Nullable String sourcePath,
long problemBeginOffset,
long problemEndOffset,
long problemLocationOffset,
myProblemBeginOffset = problemBeginOffset;
myProblemEndOffset = problemEndOffset;
myProblemLocationOffset = problemLocationOffset;
- mySourcePaths = ContainerUtil.map(sourcePaths, new Function<String, String>() {
- @Override
- public String fun(String s) {
- return s.replace(File.separatorChar, '/');
- }
- });
+ mySourcePath = sourcePath != null && !sourcePath.isEmpty()? sourcePath.replace(File.separatorChar, '/') : null;
myLine = locationLine;
myColumn = locationColumn;
}
- public CompilerMessage(@NotNull String compilerName, Kind kind, String messageText,
- @Nullable String sourcePath,
- long problemBeginOffset,
- long problemEndOffset,
- long problemLocationOffset,
- long locationLine,
- long locationColumn) {
- this(compilerName,
- kind,
- messageText,
- sourcePath == null ? Collections.<String>emptyList() : Collections.singleton(sourcePath),
- problemBeginOffset,
- problemEndOffset,
- problemLocationOffset,
- locationLine,
- locationColumn);
- }
-
@NotNull
public String getCompilerName() {
return myCompilerName;
@Nullable
public String getSourcePath() {
- return mySourcePaths.size() == 1 ? ContainerUtil.getFirstItem(mySourcePaths) : null;
+ return mySourcePath;
}
public long getLine() {
public String toString() {
final StringBuilder builder = new StringBuilder();
builder.append(getCompilerName()).append(":").append(getKind().name()).append(":").append(super.toString());
- String result;
- if (mySourcePaths.isEmpty()) {
- result = null;
- }
- else if (mySourcePaths.size() == 1) {
- result = ContainerUtil.getFirstItem(mySourcePaths);
- } else {
- result = mySourcePaths.toString();
- }
- final String path = result;
+ final String path = getSourcePath();
if (path != null) {
builder.append("; file: ").append(path);
final long line = getLine();