SettingsTransferActivity - use serviceAsync

GitOrigin-RevId: 3e70a454dfe6ab15fc49b1e154508972c21857d0
This commit is contained in:
Vladimir Krivosheev
2024-03-13 20:05:23 +01:00
committed by intellij-monorepo-bot
parent afc812872f
commit a313dd217f

View File

@@ -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<SpellCheckerSettings>()
if (settings.isSettingsTransferred) {
return
}
if (settings.isUseSingleDictionaryToSave && ProjectDictionaryLayer.name.get() == settings.dictionaryToSave &&
project.getService(ProjectDictionaryState::class.java).projectDictionary.words.isEmpty()) {
project.serviceAsync<ProjectDictionaryState>().projectDictionary.words.isEmpty()) {
settings.dictionaryToSave = ApplicationDictionaryLayer.name
}
settings.isSettingsTransferred = true