diff --git a/spellchecker/src/com/intellij/spellchecker/settings/SettingsTransferActivity.kt b/spellchecker/src/com/intellij/spellchecker/settings/SettingsTransferActivity.kt index 9334894efb91..e79164c8d4f8 100644 --- a/spellchecker/src/com/intellij/spellchecker/settings/SettingsTransferActivity.kt +++ b/spellchecker/src/com/intellij/spellchecker/settings/SettingsTransferActivity.kt @@ -1,20 +1,30 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.spellchecker.settings +import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.components.serviceAsync +import com.intellij.openapi.extensions.ExtensionNotApplicableException import com.intellij.openapi.project.Project import com.intellij.openapi.startup.ProjectActivity import com.intellij.spellchecker.ApplicationDictionaryLayer import com.intellij.spellchecker.ProjectDictionaryLayer import com.intellij.spellchecker.state.ProjectDictionaryState -internal class SettingsTransferActivity : ProjectActivity { +private class SettingsTransferActivity : ProjectActivity { + init { + if (ApplicationManager.getApplication().isUnitTestMode) { + throw ExtensionNotApplicableException.create() + } + } + override suspend fun execute(project: Project) { - val settings = SpellCheckerSettings.getInstance(project) + val settings = project.serviceAsync() if (settings.isSettingsTransferred) { return } + if (settings.isUseSingleDictionaryToSave && ProjectDictionaryLayer.name.get() == settings.dictionaryToSave && - project.getService(ProjectDictionaryState::class.java).projectDictionary.words.isEmpty()) { + project.serviceAsync().projectDictionary.words.isEmpty()) { settings.dictionaryToSave = ApplicationDictionaryLayer.name } settings.isSettingsTransferred = true