reportException() moved to a utility class and used where appropriate
This commit is contained in:
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.cli.common.messages;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MessageCollectorUtil {
|
||||
public static void reportException(@NotNull MessageCollector messageCollector, @NotNull Throwable exception) {
|
||||
messageCollector.report(CompilerMessageSeverity.EXCEPTION, MessageRenderer.PLAIN.renderException(exception),
|
||||
CompilerMessageLocation.NO_LOCATION);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -73,8 +73,7 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
|
||||
configuration.addAll(JVMConfigurationKeys.ANNOTATIONS_PATH_KEY, getAnnotationsPath(paths, arguments));
|
||||
}
|
||||
catch (Throwable t) {
|
||||
messageCollector.report(CompilerMessageSeverity.EXCEPTION, MessageRenderer.PLAIN.renderException(t),
|
||||
CompilerMessageLocation.NO_LOCATION);
|
||||
MessageCollectorUtil.reportException(messageCollector, t);
|
||||
return INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -400,8 +400,7 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
return null;
|
||||
}
|
||||
catch (Throwable t) {
|
||||
messageCollector.report(CompilerMessageSeverity.EXCEPTION, MessageRenderer.PLAIN.renderException(t),
|
||||
CompilerMessageLocation.NO_LOCATION);
|
||||
MessageCollectorUtil.reportException(messageCollector, t);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,11 @@ package org.jetbrains.jet.compiler.runner;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.Stack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.cli.common.messages.*;
|
||||
import org.jetbrains.jet.cli.common.messages.CompilerMessageLocation;
|
||||
import org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity;
|
||||
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
||||
import org.jetbrains.jet.cli.common.messages.OutputMessageUtil;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
@@ -35,6 +37,7 @@ import java.util.Map;
|
||||
|
||||
import static org.jetbrains.jet.cli.common.messages.CompilerMessageLocation.NO_LOCATION;
|
||||
import static org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity.*;
|
||||
import static org.jetbrains.jet.cli.common.messages.MessageCollectorUtil.reportException;
|
||||
|
||||
public class CompilerOutputParser {
|
||||
public static void parseCompilerMessagesFromReader(MessageCollector messageCollector, final Reader reader, OutputItemsCollector collector) {
|
||||
@@ -94,10 +97,6 @@ public class CompilerOutputParser {
|
||||
}
|
||||
}
|
||||
|
||||
public static void reportException(@NotNull MessageCollector messageCollector, @NotNull Throwable e) {
|
||||
messageCollector.report(EXCEPTION, MessageRenderer.PLAIN.renderException(e), NO_LOCATION);
|
||||
}
|
||||
|
||||
private static class CompilerOutputSAXHandler extends DefaultHandler {
|
||||
private static final Map<String, CompilerMessageSeverity> CATEGORIES = new ContainerUtil.ImmutableMapBuilder<String, CompilerMessageSeverity>()
|
||||
.put("error", ERROR)
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.intellij.util.SystemProperties;
|
||||
import org.jetbrains.jet.cli.common.messages.CompilerMessageLocation;
|
||||
import org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity;
|
||||
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
||||
import org.jetbrains.jet.cli.common.messages.MessageCollectorUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -81,7 +82,7 @@ public class KotlinCompilerRunner {
|
||||
return CompilerRunnerUtil.getReturnCodeFromObject(rc);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
CompilerOutputParser.reportException(messageCollector, e);
|
||||
MessageCollectorUtil.reportException(messageCollector, e);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user