ExceptionUtils rewritten in Kotlin
This commit is contained in:
@@ -42,7 +42,7 @@ import org.jetbrains.jet.config.CommonConfigurationKeys;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
import org.jetbrains.jet.utils.KotlinPaths;
|
||||
import org.jetbrains.jet.utils.PathUtil;
|
||||
|
||||
@@ -206,10 +206,10 @@ public class CompileEnvironmentUtil {
|
||||
throw new CompileEnvironmentException("Invalid jar path " + jarPath, e);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
finally {
|
||||
ExceptionUtils.closeQuietly(outputStream);
|
||||
UtilsPackage.closeQuietly(outputStream);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import jline.console.ConsoleReader;
|
||||
import jline.console.history.FileHistory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
@@ -59,7 +59,7 @@ public class ReplFromTerminal {
|
||||
consoleReader.setHistoryEnabled(true);
|
||||
consoleReader.setHistory(new FileHistory(new File(new File(System.getProperty("user.home")), ".kotlin_history")));
|
||||
} catch (Exception e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,13 +72,13 @@ public class ReplFromTerminal {
|
||||
try {
|
||||
waitRepl.wait();
|
||||
} catch (Throwable e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
if (replInterpreter != null) {
|
||||
return replInterpreter;
|
||||
}
|
||||
throw ExceptionUtils.rethrow(replInitializationFailed);
|
||||
throw UtilsPackage.rethrow(replInitializationFailed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public class ReplFromTerminal {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
} finally {
|
||||
try {
|
||||
((FileHistory) consoleReader.getHistory()).flush();
|
||||
@@ -132,7 +132,7 @@ public class ReplFromTerminal {
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ import org.jetbrains.jet.lang.types.lang.InlineUtil;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.plugin.JetLanguage;
|
||||
import org.jetbrains.jet.storage.LockBasedStorageManager;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
@@ -119,7 +119,7 @@ public class ReplInterpreter {
|
||||
classpath.add(file.toURI().toURL());
|
||||
}
|
||||
catch (MalformedURLException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ public class ReplInterpreter {
|
||||
PrintWriter writer = new PrintWriter(System.err);
|
||||
classLoader.dumpClasses(writer);
|
||||
writer.flush();
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -32,7 +32,7 @@ import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.storage.NotNullLazyValue;
|
||||
import org.jetbrains.jet.storage.NullableLazyValue;
|
||||
import org.jetbrains.jet.storage.StorageManager;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -81,7 +81,7 @@ public class VirtualFileKotlinClass implements KotlinJvmBinaryClass {
|
||||
}, SKIP_CODE | SKIP_DEBUG | SKIP_FRAMES);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
return classNameRef.get();
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class VirtualFileKotlinClass implements KotlinJvmBinaryClass {
|
||||
}, SKIP_CODE | SKIP_DEBUG | SKIP_FRAMES);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ public class VirtualFileKotlinClass implements KotlinJvmBinaryClass {
|
||||
}, SKIP_CODE | SKIP_DEBUG | SKIP_FRAMES);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -18,7 +18,7 @@ package org.jetbrains.jet.descriptors.serialization;
|
||||
|
||||
import com.google.protobuf.ExtensionRegistryLite;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -34,7 +34,7 @@ public final class ClassData {
|
||||
return new ClassData(nameResolver, classProto);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public final class ClassData {
|
||||
return result.toByteArray();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -17,7 +17,7 @@
|
||||
package org.jetbrains.jet.descriptors.serialization;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -35,7 +35,7 @@ public class NameSerializationUtil {
|
||||
return new NameResolver(simpleNames, qualifiedNames);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class NameSerializationUtil {
|
||||
qualifiedNameTable.writeDelimitedTo(out);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -18,7 +18,7 @@ package org.jetbrains.jet.descriptors.serialization;
|
||||
|
||||
import com.google.protobuf.ExtensionRegistryLite;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -34,7 +34,7 @@ public final class PackageData {
|
||||
return new PackageData(nameResolver, packageProto);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public final class PackageData {
|
||||
return result.toByteArray();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.jetAsJava.KotlinLightMethod;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
import org.jetbrains.jet.utils.KotlinVfsUtil;
|
||||
|
||||
import java.io.File;
|
||||
@@ -97,7 +97,7 @@ public class LightClassUtil {
|
||||
FileUtil.toSystemIndependentName(BUILT_INS_SRC_DIR.getAbsolutePath()));
|
||||
}
|
||||
catch (MalformedURLException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.intellij.util.io.ZipUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.cli.common.ExitCode;
|
||||
import org.jetbrains.jet.cli.jvm.K2JVMCompiler;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
import org.jetbrains.jet.utils.PathUtil;
|
||||
|
||||
import java.io.*;
|
||||
@@ -53,7 +53,7 @@ public class MockLibraryUtil {
|
||||
return jarFile;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class MockLibraryUtil {
|
||||
assertEquals(new String(outStream.toByteArray()), ExitCode.OK.name(), invocationResult.name());
|
||||
}
|
||||
catch (Throwable e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.lang.diagnostics.*;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.io.File;
|
||||
@@ -85,7 +85,7 @@ public abstract class BaseDiagnosticsTest extends JetLiteFixture {
|
||||
JetTestUtils.mkdirs(javaFilesDir);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
return javaFilesDir;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public abstract class BaseDiagnosticsTest extends JetLiteFixture {
|
||||
Files.write(content, javaFile, Charset.forName("utf-8"));
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.jetbrains.jet.cli.common.ExitCode;
|
||||
import org.jetbrains.jet.cli.js.K2JSCompiler;
|
||||
import org.jetbrains.jet.cli.jvm.K2JVMCompiler;
|
||||
import org.jetbrains.jet.test.Tmpdir;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.TestName;
|
||||
|
||||
@@ -54,7 +54,7 @@ public class CliBaseTest {
|
||||
return Pair.create(bytes.toString("utf-8"), exitCode);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
finally {
|
||||
System.setOut(origOut);
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.ConfigurationKind;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -54,7 +54,7 @@ public abstract class AbstractBytecodeTextTest extends CodegenTestCase {
|
||||
}
|
||||
catch (Throwable e) {
|
||||
System.out.println(text);
|
||||
ExceptionUtils.rethrow(e);
|
||||
UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||
import org.jetbrains.jet.lang.types.lang.InlineUtil;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -115,7 +115,7 @@ public class CodegenTestUtil {
|
||||
return javaClassesTempDirectory;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.test.TestCaseWithTmpdir;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -80,7 +80,7 @@ public class LineNumberTest extends TestCaseWithTmpdir {
|
||||
text = FileUtil.loadFile(file);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
|
||||
return JetTestUtils.createFile(file.getName(), text, environment.getProject());
|
||||
@@ -121,7 +121,7 @@ public class LineNumberTest extends TestCaseWithTmpdir {
|
||||
}
|
||||
catch (Throwable e) {
|
||||
System.out.println(factory.createText());
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.jet.lang.parsing.JetScriptDefinition;
|
||||
import org.jetbrains.jet.lang.parsing.JetScriptDefinitionProvider;
|
||||
import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter;
|
||||
import org.jetbrains.jet.lang.resolve.ScriptNameUtil;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
@@ -81,7 +81,7 @@ public class ScriptGenTest extends CodegenTestCase {
|
||||
}
|
||||
catch (Throwable e) {
|
||||
System.out.println(generateToText());
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.codegen.CodegenTestCase;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiUtil;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -102,7 +102,7 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase {
|
||||
}
|
||||
catch (Throwable e) {
|
||||
System.out.println(generateToText());
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||
import org.jetbrains.jet.test.TestCaseWithTmpdir;
|
||||
import org.jetbrains.jet.test.util.DescriptorValidator;
|
||||
import org.jetbrains.jet.test.util.RecursiveDescriptorComparator;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
@@ -129,7 +129,7 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
||||
return outputFile;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.google.common.io.Files;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
import org.junit.rules.TestWatcher;
|
||||
import org.junit.runner.Description;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Tmpdir extends TestWatcher {
|
||||
tmpDir = Files.createTempDir().getCanonicalFile();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import jet.Function1;
|
||||
import jet.Unit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
import org.jetbrains.jet.utils.WrappedValues;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -36,7 +36,7 @@ public class LockBasedStorageManager implements StorageManager {
|
||||
@NotNull
|
||||
@Override
|
||||
public RuntimeException handleException(@NotNull Throwable throwable) {
|
||||
throw ExceptionUtils.rethrow(throwable);
|
||||
throw UtilsPackage.rethrow(throwable);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* 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.utils;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
||||
public class ExceptionUtils {
|
||||
|
||||
private ExceptionUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate exception to unchecked exception.
|
||||
*
|
||||
* Return type is specified to make it possible to use it like this:
|
||||
* throw ExceptionUtils.rethrow(e);
|
||||
* In this case compiler knows that code after this rethrowing won't be executed.
|
||||
*/
|
||||
public static RuntimeException rethrow(Throwable e) {
|
||||
if (e instanceof RuntimeException) {
|
||||
throw (RuntimeException) e;
|
||||
}
|
||||
else if (e instanceof Error) {
|
||||
throw (Error) e;
|
||||
}
|
||||
else {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void closeQuietly(Closeable closeable) {
|
||||
if (closeable != null) {
|
||||
try {
|
||||
closeable.close();
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -69,7 +69,7 @@ public class WrappedValues {
|
||||
@Nullable
|
||||
public static <V> V unescapeThrowable(@Nullable Object value) {
|
||||
if (value instanceof ThrowableWrapper) {
|
||||
throw ExceptionUtils.rethrow(((ThrowableWrapper) value).getThrowable());
|
||||
throw UtilsPackage.rethrow(((ThrowableWrapper) value).getThrowable());
|
||||
}
|
||||
|
||||
//noinspection unchecked
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2010-2014 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.utils
|
||||
|
||||
import java.io.Closeable
|
||||
|
||||
/**
|
||||
* Translate exception to unchecked exception.
|
||||
*
|
||||
* Return type is specified to make it possible to use it like this:
|
||||
* throw ExceptionUtils.rethrow(e);
|
||||
* In this case compiler knows that code after this rethrowing won't be executed.
|
||||
*/
|
||||
public fun rethrow(e: Throwable): RuntimeException {
|
||||
throw e
|
||||
}
|
||||
|
||||
public fun closeQuietly(closeable: Closeable?) {
|
||||
if (closeable != null) {
|
||||
try {
|
||||
closeable.close()
|
||||
}
|
||||
catch (ignored: Throwable) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.jet.storage.LockBasedStorageManager;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
@@ -128,7 +128,7 @@ public class BuiltInsReferenceResolver extends AbstractProjectComponent {
|
||||
builtIns.addAll(getBuiltInSourceFiles(BUILT_INS_COMPILABLE_SRC_DIR.toURI().toURL()));
|
||||
}
|
||||
catch (MalformedURLException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.jet.editor;
|
||||
|
||||
import com.intellij.testFramework.EditorTestUtil;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -315,7 +315,7 @@ public class TypedHandlerTest extends LightCodeInsightTestCase {
|
||||
checkResultByText(afterText);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.InTextDirectivesUtils;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -59,7 +59,7 @@ public abstract class JetLightCodeInsightFixtureTestCase extends LightCodeInsigh
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ import org.jetbrains.jet.codegen.GenerationUtils;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.java.JetFilesProvider;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -64,7 +64,7 @@ public abstract class PositionManagerTestCase extends MultiFileTestCase {
|
||||
configureByFile(path);
|
||||
}
|
||||
catch (Exception e) {
|
||||
ExceptionUtils.rethrow(e);
|
||||
UtilsPackage.rethrow(e);
|
||||
}
|
||||
performTest();
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public abstract class PositionManagerTestCase extends MultiFileTestCase {
|
||||
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
|
||||
}
|
||||
catch (Exception e) {
|
||||
ExceptionUtils.rethrow(e);
|
||||
UtilsPackage.rethrow(e);
|
||||
}
|
||||
performTest();
|
||||
}
|
||||
@@ -107,7 +107,7 @@ public abstract class PositionManagerTestCase extends MultiFileTestCase {
|
||||
}
|
||||
}
|
||||
catch (NoDataException e) {
|
||||
ExceptionUtils.rethrow(e);
|
||||
UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -61,7 +61,7 @@ public class JetExceptionFilterTest extends MultiFileTestCase {
|
||||
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
|
||||
}
|
||||
catch (Exception e) {
|
||||
ExceptionUtils.rethrow(e);
|
||||
UtilsPackage.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.jet.utils.ExceptionUtils.rethrow;
|
||||
import static org.jetbrains.jet.utils.UtilsPackage.rethrow;
|
||||
import static org.jetbrains.k2js.test.BasicTest.pathToTestFilesRoot;
|
||||
|
||||
public final class RhinoUtils {
|
||||
|
||||
Reference in New Issue
Block a user