Drop LockBasedStorageManager.defaultDebugName, use meaningful name everywhere
Also, drop `createDelegatingWithSameLock` as it was unused
This commit is contained in:
committed by
Dmitry Savvinov
parent
893479bd5e
commit
69fff12384
@@ -16,7 +16,7 @@ import java.util.*
|
||||
abstract class TargetPlatform(val platformName: String) {
|
||||
private data class DefaultImportsKey(val includeKotlinComparisons: Boolean, val includeLowPriorityImports: Boolean)
|
||||
|
||||
private val defaultImports = LockBasedStorageManager().let { storageManager ->
|
||||
private val defaultImports = LockBasedStorageManager("TargetPlatform").let { storageManager ->
|
||||
storageManager.createMemoizedFunction<DefaultImportsKey, List<ImportPath>> { (includeKotlinComparisons, includeLowPriorityImports) ->
|
||||
ArrayList<ImportPath>().apply {
|
||||
listOf(
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ internal fun String?.orAnonymous(kind: String = ""): String =
|
||||
this ?: "<anonymous" + (if (kind.isNotBlank()) " $kind" else "") + ">"
|
||||
|
||||
internal fun constructAnnotation(psi: KtAnnotationEntry, targetClass: KClass<out Annotation>, project: Project): Annotation {
|
||||
val module = ModuleDescriptorImpl(Name.special("<script-annotations-preprocessing>"), LockBasedStorageManager(), DefaultBuiltIns.Instance)
|
||||
val module = ModuleDescriptorImpl(Name.special("<script-annotations-preprocessing>"), LockBasedStorageManager("scriptAnnotationsPreprocessing"), DefaultBuiltIns.Instance)
|
||||
val evaluator = ConstantExpressionEvaluator(module, LanguageVersionSettingsImpl.DEFAULT, project)
|
||||
val trace = BindingTraceContext()
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ class MutableModuleContextImpl(
|
||||
|
||||
fun GlobalContext(): GlobalContextImpl {
|
||||
val tracker = ExceptionTracker()
|
||||
return GlobalContextImpl(LockBasedStorageManager.createWithExceptionHandling(tracker), tracker)
|
||||
return GlobalContextImpl(LockBasedStorageManager.createWithExceptionHandling("GlobalContext", tracker), tracker)
|
||||
}
|
||||
|
||||
fun ProjectContext(project: Project): ProjectContext = ProjectContextImpl(project, GlobalContext())
|
||||
|
||||
+1
-1
@@ -215,7 +215,7 @@ class ExperimentalUsageChecker(project: Project) : CallChecker {
|
||||
// "-Xuse-experimental" arguments. However, it's not easy to do this. This should be solved in the future with the support of
|
||||
// module annotations. For now, we only check deprecations because this is needed to correctly retire unneeded compiler arguments.
|
||||
val deprecationResolver =
|
||||
DeprecationResolver(LockBasedStorageManager(), languageVersionSettings, CoroutineCompatibilitySupport.ENABLED)
|
||||
DeprecationResolver(LockBasedStorageManager("ExperimentalUsageChecker"), languageVersionSettings, CoroutineCompatibilitySupport.ENABLED)
|
||||
|
||||
// Returns true if fqName refers to a valid experimental API marker.
|
||||
fun checkAnnotation(fqName: String): Boolean {
|
||||
|
||||
+2
-2
@@ -84,11 +84,11 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() {
|
||||
if (files.any(TestFile::checkLazyLog)) {
|
||||
lazyOperationsLog = LazyOperationsLog(HASH_SANITIZER)
|
||||
storageManager = LoggingStorageManager(
|
||||
LockBasedStorageManager.createWithExceptionHandling(tracker),
|
||||
LockBasedStorageManager.createWithExceptionHandling("AbstractDiagnosticTest", tracker),
|
||||
lazyOperationsLog.addRecordFunction
|
||||
)
|
||||
} else {
|
||||
storageManager = LockBasedStorageManager.createWithExceptionHandling(tracker)
|
||||
storageManager = LockBasedStorageManager.createWithExceptionHandling("AbstractDiagnosticTest", tracker)
|
||||
}
|
||||
|
||||
val context = SimpleGlobalContext(storageManager, tracker)
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ class BuiltInsSerializerTest : TestCaseWithTmpdir() {
|
||||
val module = KotlinTestUtils.createEmptyModule("<module>", DefaultBuiltIns.Instance)
|
||||
|
||||
val packageFragmentProvider = BuiltInsLoaderImpl().createBuiltInPackageFragmentProvider(
|
||||
LockBasedStorageManager(), module, setOf(TEST_PACKAGE_FQNAME), emptyList(), PlatformDependentDeclarationFilter.All
|
||||
LockBasedStorageManager("BuiltInsSerializerTest"), module, setOf(TEST_PACKAGE_FQNAME), emptyList(), PlatformDependentDeclarationFilter.All
|
||||
) {
|
||||
val file = File(tmpdir, it)
|
||||
if (file.exists()) FileInputStream(file) else null
|
||||
|
||||
@@ -83,7 +83,7 @@ public class LoadBuiltinsTest extends KotlinTestWithEnvironment {
|
||||
|
||||
@NotNull
|
||||
private static PackageFragmentProvider createBuiltInsPackageFragmentProvider() {
|
||||
LockBasedStorageManager storageManager = new LockBasedStorageManager();
|
||||
LockBasedStorageManager storageManager = new LockBasedStorageManager("LoadBuiltinsTest");
|
||||
ModuleDescriptorImpl builtInsModule =
|
||||
new ModuleDescriptorImpl(KotlinBuiltIns.BUILTINS_MODULE_NAME, storageManager, DefaultBuiltIns.getInstance());
|
||||
|
||||
|
||||
+1
-1
@@ -99,7 +99,7 @@ class KotlinJavascriptSerializerTest : TestCaseWithTmpdir() {
|
||||
|
||||
val (header, packageFragmentProtos) = readModuleAsProto(metadata.body, metadata.version)
|
||||
val provider = createKotlinJavascriptPackageFragmentProvider(
|
||||
LockBasedStorageManager(), module, header, packageFragmentProtos, metadata.version,
|
||||
LockBasedStorageManager("KotlinJavascriptrSerializerTest"), module, header, packageFragmentProtos, metadata.version,
|
||||
DeserializationConfiguration.Default, LookupTracker.DO_NOTHING
|
||||
).sure { "No package fragment provider was created" }
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public class StorageManagerTest extends TestCase {
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
m = new LockBasedStorageManager();
|
||||
m = new LockBasedStorageManager("StorageManagerTest");
|
||||
}
|
||||
|
||||
public static <T> void doTestComputesOnce(Function0<T> v, T expected, Counter counter) throws Exception {
|
||||
@@ -416,7 +416,7 @@ public class StorageManagerTest extends TestCase {
|
||||
public void testExceptionHandlingStrategyForLazyValues() throws Exception {
|
||||
class RethrownException extends RuntimeException {}
|
||||
|
||||
LockBasedStorageManager m = LockBasedStorageManager.createWithExceptionHandling(throwable -> {
|
||||
LockBasedStorageManager m = LockBasedStorageManager.createWithExceptionHandling("StorageManagerTest", throwable -> {
|
||||
throw new RethrownException();
|
||||
});
|
||||
try {
|
||||
@@ -432,7 +432,7 @@ public class StorageManagerTest extends TestCase {
|
||||
public void testExceptionHandlingStrategyForMemoizedFunctions() throws Exception {
|
||||
class RethrownException extends RuntimeException {}
|
||||
|
||||
LockBasedStorageManager m = LockBasedStorageManager.createWithExceptionHandling(throwable -> {
|
||||
LockBasedStorageManager m = LockBasedStorageManager.createWithExceptionHandling("StorageManagerTest", throwable -> {
|
||||
throw new RethrownException();
|
||||
});
|
||||
try {
|
||||
|
||||
@@ -494,7 +494,7 @@ open class JvmBuiltInsSettings(
|
||||
}
|
||||
}
|
||||
|
||||
private class FallbackBuiltIns private constructor() : KotlinBuiltIns(LockBasedStorageManager()) {
|
||||
private class FallbackBuiltIns private constructor() : KotlinBuiltIns(LockBasedStorageManager("FallbackBuiltIns")) {
|
||||
init {
|
||||
createBuiltInsModule()
|
||||
}
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ class RuntimeModuleData private constructor(
|
||||
|
||||
companion object {
|
||||
fun create(classLoader: ClassLoader): RuntimeModuleData {
|
||||
val storageManager = LockBasedStorageManager()
|
||||
val storageManager = LockBasedStorageManager("RuntimeModuleData")
|
||||
val builtIns = JvmBuiltIns(storageManager)
|
||||
val module = ModuleDescriptorImpl(Name.special("<runtime module for $classLoader>"), storageManager, builtIns)
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.builtins
|
||||
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||
|
||||
class DefaultBuiltIns private constructor() : KotlinBuiltIns(LockBasedStorageManager()) {
|
||||
class DefaultBuiltIns private constructor() : KotlinBuiltIns(LockBasedStorageManager("DefaultBuiltIns")) {
|
||||
init {
|
||||
createBuiltInsModule()
|
||||
}
|
||||
|
||||
@@ -64,8 +64,8 @@ public class LockBasedStorageManager implements StorageManager {
|
||||
};
|
||||
|
||||
@NotNull
|
||||
public static LockBasedStorageManager createWithExceptionHandling(@NotNull ExceptionHandlingStrategy exceptionHandlingStrategy) {
|
||||
return new LockBasedStorageManager(exceptionHandlingStrategy);
|
||||
public static LockBasedStorageManager createWithExceptionHandling(@NotNull String debugText, @NotNull ExceptionHandlingStrategy exceptionHandlingStrategy) {
|
||||
return new LockBasedStorageManager(debugText, exceptionHandlingStrategy, new ReentrantLock());
|
||||
}
|
||||
|
||||
protected final Lock lock;
|
||||
@@ -82,16 +82,8 @@ public class LockBasedStorageManager implements StorageManager {
|
||||
this.debugText = debugText;
|
||||
}
|
||||
|
||||
public LockBasedStorageManager() {
|
||||
this(defaultDebugName(), ExceptionHandlingStrategy.THROW, new ReentrantLock());
|
||||
}
|
||||
|
||||
protected LockBasedStorageManager(@NotNull ExceptionHandlingStrategy exceptionHandlingStrategy) {
|
||||
this(defaultDebugName(), exceptionHandlingStrategy, new ReentrantLock());
|
||||
}
|
||||
|
||||
private static String defaultDebugName() {
|
||||
return "<unknown creating class>";
|
||||
public LockBasedStorageManager(String debugText) {
|
||||
this(debugText, ExceptionHandlingStrategy.THROW, new ReentrantLock());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -526,14 +518,6 @@ public class LockBasedStorageManager implements StorageManager {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static LockBasedStorageManager createDelegatingWithSameLock(
|
||||
@NotNull LockBasedStorageManager base,
|
||||
@NotNull ExceptionHandlingStrategy newStrategy
|
||||
) {
|
||||
return new LockBasedStorageManager(defaultDebugName(), newStrategy, base.lock);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static <T extends Throwable> T sanitizeStackTrace(@NotNull T throwable) {
|
||||
StackTraceElement[] stackTrace = throwable.getStackTrace();
|
||||
|
||||
+4
-1
@@ -11,7 +11,10 @@ import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||
|
||||
internal fun GlobalContextImpl.contextWithNewLockAndCompositeExceptionTracker(): GlobalContextImpl {
|
||||
val newExceptionTracker = CompositeExceptionTracker(this.exceptionTracker)
|
||||
return GlobalContextImpl(LockBasedStorageManager.createWithExceptionHandling(newExceptionTracker), newExceptionTracker)
|
||||
return GlobalContextImpl(
|
||||
LockBasedStorageManager.createWithExceptionHandling("GlobalContextUtils", newExceptionTracker),
|
||||
newExceptionTracker
|
||||
)
|
||||
}
|
||||
|
||||
private class CompositeExceptionTracker(val delegate: ExceptionTracker) : ExceptionTracker() {
|
||||
|
||||
@@ -55,7 +55,7 @@ public class JsConfig {
|
||||
|
||||
private final Project project;
|
||||
private final CompilerConfiguration configuration;
|
||||
private final LockBasedStorageManager storageManager = new LockBasedStorageManager();
|
||||
private final LockBasedStorageManager storageManager = new LockBasedStorageManager("JsConfig");
|
||||
|
||||
private final List<KotlinJavascriptMetadata> metadata = new SmartList<>();
|
||||
private final List<KotlinJavascriptMetadata> friends = new SmartList<>();
|
||||
|
||||
Reference in New Issue
Block a user