IJPL-207762 [command completion] sync command completion settings between FE and BE

GitOrigin-RevId: 541af0cd34e8df639923ee031ab01a2514ef22c5
This commit is contained in:
Max Medvedev
2026-02-14 15:01:54 +00:00
committed by intellij-monorepo-bot
parent 05b452e26e
commit ca39ed7818
2 changed files with 22 additions and 8 deletions
@@ -74,5 +74,9 @@
<completion.frontendFriendlyPrefixMatcher target="com.intellij.codeInsight.completion.impl.BetterPrefixMatcher$AutoRestarting"
converter="com.intellij.codeInsight.completion.impl.BetterPrefixMatcher$AutoRestarting$Converter"
descriptor="com.intellij.codeInsight.completion.impl.BetterPrefixMatcher$AutoRestarting$Descriptor"/>
<applicationService serviceImplementation="com.intellij.codeInsight.completion.command.configuration.ApplicationCommandCompletionService"/>
<applicationSettings service="com.intellij.codeInsight.completion.command.configuration.ApplicationCommandCompletionService"/>
</extensions>
</idea-plugin>
@@ -1,4 +1,4 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInsight.completion.command.configuration
import com.intellij.openapi.application.ApplicationManager
@@ -8,6 +8,7 @@ import com.intellij.openapi.components.Service
import com.intellij.openapi.components.SettingsCategory
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.openapi.components.service
import com.intellij.openapi.util.registry.Registry
import com.intellij.util.PlatformUtils
import org.jetbrains.annotations.ApiStatus
@@ -17,16 +18,21 @@ import org.jetbrains.annotations.TestOnly
/**
* Service responsible for managing and persisting command completion settings at the application level.
*/
@Service(Service.Level.APP)
@ApiStatus.Internal
@State(name = "CommandCompletion", category = SettingsCategory.UI, storages = [Storage("CommandCompletion.xml", roamingType = RoamingType.DISABLED)])
@State(
name = "CommandCompletion",
category = SettingsCategory.UI,
storages = [
Storage(value = "CommandCompletion.xml", roamingType = RoamingType.DEFAULT)
]
)
internal class ApplicationCommandCompletionService : PersistentStateComponent<AppCommandCompletionSettings> {
companion object {
internal fun getInstance(): ApplicationCommandCompletionService = ApplicationManager.getApplication().getService(ApplicationCommandCompletionService::class.java)
fun getInstance(): ApplicationCommandCompletionService = service<ApplicationCommandCompletionService>()
private fun initialState(): AppCommandCompletionSettings = AppCommandCompletionSettings()
}
private var myState = AppCommandCompletionSettings()
private var myState = initialState()
override fun getState(): AppCommandCompletionSettings = myState
@@ -34,6 +40,10 @@ internal class ApplicationCommandCompletionService : PersistentStateComponent<Ap
myState = state
}
override fun noStateLoaded() {
loadState(initialState())
}
fun commandCompletionEnabled(): Boolean {
return myState.isEnabled()
}
@@ -52,7 +62,7 @@ internal class ApplicationCommandCompletionService : PersistentStateComponent<Ap
class CommandCompletionSettingsService {
companion object {
@JvmStatic
fun getInstance(): CommandCompletionSettingsService = ApplicationManager.getApplication().getService(CommandCompletionSettingsService::class.java)
fun getInstance(): CommandCompletionSettingsService = service<CommandCompletionSettingsService>()
}
fun commandCompletionEnabled(): Boolean {