diff --git a/.consulo/codeStyleSettings.xml b/.consulo/codeStyleSettings.xml
index 2ec06c7..6aa7185 100644
--- a/.consulo/codeStyleSettings.xml
+++ b/.consulo/codeStyleSettings.xml
@@ -4,6 +4,6 @@
-
+
\ No newline at end of file
diff --git a/ant-impl/src/main/java/com/intellij/lang/ant/config/execution/ExecutionHandler.java b/ant-impl/src/main/java/com/intellij/lang/ant/config/execution/ExecutionHandler.java
index f04bc4a..716850d 100644
--- a/ant-impl/src/main/java/com/intellij/lang/ant/config/execution/ExecutionHandler.java
+++ b/ant-impl/src/main/java/com/intellij/lang/ant/config/execution/ExecutionHandler.java
@@ -15,14 +15,14 @@
*/
package com.intellij.lang.ant.config.execution;
-import com.intellij.lang.ant.AntBundle;
import com.intellij.lang.ant.config.AntBuildFile;
import com.intellij.lang.ant.config.AntBuildFileBase;
import com.intellij.lang.ant.config.AntBuildListener;
import com.intellij.lang.ant.config.actions.RunAction;
import com.intellij.lang.ant.config.impl.BuildFileProperty;
import consulo.apache.ant.execution.OutputWatcher;
-import consulo.application.ApplicationManager;
+import consulo.apache.ant.impl.localize.ApacheAntImplLocalize;
+import consulo.application.Application;
import consulo.application.progress.ProgressIndicator;
import consulo.application.progress.Task;
import consulo.application.util.concurrent.AppExecutorUtil;
@@ -37,6 +37,7 @@
import consulo.execution.CantRunException;
import consulo.execution.ui.awt.ExecutionErrorDialog;
import consulo.localHistory.LocalHistory;
+import consulo.localize.LocalizeValue;
import consulo.logging.Logger;
import consulo.pathMacro.Macro;
import consulo.process.ExecutionException;
@@ -45,6 +46,7 @@
import consulo.process.event.ProcessEvent;
import consulo.process.event.ProcessListener;
import consulo.project.Project;
+import consulo.ui.annotation.RequiredUIAccess;
import consulo.util.lang.StringUtil;
import consulo.virtualFileSystem.encoding.EncodingProjectManager;
import consulo.virtualFileSystem.util.VirtualFileUtil;
@@ -55,195 +57,204 @@
import java.util.concurrent.TimeUnit;
public final class ExecutionHandler {
- private static final Logger LOG = Logger.getInstance(ExecutionHandler.class);
-
- private ExecutionHandler() {
- }
-
- /**
- * @param antBuildListener should not be null. Use {@link com.intellij.lang.ant.config.AntBuildListener#NULL}
- */
- public static void runBuild(AntBuildFileBase buildFile,
- String[] targets,
- DataContext dataContext,
- List additionalProperties,
- @Nonnull AntBuildListener antBuildListener) {
- FileDocumentManager.getInstance().saveAllDocuments();
- final AntCommandLineBuilder builder = new AntCommandLineBuilder();
- BuildViewManager buildViewManager = BuildViewManager.getInstance(buildFile.getProject());
- final GeneralCommandLine commandLine;
- BuildProgress buildProgress;
- Project project = buildFile.getProject();
-
- try {
- builder.setBuildFile(buildFile.getAllOptions(), VirtualFileUtil.virtualToIoFile(buildFile.getVirtualFile()));
- builder.calculateProperties(dataContext, additionalProperties);
- builder.addTargets(targets);
-
- builder.getJavaParameters().setCharset(EncodingProjectManager.getInstance(buildFile.getProject()).getDefaultCharset());
-
- buildProgress = buildViewManager.createBuildProgress();
-
- commandLine = builder.getJavaParameters().toCommandLine();
- }
- catch (RunCanceledException e) {
- e.showMessage(project, AntBundle.message("run.ant.erorr.dialog.title"));
- antBuildListener.buildFinished(AntBuildListener.FAILED_TO_RUN, 0);
- return;
- }
- catch (CantRunException e) {
- ExecutionErrorDialog.show(e, AntBundle.message("cant.run.ant.erorr.dialog.title"), project);
- antBuildListener.buildFinished(AntBuildListener.FAILED_TO_RUN, 0);
- return;
- }
- catch (Macro.ExecutionCancelledException e) {
- antBuildListener.buildFinished(AntBuildListener.ABORTED, 0);
- return;
- }
- catch (Throwable e) {
- antBuildListener.buildFinished(AntBuildListener.FAILED_TO_RUN, 0);
- LOG.error(e);
- return;
+ private static final Logger LOG = Logger.getInstance(ExecutionHandler.class);
+
+ private ExecutionHandler() {
}
- final boolean startInBackground = buildFile.isRunInBackground();
+ /**
+ * @param antBuildListener should not be null. Use {@link com.intellij.lang.ant.config.AntBuildListener#NULL}
+ */
+ @RequiredUIAccess
+ public static void runBuild(
+ AntBuildFileBase buildFile,
+ String[] targets,
+ DataContext dataContext,
+ List additionalProperties,
+ @Nonnull AntBuildListener antBuildListener
+ ) {
+ FileDocumentManager.getInstance().saveAllDocuments();
+ AntCommandLineBuilder builder = new AntCommandLineBuilder();
+ BuildViewManager buildViewManager = BuildViewManager.getInstance(buildFile.getProject());
+ final GeneralCommandLine commandLine;
+ BuildProgress buildProgress;
+ Project project = buildFile.getProject();
+
+ try {
+ builder.setBuildFile(buildFile.getAllOptions(), VirtualFileUtil.virtualToIoFile(buildFile.getVirtualFile()));
+ builder.calculateProperties(dataContext, additionalProperties);
+ builder.addTargets(targets);
- new Task.Backgroundable(buildFile.getProject(), AntBundle.message("ant.build.progress.dialog.title"), true) {
+ builder.getJavaParameters().setCharset(EncodingProjectManager.getInstance(buildFile.getProject()).getDefaultCharset());
- @Override
- public boolean shouldStartInBackground() {
- return startInBackground;
- }
+ buildProgress = buildViewManager.createBuildProgress();
- @Override
- public void run(@Nonnull final ProgressIndicator indicator) {
- try {
- runBuild(indicator, buildFile, antBuildListener, commandLine, buildProgress, targets);
+ commandLine = builder.getJavaParameters().toCommandLine();
+ }
+ catch (RunCanceledException e) {
+ e.showMessage(project, ApacheAntImplLocalize.runAntErorrDialogTitle());
+ antBuildListener.buildFinished(AntBuildListener.FAILED_TO_RUN, 0);
+ return;
+ }
+ catch (CantRunException e) {
+ ExecutionErrorDialog.show(e, ApacheAntImplLocalize.cantRunAntErorrDialogTitle().get(), project);
+ antBuildListener.buildFinished(AntBuildListener.FAILED_TO_RUN, 0);
+ return;
+ }
+ catch (Macro.ExecutionCancelledException e) {
+ antBuildListener.buildFinished(AntBuildListener.ABORTED, 0);
+ return;
}
catch (Throwable e) {
- LOG.error(e);
- antBuildListener.buildFinished(AntBuildListener.FAILED_TO_RUN, 0);
+ antBuildListener.buildFinished(AntBuildListener.FAILED_TO_RUN, 0);
+ LOG.error(e);
+ return;
}
- }
- }.queue();
- }
-
- private static void runBuild(@Nonnull ProgressIndicator progress,
- @Nonnull final AntBuildFileBase buildFile,
- @Nonnull final AntBuildListener antBuildListener,
- @Nonnull GeneralCommandLine commandLine,
- @Nonnull BuildProgress buildProgress,
- String[] targets) {
- final Project project = buildFile.getProject();
-
- String id = UUID.randomUUID().toString();
-
- String title = AntBundle.message("ant.build.local.history.label", buildFile.getName());
- DefaultBuildDescriptor buildDescriptor =
- new DefaultBuildDescriptor(id,
- buildFile.getName(),
- StringUtil.notNullize(buildFile.getVirtualFile().getParent().getPath()),
- System.currentTimeMillis());
- buildDescriptor.setActivateToolWindowWhenAdded(true);
- buildDescriptor.withRestartAction(new RunAction(buildFile, targets));
- buildProgress.start(new BuildProgressDescriptor() {
- @Nonnull
- @Override
- public String getTitle() {
- return buildFile.getName();
- }
-
- @Override
- @Nonnull
- public BuildDescriptor getBuildDescriptor() {
- return buildDescriptor;
- }
- });
-
- LocalHistory.getInstance().putSystemLabel(project, title);
- final AntProcessWrapper handler;
- try {
- handler = AntProcessWrapper.runCommandLine(commandLine);
- }
- catch (final ExecutionException e) {
- ApplicationManager.getApplication()
- .invokeLater(() -> ExecutionErrorDialog.show(e,
- AntBundle.message("could.not.start.process.erorr.dialog.title"),
- project));
-
- buildProgress.fail(System.currentTimeMillis(), e.getMessage());
- antBuildListener.buildFinished(AntBuildListener.FAILED_TO_RUN, 0);
- return;
- }
- processRunningAnt(progress, handler, buildFile, antBuildListener, buildProgress);
- handler.waitFor();
- }
+ final boolean startInBackground = buildFile.isRunInBackground();
+
+ new Task.Backgroundable(buildFile.getProject(), ApacheAntImplLocalize.antBuildProgressDialogTitle().get(), true) {
+ @Override
+ public boolean shouldStartInBackground() {
+ return startInBackground;
+ }
- private static void processRunningAnt(ProgressIndicator progress,
- AntProcessWrapper wrapper,
- AntBuildFile buildFile,
- AntBuildListener antBuildListener,
- @Nonnull BuildProgress buildProgress) {
- final Project project = buildFile.getProject();
+ @Override
+ public void run(@Nonnull ProgressIndicator indicator) {
+ try {
+ runBuild(indicator, buildFile, antBuildListener, commandLine, buildProgress, targets);
+ }
+ catch (Throwable e) {
+ LOG.error(e);
+ antBuildListener.buildFinished(AntBuildListener.FAILED_TO_RUN, 0);
+ }
+ }
+ }.queue();
+ }
- final CheckCancelTask checkCancelTask = new CheckCancelTask(progress, wrapper.getProcessHandler());
- checkCancelTask.start(0);
+ private static void runBuild(
+ @Nonnull ProgressIndicator progress,
+ @Nonnull AntBuildFileBase buildFile,
+ @Nonnull AntBuildListener antBuildListener,
+ @Nonnull GeneralCommandLine commandLine,
+ @Nonnull BuildProgress buildProgress,
+ String[] targets
+ ) {
+ Project project = buildFile.getProject();
- final OutputWatcher parser = OutputParser2.attachParser(project, wrapper, progress, buildFile, buildProgress);
+ String id = UUID.randomUUID().toString();
- wrapper.addProcessListener(new ProcessListener() {
- @Override
- public void processTerminated(ProcessEvent event) {
- checkCancelTask.cancel();
- parser.setStopped(true);
+ LocalizeValue title = ApacheAntImplLocalize.antBuildLocalHistoryLabel(buildFile.getName());
+ LocalizeValue buildFileName = LocalizeValue.ofNullable(buildFile.getName());
+ DefaultBuildDescriptor buildDescriptor = new DefaultBuildDescriptor(
+ id,
+ buildFileName,
+ StringUtil.notNullize(buildFile.getVirtualFile().getParent().getPath()),
+ System.currentTimeMillis()
+ );
+ buildDescriptor.setActivateToolWindowWhenAdded(true);
+ buildDescriptor.withRestartAction(new RunAction(buildFile, targets));
+ buildProgress.start(new BuildProgressDescriptor() {
+ @Nonnull
+ @Override
+ public LocalizeValue getTitle() {
+ return buildFileName;
+ }
- if (progress != null && progress.isCanceled()) {
- buildProgress.cancel();
- antBuildListener.buildFinished(AntBuildListener.ABORTED, 0);
- }
- else if (parser.getErrorsCount() > 0) {
- buildProgress.fail();
- antBuildListener.buildFinished(AntBuildListener.FINISHED_SUCCESSFULLY, parser.getErrorsCount());
+ @Override
+ @Nonnull
+ public BuildDescriptor getBuildDescriptor() {
+ return buildDescriptor;
+ }
+ });
+
+ LocalHistory.getInstance().putSystemLabel(project, title);
+ AntProcessWrapper handler;
+ try {
+ handler = AntProcessWrapper.runCommandLine(commandLine);
}
- else {
- buildProgress.finish();
- antBuildListener.buildFinished(AntBuildListener.FINISHED_SUCCESSFULLY, 0);
+ catch (ExecutionException e) {
+ Application.get().invokeLater(() -> ExecutionErrorDialog.show(
+ e,
+ ApacheAntImplLocalize.couldNotStartProcessErorrDialogTitle().get(),
+ project
+ ));
+
+ buildProgress.fail(System.currentTimeMillis(), LocalizeValue.ofNullable(e.getMessage()));
+ antBuildListener.buildFinished(AntBuildListener.FAILED_TO_RUN, 0);
+ return;
}
- }
- });
- wrapper.startNotify();
- }
-
- static final class CheckCancelTask implements Runnable {
- private final ProgressIndicator myProgressIndicator;
- private final ProcessHandler myProcessHandler;
- private volatile boolean myCanceled;
-
- public CheckCancelTask(ProgressIndicator progressIndicator, ProcessHandler process) {
- myProgressIndicator = progressIndicator;
- myProcessHandler = process;
+
+ processRunningAnt(progress, handler, buildFile, antBuildListener, buildProgress);
+ handler.waitFor();
}
- public void cancel() {
- myCanceled = true;
+ private static void processRunningAnt(
+ ProgressIndicator progress,
+ AntProcessWrapper wrapper,
+ AntBuildFile buildFile,
+ AntBuildListener antBuildListener,
+ @Nonnull BuildProgress buildProgress
+ ) {
+ Project project = buildFile.getProject();
+
+ final CheckCancelTask checkCancelTask = new CheckCancelTask(progress, wrapper.getProcessHandler());
+ checkCancelTask.start(0);
+
+ final OutputWatcher parser = OutputParser2.attachParser(project, wrapper, progress, buildFile, buildProgress);
+
+ wrapper.addProcessListener(new ProcessListener() {
+ @Override
+ public void processTerminated(ProcessEvent event) {
+ checkCancelTask.cancel();
+ parser.setStopped(true);
+
+ if (progress != null && progress.isCanceled()) {
+ buildProgress.cancel();
+ antBuildListener.buildFinished(AntBuildListener.ABORTED, 0);
+ }
+ else if (parser.getErrorsCount() > 0) {
+ buildProgress.fail();
+ antBuildListener.buildFinished(AntBuildListener.FINISHED_SUCCESSFULLY, parser.getErrorsCount());
+ }
+ else {
+ buildProgress.finish();
+ antBuildListener.buildFinished(AntBuildListener.FINISHED_SUCCESSFULLY, 0);
+ }
+ }
+ });
+ wrapper.startNotify();
}
- @Override
- public void run() {
- if (!myCanceled) {
- try {
- myProgressIndicator.checkCanceled();
- start(50);
+ static final class CheckCancelTask implements Runnable {
+ private final ProgressIndicator myProgressIndicator;
+ private final ProcessHandler myProcessHandler;
+ private volatile boolean myCanceled;
+
+ public CheckCancelTask(ProgressIndicator progressIndicator, ProcessHandler process) {
+ myProgressIndicator = progressIndicator;
+ myProcessHandler = process;
}
- catch (ProcessCanceledException e) {
- myProcessHandler.destroyProcess();
+
+ public void cancel() {
+ myCanceled = true;
}
- }
- }
- public void start(final long delay) {
- AppExecutorUtil.getAppScheduledExecutorService().schedule(this, delay, TimeUnit.MILLISECONDS);
+ @Override
+ public void run() {
+ if (!myCanceled) {
+ try {
+ myProgressIndicator.checkCanceled();
+ start(50);
+ }
+ catch (ProcessCanceledException e) {
+ myProcessHandler.destroyProcess();
+ }
+ }
+ }
+
+ public void start(long delay) {
+ AppExecutorUtil.getAppScheduledExecutorService().schedule(this, delay, TimeUnit.MILLISECONDS);
+ }
}
- }
}
diff --git a/ant-impl/src/main/java/com/intellij/lang/ant/config/execution/OutputParser.java b/ant-impl/src/main/java/com/intellij/lang/ant/config/execution/OutputParser.java
index 782a812..14c9251 100644
--- a/ant-impl/src/main/java/com/intellij/lang/ant/config/execution/OutputParser.java
+++ b/ant-impl/src/main/java/com/intellij/lang/ant/config/execution/OutputParser.java
@@ -17,316 +17,329 @@
import com.intellij.java.compiler.impl.javaCompiler.FileObject;
import com.intellij.java.compiler.impl.javaCompiler.javac.JavacOutputParser;
-import com.intellij.lang.ant.AntBundle;
import consulo.apache.ant.execution.OutputWatcher;
+import consulo.apache.ant.impl.localize.ApacheAntImplLocalize;
import consulo.apache.ant.rt.common.AntLoggerConstants;
-import consulo.application.ApplicationManager;
+import consulo.application.Application;
import consulo.application.progress.ProgressIndicator;
+import consulo.compiler.CompileContext;
import consulo.compiler.CompilerMessageCategory;
+import consulo.localize.LocalizeValue;
import consulo.logging.Logger;
+import consulo.navigation.Navigatable;
import consulo.process.ProcessHandler;
import consulo.project.Project;
import consulo.virtualFileSystem.VirtualFile;
import consulo.virtualFileSystem.VirtualFileManager;
-import org.jetbrains.annotations.NonNls;
-
import jakarta.annotation.Nullable;
+
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
-//import com.intellij.compiler.impl.javaCompiler.jikes.JikesOutputParser;
-
public class OutputParser implements OutputWatcher {
-
- @NonNls private static final String JAVAC = "javac";
- @NonNls private static final String ECHO = "echo";
-
- private static final Logger LOG = Logger.getInstance("#com.intellij.ant.execution.OutputParser");
- private final Project myProject;
- private final OldAntBuildMessageView myMessageView;
- private final WeakReference myProgress;
- private final String myBuildName;
- private final ProcessHandler myProcessHandler;
- private boolean isStopped;
- private List myJavacMessages;
- private boolean myFirstLineProcessed;
- private boolean myStartedSuccessfully;
- private boolean myIsEcho;
-
- public OutputParser(Project project,
- ProcessHandler processHandler,
- OldAntBuildMessageView errorsView,
- ProgressIndicator progress,
- String buildName) {
- myProject = project;
- myProcessHandler = processHandler;
- myMessageView = errorsView;
- myProgress = new WeakReference(progress);
- myBuildName = buildName;
- myMessageView.setParsingThread(this);
- }
-
- @Override
- public final void stopProcess() {
- myProcessHandler.destroyProcess();
- }
-
- @Override
- public boolean isTerminateInvoked() {
- return myProcessHandler.isProcessTerminating();
- }
-
- protected Project getProject() {
- return myProject;
- }
-
- protected ProcessHandler getProcessHandler() {
- return myProcessHandler;
- }
-
- @Override
- public final boolean isStopped() {
- return isStopped;
- }
-
- @Override
- public final void setStopped(boolean stopped) {
- isStopped = stopped;
- }
-
- @Override
- public int getErrorsCount() {
- return 0;
- }
-
- private void setProgressStatistics(String s) {
- final ProgressIndicator progress = myProgress.get();
- if (progress != null) {
- progress.setText2(s);
+ private static final String JAVAC = "javac";
+ private static final String ECHO = "echo";
+
+ private static final Logger LOG = Logger.getInstance("#com.intellij.ant.execution.OutputParser");
+ private final Project myProject;
+ private final OldAntBuildMessageView myMessageView;
+ private final WeakReference myProgress;
+ private final String myBuildName;
+ private final ProcessHandler myProcessHandler;
+ private boolean isStopped;
+ private List myJavacMessages;
+ private boolean myFirstLineProcessed;
+ private boolean myStartedSuccessfully;
+ private boolean myIsEcho;
+
+ public OutputParser(
+ Project project,
+ ProcessHandler processHandler,
+ OldAntBuildMessageView errorsView,
+ ProgressIndicator progress,
+ String buildName
+ ) {
+ myProject = project;
+ myProcessHandler = processHandler;
+ myMessageView = errorsView;
+ myProgress = new WeakReference<>(progress);
+ myBuildName = buildName;
+ myMessageView.setParsingThread(this);
}
- }
- private void setProgressText(String s) {
- final ProgressIndicator progress = myProgress.get();
- if (progress != null) {
- progress.setText(s);
+ @Override
+ public final void stopProcess() {
+ myProcessHandler.destroyProcess();
}
- }
-
- private void printRawError(String text) {
- myMessageView.outputError(text, 0);
- }
- public final void readErrorOutput(String text) {
- if (!myFirstLineProcessed) {
- myFirstLineProcessed = true;
- myStartedSuccessfully = false;
- myMessageView.buildFailed(myBuildName);
- }
- if (!myStartedSuccessfully) {
- printRawError(text);
+ @Override
+ public boolean isTerminateInvoked() {
+ return myProcessHandler.isProcessTerminating();
}
- }
-
- protected final void processTag(char tagName, final String tagValue, final int priority) {
- if (LOG.isDebugEnabled()) {
- LOG.debug(String.valueOf(tagName) + priority + "=" + tagValue);
+ protected Project getProject() {
+ return myProject;
}
- if (AntLoggerConstants.TARGET == tagName) {
- setProgressStatistics(AntBundle.message("target.tag.name.status.text", tagValue));
- }
- else if (AntLoggerConstants.TASK == tagName) {
- setProgressText(AntBundle.message("executing.task.tag.value.status.text", tagValue));
- if (JAVAC.equals(tagValue)) {
- myJavacMessages = new ArrayList();
- }
- else if (ECHO.equals(tagValue)) {
- myIsEcho = true;
- }
+ protected ProcessHandler getProcessHandler() {
+ return myProcessHandler;
}
- if (myJavacMessages != null && (AntLoggerConstants.MESSAGE == tagName || AntLoggerConstants.ERROR == tagName)) {
- myJavacMessages.add(tagValue);
- return;
+ @Override
+ public final boolean isStopped() {
+ return isStopped;
}
- if (AntLoggerConstants.MESSAGE == tagName) {
- if (myIsEcho) {
- myMessageView.outputMessage(tagValue, OldAntBuildMessageView.PRIORITY_VERBOSE);
- }
- else {
- myMessageView.outputMessage(tagValue, priority);
- }
- }
- else if (AntLoggerConstants.TARGET == tagName) {
- myMessageView.startTarget(tagValue);
+ @Override
+ public final void setStopped(boolean stopped) {
+ isStopped = stopped;
}
- else if (AntLoggerConstants.TASK == tagName) {
- myMessageView.startTask(tagValue);
+
+ @Override
+ public int getErrorsCount() {
+ return 0;
}
- else if (AntLoggerConstants.ERROR == tagName) {
- myMessageView.outputError(tagValue, priority);
+
+ private void setProgressStatistics(LocalizeValue s) {
+ ProgressIndicator progress = myProgress.get();
+ if (progress != null) {
+ progress.setText2(s);
+ }
}
- else if (AntLoggerConstants.EXCEPTION == tagName) {
- String exceptionText = tagValue.replace(AntLoggerConstants.EXCEPTION_LINE_SEPARATOR, '\n');
- myMessageView.outputException(exceptionText);
+
+ private void setProgressText(LocalizeValue s) {
+ ProgressIndicator progress = myProgress.get();
+ if (progress != null) {
+ progress.setText(s);
+ }
}
- else if (AntLoggerConstants.BUILD == tagName) {
- myMessageView.startBuild(myBuildName);
+
+ private void printRawError(String text) {
+ myMessageView.outputError(text, 0);
}
- else if (AntLoggerConstants.TARGET_END == tagName || AntLoggerConstants.TASK_END == tagName) {
- final List javacMessages = myJavacMessages;
- myJavacMessages = null;
- processJavacMessages(javacMessages, myMessageView, myProject);
- myIsEcho = false;
- if (AntLoggerConstants.TARGET_END == tagName) {
- myMessageView.finishTarget();
- }
- else {
- myMessageView.finishTask();
- }
+
+ public final void readErrorOutput(String text) {
+ if (!myFirstLineProcessed) {
+ myFirstLineProcessed = true;
+ myStartedSuccessfully = false;
+ myMessageView.buildFailed(myBuildName);
+ }
+ if (!myStartedSuccessfully) {
+ printRawError(text);
+ }
}
- }
-
- private static boolean isJikesMessage(String errorMessage) {
- for (int j = 0; j < errorMessage.length(); j++) {
- if (errorMessage.charAt(j) == ':') {
- int offset = getNextTwoPoints(j, errorMessage);
- if (offset < 0) {
- continue;
+
+ protected final void processTag(char tagName, String tagValue, int priority) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(String.valueOf(tagName) + priority + "=" + tagValue);
+ }
+
+ if (AntLoggerConstants.TARGET == tagName) {
+ setProgressStatistics(ApacheAntImplLocalize.targetTagNameStatusText(tagValue));
}
- offset = getNextTwoPoints(offset, errorMessage);
- if (offset < 0) {
- continue;
+ else if (AntLoggerConstants.TASK == tagName) {
+ setProgressText(ApacheAntImplLocalize.executingTaskTagValueStatusText(tagValue));
+ if (JAVAC.equals(tagValue)) {
+ myJavacMessages = new ArrayList<>();
+ }
+ else if (ECHO.equals(tagValue)) {
+ myIsEcho = true;
+ }
}
- offset = getNextTwoPoints(offset, errorMessage);
- if (offset < 0) {
- continue;
+
+ if (myJavacMessages != null && (AntLoggerConstants.MESSAGE == tagName || AntLoggerConstants.ERROR == tagName)) {
+ myJavacMessages.add(tagValue);
+ return;
}
- offset = getNextTwoPoints(offset, errorMessage);
- if (offset >= 0) {
- return true;
+
+ if (AntLoggerConstants.MESSAGE == tagName) {
+ if (myIsEcho) {
+ myMessageView.outputMessage(tagValue, OldAntBuildMessageView.PRIORITY_VERBOSE);
+ }
+ else {
+ myMessageView.outputMessage(tagValue, priority);
+ }
+ }
+ else if (AntLoggerConstants.TARGET == tagName) {
+ myMessageView.startTarget(tagValue);
+ }
+ else if (AntLoggerConstants.TASK == tagName) {
+ myMessageView.startTask(tagValue);
+ }
+ else if (AntLoggerConstants.ERROR == tagName) {
+ myMessageView.outputError(tagValue, priority);
+ }
+ else if (AntLoggerConstants.EXCEPTION == tagName) {
+ String exceptionText = tagValue.replace(AntLoggerConstants.EXCEPTION_LINE_SEPARATOR, '\n');
+ myMessageView.outputException(exceptionText);
+ }
+ else if (AntLoggerConstants.BUILD == tagName) {
+ myMessageView.startBuild(myBuildName);
+ }
+ else if (AntLoggerConstants.TARGET_END == tagName || AntLoggerConstants.TASK_END == tagName) {
+ List javacMessages = myJavacMessages;
+ myJavacMessages = null;
+ processJavacMessages(javacMessages, myMessageView, myProject);
+ myIsEcho = false;
+ if (AntLoggerConstants.TARGET_END == tagName) {
+ myMessageView.finishTarget();
+ }
+ else {
+ myMessageView.finishTask();
+ }
}
- }
- }
- return false;
- }
-
- private static int getNextTwoPoints(int offset, String message) {
- for (int i = offset + 1; i < message.length(); i++) {
- char c = message.charAt(i);
- if (c == ':') {
- return i;
- }
- if (Character.isDigit(c)) {
- continue;
- }
- return -1;
- }
- return -1;
- }
-
- private static void processJavacMessages(final List javacMessages, final OldAntBuildMessageView messageView, Project project) {
- if (javacMessages == null) return;
-
- boolean isJikes = false;
- for (String errorMessage : javacMessages) {
- if (isJikesMessage(errorMessage)) {
- isJikes = true;
- break;
- }
}
- com.intellij.java.compiler.impl.OutputParser outputParser;
- if (isJikes) {
- outputParser = null;
- // outputParser = new JikesOutputParser(project);
- }
- else {
- outputParser = new JavacOutputParser(project);
+ private static boolean isJikesMessage(String errorMessage) {
+ for (int j = 0; j < errorMessage.length(); j++) {
+ if (errorMessage.charAt(j) == ':') {
+ int offset = getNextTwoPoints(j, errorMessage);
+ if (offset < 0) {
+ continue;
+ }
+ offset = getNextTwoPoints(offset, errorMessage);
+ if (offset < 0) {
+ continue;
+ }
+ offset = getNextTwoPoints(offset, errorMessage);
+ if (offset < 0) {
+ continue;
+ }
+ offset = getNextTwoPoints(offset, errorMessage);
+ if (offset >= 0) {
+ return true;
+ }
+ }
+ }
+ return false;
}
- com.intellij.java.compiler.impl.OutputParser.Callback callback = new com.intellij.java.compiler.impl.OutputParser.Callback() {
- private int myIndex = -1;
+ private static int getNextTwoPoints(int offset, String message) {
+ for (int i = offset + 1; i < message.length(); i++) {
+ char c = message.charAt(i);
+ if (c == ':') {
+ return i;
+ }
+ if (Character.isDigit(c)) {
+ continue;
+ }
+ return -1;
+ }
+ return -1;
+ }
- @Override
- @Nullable
- public String getCurrentLine() {
- if (javacMessages == null || myIndex >= javacMessages.size()) {
- return null;
+ private static void processJavacMessages(final List javacMessages, final OldAntBuildMessageView messageView, Project project) {
+ if (javacMessages == null) {
+ return;
}
- return javacMessages.get(myIndex);
- }
-
- @Override
- public String getNextLine() {
- final int size = javacMessages.size();
- final int next = Math.min(myIndex + 1, javacMessages.size());
- myIndex = next;
- if (next >= size) {
- return null;
+
+ boolean isJikes = false;
+ for (String errorMessage : javacMessages) {
+ if (isJikesMessage(errorMessage)) {
+ isJikes = true;
+ break;
+ }
}
- return javacMessages.get(next);
- }
-
- @Override
- public void pushBack(String line) {
- myIndex--;
- }
-
- @Override
- public void message(final CompilerMessageCategory category,
- final String message,
- final String url,
- final int lineNum,
- final int columnNum) {
- consulo.util.lang.text.StringTokenizer tokenizer = new consulo.util.lang.text.StringTokenizer(message, "\n", false);
- final String[] strings = new String[tokenizer.countTokens()];
- //noinspection ForLoopThatDoesntUseLoopVariable
- for (int idx = 0; tokenizer.hasMoreTokens(); idx++) {
- strings[idx] = tokenizer.nextToken();
+
+ com.intellij.java.compiler.impl.OutputParser outputParser;
+ if (isJikes) {
+ outputParser = null;
+ // outputParser = new JikesOutputParser(project);
}
- ApplicationManager.getApplication().runReadAction(new Runnable() {
- @Override
- public void run() {
- VirtualFile file = url == null ? null : VirtualFileManager.getInstance().findFileByUrl(url);
- messageView.outputJavacMessage(convertCategory(category), strings, file, url, lineNum, columnNum);
- }
- });
- }
-
- @Override
- public void setProgressText(String text) {
- }
-
- @Override
- public void fileProcessed(String path) {
- }
-
- @Override
- public void fileGenerated(FileObject path) {
- }
- };
- try {
- while (true) {
- if (!outputParser.processMessageLine(callback)) {
- break;
+ else {
+ outputParser = new JavacOutputParser(project);
}
- }
- }
- catch (Exception e) {
- //ignore
- }
- }
- private static OldAntBuildMessageView.MessageType convertCategory(consulo.compiler.CompilerMessageCategory category) {
- if (consulo.compiler.CompilerMessageCategory.ERROR.equals(category)) {
- return OldAntBuildMessageView.MessageType.ERROR;
+ com.intellij.java.compiler.impl.OutputParser.Callback callback = new com.intellij.java.compiler.impl.OutputParser.Callback() {
+ private int myIndex = -1;
+
+ @Override
+ @Nullable
+ public String getCurrentLine() {
+ if (javacMessages == null || myIndex >= javacMessages.size()) {
+ return null;
+ }
+ return javacMessages.get(myIndex);
+ }
+
+ @Override
+ public String getNextLine() {
+ int size = javacMessages.size();
+ int next = Math.min(myIndex + 1, javacMessages.size());
+ myIndex = next;
+ if (next >= size) {
+ return null;
+ }
+ return javacMessages.get(next);
+ }
+
+ @Override
+ public void pushBack(String line) {
+ myIndex--;
+ }
+
+ @Override
+ public CompileContext.MessageBuilder newMessage(CompilerMessageCategory category, LocalizeValue message) {
+ OldAntBuildMessageView.MessageType messageType = switch (category) {
+ case CompilerMessageCategory.ERROR -> OldAntBuildMessageView.MessageType.ERROR;
+ default -> OldAntBuildMessageView.MessageType.MESSAGE;
+ };
+
+ return new CompileContext.MessageBuilder() {
+ private String myUrl = null;
+ private VirtualFile myFile = null;
+ private int myRow = -1, myColumn = -1;
+
+ @Override
+ public CompileContext.MessageBuilder url(String url) {
+ myUrl = url;
+ myFile = VirtualFileManager.getInstance().findFileByUrl(url);
+ return this;
+ }
+
+ @Override
+ public CompileContext.MessageBuilder position(int row, int column) {
+ myRow = row;
+ myColumn = column;
+ return this;
+ }
+
+ @Override
+ public CompileContext.MessageBuilder navigatable(Navigatable navigatable) {
+ return this;
+ }
+
+ @Override
+ public void add() {
+ Application.get().runReadAction(
+ () -> messageView.outputJavacMessage(messageType, message.get().split("\n"), myFile, myUrl, myRow, myColumn)
+ );
+ }
+ };
+ }
+
+ @Override
+ public void setProgressText(LocalizeValue text) {
+ }
+
+ @Override
+ public void fileProcessed(String path) {
+ }
+
+ @Override
+ public void fileGenerated(FileObject path) {
+ }
+ };
+ try {
+ while (true) {
+ if (!outputParser.processMessageLine(callback)) {
+ break;
+ }
+ }
+ }
+ catch (Exception e) {
+ //ignore
+ }
}
- return OldAntBuildMessageView.MessageType.MESSAGE;
- }
-
}
diff --git a/ant-impl/src/main/java/com/intellij/lang/ant/config/execution/RunCanceledException.java b/ant-impl/src/main/java/com/intellij/lang/ant/config/execution/RunCanceledException.java
index 580ce3f..9cc252c 100644
--- a/ant-impl/src/main/java/com/intellij/lang/ant/config/execution/RunCanceledException.java
+++ b/ant-impl/src/main/java/com/intellij/lang/ant/config/execution/RunCanceledException.java
@@ -15,18 +15,20 @@
*/
package com.intellij.lang.ant.config.execution;
+import consulo.localize.LocalizeValue;
+import consulo.ui.annotation.RequiredUIAccess;
import consulo.ui.ex.awt.Messages;
import consulo.execution.CantRunException;
import consulo.project.Project;
-public class RunCanceledException extends CantRunException
-{
- public RunCanceledException(String message) {
- super(message);
- }
+public class RunCanceledException extends CantRunException {
+ public RunCanceledException(String message) {
+ super(message);
+ }
- public void showMessage(Project project, String title) {
- Messages.showInfoMessage(project, getMessage(), title);
- }
+ @RequiredUIAccess
+ public void showMessage(Project project, LocalizeValue title) {
+ Messages.showInfoMessage(project, getMessage(), title.get());
+ }
}
diff --git a/ant-impl/src/main/java/consulo/apache/ant/execution/OutputBuilder.java b/ant-impl/src/main/java/consulo/apache/ant/execution/OutputBuilder.java
index 8227fc6..1d950b6 100644
--- a/ant-impl/src/main/java/consulo/apache/ant/execution/OutputBuilder.java
+++ b/ant-impl/src/main/java/consulo/apache/ant/execution/OutputBuilder.java
@@ -1,190 +1,189 @@
package consulo.apache.ant.execution;
+import com.intellij.java.compiler.impl.OutputParser;
import com.intellij.java.compiler.impl.javaCompiler.FileObject;
import com.intellij.java.compiler.impl.javaCompiler.javac.JavacOutputParser;
-import consulo.application.ApplicationManager;
+import consulo.application.Application;
import consulo.build.ui.FilePosition;
import consulo.build.ui.event.MessageEvent;
import consulo.build.ui.progress.BuildProgress;
import consulo.build.ui.progress.BuildProgressDescriptor;
+import consulo.compiler.CompileContext;
import consulo.compiler.CompilerMessageCategory;
+import consulo.localize.LocalizeValue;
import consulo.logging.Logger;
+import consulo.navigation.Navigatable;
import consulo.process.ProcessHandler;
import consulo.project.Project;
import consulo.virtualFileSystem.VirtualFile;
import consulo.virtualFileSystem.VirtualFileManager;
-import jetbrains.buildServer.messages.serviceMessages.*;
-
import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
+import jetbrains.buildServer.messages.serviceMessages.*;
+
import java.io.File;
-import java.util.ArrayList;
-import java.util.Deque;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.atomic.AtomicInteger;
/**
* @author VISTALL
- * @since 08/05/2023
+ * @since 2023-05-08
*/
public class OutputBuilder implements OutputWatcher, MessageProcessor {
- private static final String JAVAC = "javac";
- private static final String ECHO = "echo";
-
- private static final Logger LOG = Logger.getInstance(OutputBuilder.class);
- private final Project myProject;
- private final BuildProgress myBuildProgress;
- private final ProcessHandler myProcessHandler;
- private boolean isStopped;
- private List myJavacMessages;
- private boolean myIsEcho;
- private int myErrorsCount;
-
- private Map> myTargets = new ConcurrentHashMap<>();
- private Map> myTasks = new ConcurrentHashMap<>();
-
- private Deque> myQueue = new ConcurrentLinkedDeque<>();
-
- public OutputBuilder(Project project,
- ProcessHandler processHandler,
- BuildProgress buildProgress) {
- myProject = project;
- myProcessHandler = processHandler;
- myBuildProgress = buildProgress;
-
- myQueue.add(myBuildProgress);
- }
-
- @Override
- public int getErrorsCount() {
- return myErrorsCount;
- }
-
- @Override
- public final void stopProcess() {
- myProcessHandler.destroyProcess();
- }
-
- @Override
- public boolean isTerminateInvoked() {
- return myProcessHandler.isProcessTerminating();
- }
-
- @Override
- public final boolean isStopped() {
- return isStopped;
- }
-
- @Override
- public final void setStopped(boolean stopped) {
- isStopped = stopped;
- }
-
- @Override
- public void onMessage(@Nullable ServiceMessage serviceMessage, @Nonnull String text) {
- if (LOG.isDebugEnabled()) {
- LOG.debug(text);
- }
+ private static final String JAVAC = "javac";
+ private static final String ECHO = "echo";
+
+ private static final Logger LOG = Logger.getInstance(OutputBuilder.class);
+ private final Project myProject;
+ private final BuildProgress myBuildProgress;
+ private final ProcessHandler myProcessHandler;
+ private boolean isStopped;
+ private List myJavacMessages;
+ private boolean myIsEcho;
+ private int myErrorsCount;
+
+ private Map> myTargets = new ConcurrentHashMap<>();
+ private Map> myTasks = new ConcurrentHashMap<>();
- BuildProgress current = myQueue.getLast();
+ private Deque> myQueue = new ConcurrentLinkedDeque<>();
- if (serviceMessage == null) {
- current.output(text + "\n", true);
- return;
+ public OutputBuilder(Project project, ProcessHandler processHandler, BuildProgress buildProgress) {
+ myProject = project;
+ myProcessHandler = processHandler;
+ myBuildProgress = buildProgress;
+
+ myQueue.add(myBuildProgress);
}
- if (serviceMessage instanceof BuildStatus buildStatus) {
- boolean started = "buildStarted".equals(buildStatus.getStatus());
+ @Override
+ public int getErrorsCount() {
+ return myErrorsCount;
+ }
- if (started) {
- // we already started it
- }
- else {
- if (myErrorsCount > 0) {
- myBuildProgress.fail();
- }
- else {
- myBuildProgress.finish();
- }
- }
+ @Override
+ public final void stopProcess() {
+ myProcessHandler.destroyProcess();
}
- else if (serviceMessage instanceof ProgressStart progressStart) {
- BuildProgress childProgress = current.startChildProgress("target: " + progressStart.getArgument());
- myTargets.put(progressStart.getArgument(), childProgress);
- myQueue.addLast(childProgress);
+
+ @Override
+ public boolean isTerminateInvoked() {
+ return myProcessHandler.isProcessTerminating();
}
- else if (serviceMessage instanceof TestStarted started) {
- String taskName = started.getTestName();
- BuildProgress childProgress = current.startChildProgress("task: " + taskName);
- myTasks.put(taskName, childProgress);
- myQueue.addLast(childProgress);
-
- if (JAVAC.equals(taskName)) {
- myJavacMessages = new ArrayList<>();
- }
+
+ @Override
+ public final boolean isStopped() {
+ return isStopped;
}
- else if (serviceMessage instanceof TestFinished testFinished) {
- String taskName = testFinished.getTestName();
- BuildProgress childProgress = myTasks.remove(taskName);
- final List javacMessages = myJavacMessages;
- myJavacMessages = null;
- int currentErrors = processJavacMessages(javacMessages, myQueue.getLast(), myProject);
- myErrorsCount += currentErrors;
- myIsEcho = false;
-
- if (childProgress != null) {
- if (currentErrors > 0) {
- childProgress.fail();
- }
- else {
- childProgress.finish();
- }
- myQueue.remove(childProgress);
- }
+ @Override
+ public final void setStopped(boolean stopped) {
+ isStopped = stopped;
}
- else if (serviceMessage instanceof ProgressFinish progressFinish) {
- BuildProgress childProgress = myTargets.remove(progressFinish.getArgument());
- final List javacMessages = myJavacMessages;
- myJavacMessages = null;
- int currentErrors = processJavacMessages(javacMessages, myQueue.getLast(), myProject);
- myErrorsCount += currentErrors;
- myIsEcho = false;
-
- if (childProgress != null) {
- if (currentErrors > 0) {
- childProgress.fail();
- }
- else {
- childProgress.finish();
+
+ @Override
+ public void onMessage(@Nullable ServiceMessage serviceMessage, @Nonnull String text) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(text);
}
- myQueue.remove(childProgress);
- }
- }
- else if (serviceMessage instanceof Message messageObj) {
- String messageText = messageObj.getText();
- // org.apache.tools.ant.Project.MSG_ERR = 0
- boolean isError = "0".equals(messageObj.getStatus());
- boolean isWarn = "1".equals(messageObj.getStatus());
- boolean isInfo = "2".equals(messageObj.getStatus());
-
- if (isError || isWarn || isInfo) {
- if (myJavacMessages != null) {
- myJavacMessages.add(messageText);
+ BuildProgress current = myQueue.getLast();
+
+ if (serviceMessage == null) {
+ current.output(text + "\n", true);
+ return;
}
- else {
- myQueue.getLast().output(messageText + "\n", !isError);
- if (isError) {
- myErrorsCount++;
- }
+ if (serviceMessage instanceof BuildStatus buildStatus) {
+ boolean started = "buildStarted".equals(buildStatus.getStatus());
+
+ if (started) {
+ // we already started it
+ }
+ else if (myErrorsCount > 0) {
+ myBuildProgress.fail();
+ }
+ else {
+ myBuildProgress.finish();
+ }
+ }
+ else if (serviceMessage instanceof ProgressStart progressStart) {
+ BuildProgress childProgress =
+ current.startChildProgress(LocalizeValue.localizeTODO("target: " + progressStart.getArgument()));
+ myTargets.put(progressStart.getArgument(), childProgress);
+ myQueue.addLast(childProgress);
+ }
+ else if (serviceMessage instanceof TestStarted started) {
+ String taskName = started.getTestName();
+ BuildProgress childProgress =
+ current.startChildProgress(LocalizeValue.localizeTODO("task: " + taskName));
+ myTasks.put(taskName, childProgress);
+ myQueue.addLast(childProgress);
+
+ if (JAVAC.equals(taskName)) {
+ myJavacMessages = new ArrayList<>();
+ }
+ }
+ else if (serviceMessage instanceof TestFinished testFinished) {
+ String taskName = testFinished.getTestName();
+ BuildProgress childProgress = myTasks.remove(taskName);
+ List javacMessages = myJavacMessages;
+ myJavacMessages = null;
+ int currentErrors = processJavacMessages(javacMessages, myQueue.getLast(), myProject);
+ myErrorsCount += currentErrors;
+ myIsEcho = false;
+
+ if (childProgress != null) {
+ if (currentErrors > 0) {
+ childProgress.fail();
+ }
+ else {
+ childProgress.finish();
+ }
+
+ myQueue.remove(childProgress);
+ }
+ }
+ else if (serviceMessage instanceof ProgressFinish progressFinish) {
+ BuildProgress childProgress = myTargets.remove(progressFinish.getArgument());
+ List javacMessages = myJavacMessages;
+ myJavacMessages = null;
+ int currentErrors = processJavacMessages(javacMessages, myQueue.getLast(), myProject);
+ myErrorsCount += currentErrors;
+ myIsEcho = false;
+
+ if (childProgress != null) {
+ if (currentErrors > 0) {
+ childProgress.fail();
+ }
+ else {
+ childProgress.finish();
+ }
+
+ myQueue.remove(childProgress);
+ }
+ }
+ else if (serviceMessage instanceof Message messageObj) {
+ String messageText = messageObj.getText();
+ // org.apache.tools.ant.Project.MSG_ERR = 0
+ boolean isError = "0".equals(messageObj.getStatus());
+ boolean isWarn = "1".equals(messageObj.getStatus());
+ boolean isInfo = "2".equals(messageObj.getStatus());
+
+ if (isError || isWarn || isInfo) {
+ if (myJavacMessages != null) {
+ myJavacMessages.add(messageText);
+ }
+ else {
+ myQueue.getLast().output(messageText + "\n", !isError);
+
+ if (isError) {
+ myErrorsCount++;
+ }
+ }
+ }
}
- }
- }
// if (AntLoggerConstants.TARGET == tagName) {
// setProgressStatistics(AntBundle.message("target.tag.name.status.text", tagValue));
@@ -240,112 +239,122 @@ else if (serviceMessage instanceof Message messageObj) {
// myMessageView.finishTask();
// }
// }
- }
+ }
- private static int processJavacMessages(List javacMessages,
- BuildProgress buildProgress,
- Project project) {
- if (javacMessages == null) return 0;
+ private static int processJavacMessages(
+ List javacMessages,
+ BuildProgress buildProgress,
+ Project project
+ ) {
+ if (javacMessages == null) {
+ return 0;
+ }
- com.intellij.java.compiler.impl.OutputParser outputParser = new JavacOutputParser(project);
+ OutputParser outputParser = new JavacOutputParser(project);
+ AtomicInteger errorCount = new AtomicInteger();
+ OutputParser.Callback callback = new OutputParser.Callback() {
+ private int myIndex = -1;
- AtomicInteger errorCount = new AtomicInteger();
- com.intellij.java.compiler.impl.OutputParser.Callback callback = new com.intellij.java.compiler.impl.OutputParser.Callback() {
- private int myIndex = -1;
+ @Override
+ @Nullable
+ public String getCurrentLine() {
+ if (javacMessages == null || myIndex >= javacMessages.size()) {
+ return null;
+ }
+ return javacMessages.get(myIndex);
+ }
- @Override
- @Nullable
- public String getCurrentLine() {
- if (javacMessages == null || myIndex >= javacMessages.size()) {
- return null;
- }
- return javacMessages.get(myIndex);
- }
-
- @Override
- public String getNextLine() {
- final int size = javacMessages.size();
- final int next = Math.min(myIndex + 1, javacMessages.size());
- myIndex = next;
- if (next >= size) {
- return null;
- }
- return javacMessages.get(next);
- }
-
- @Override
- public void pushBack(String line) {
- myIndex--;
- }
-
- @Override
- public void message(final CompilerMessageCategory category,
- final String message,
- final String url,
- final int lineNum,
- final int columnNum) {
- if (category == CompilerMessageCategory.ERROR) {
- errorCount.incrementAndGet();
- }
- ApplicationManager.getApplication().runReadAction(new Runnable() {
- @Override
- public void run() {
- VirtualFile file = url == null ? null : VirtualFileManager.getInstance().findFileByUrl(url);
- if (file != null) {
- buildProgress.fileMessage(message,
- message,
- convertCategory(category),
- new FilePosition(new File(file.getCanonicalPath()),
- lineNum - 1,
- columnNum,
- lineNum - 1,
- columnNum));
+ @Override
+ public String getNextLine() {
+ int size = javacMessages.size();
+ int next = Math.min(myIndex + 1, javacMessages.size());
+ myIndex = next;
+ if (next >= size) {
+ return null;
+ }
+ return javacMessages.get(next);
}
- else {
- buildProgress.message(message,
- message,
- convertCategory(category),
- null);
+
+ @Override
+ public void pushBack(String line) {
+ myIndex--;
}
- }
- });
- }
-
- @Override
- public void setProgressText(String text) {
- }
-
- @Override
- public void fileProcessed(String path) {
- }
-
- @Override
- public void fileGenerated(FileObject path) {
- }
- };
- try {
- while (true) {
- if (!outputParser.processMessageLine(callback)) {
- break;
- }
- }
- }
- catch (Exception e) {
- //ignore
- }
+ @Override
+ public CompileContext.MessageBuilder newMessage(CompilerMessageCategory category, LocalizeValue message) {
+ MessageEvent.Kind kind = switch (category) {
+ case CompilerMessageCategory.ERROR -> MessageEvent.Kind.ERROR;
+ case CompilerMessageCategory.WARNING -> MessageEvent.Kind.WARNING;
+ case CompilerMessageCategory.INFORMATION -> MessageEvent.Kind.INFO;
+ case CompilerMessageCategory.STATISTICS -> MessageEvent.Kind.STATISTICS;
+ };
+
+ return new CompileContext.MessageBuilder() {
+ private VirtualFile myFile = null;
+ private int myRow = -1, myColumn = -1;
+
+ @Override
+ public CompileContext.MessageBuilder url(String url) {
+ myFile = VirtualFileManager.getInstance().findFileByUrl(url);
+ return this;
+ }
+
+ @Override
+ public CompileContext.MessageBuilder position(int row, int column) {
+ myRow = row;
+ myColumn = column;
+ return this;
+ }
+
+ @Override
+ public CompileContext.MessageBuilder navigatable(Navigatable navigatable) {
+ return this;
+ }
+
+ @Override
+ public void add() {
+ if (category == CompilerMessageCategory.ERROR) {
+ errorCount.incrementAndGet();
+ }
+
+ Application.get().runReadAction(() -> {
+ if (myFile != null) {
+ FilePosition position =
+ new FilePosition(new File(Objects.requireNonNull(myFile.getCanonicalPath())), myRow - 1, myColumn);
+ buildProgress.fileMessage(message, message, kind, position);
+ }
+ else {
+ buildProgress.message(message, message, kind, null);
+ }
+ });
+ }
+ };
+ }
- return errorCount.get();
- }
+ @Override
+ public void setProgressText(LocalizeValue text) {
+ }
- private static MessageEvent.Kind convertCategory(CompilerMessageCategory category) {
- if (CompilerMessageCategory.ERROR.equals(category)) {
- return MessageEvent.Kind.ERROR;
- }
- if (CompilerMessageCategory.WARNING.equals(category)) {
- return MessageEvent.Kind.WARNING;
+ @Override
+ public void fileProcessed(String path) {
+ }
+
+ @Override
+ public void fileGenerated(FileObject path) {
+ }
+ };
+ try {
+ while (true) {
+ if (!outputParser.processMessageLine(callback)) {
+ break;
+ }
+ }
+ }
+ catch (Exception e) {
+ //ignore
+ }
+
+ return errorCount.get();
}
- return MessageEvent.Kind.INFO;
- }
}