IJPL-211960: Introduce HotSwapSourceFileFilterProvider to enable custom filtering of source files staged for HotSwap

- custom plugins could influence this decision
- precise filtering could be implemented upon this logic

GitOrigin-RevId: 2abba919ca41b29d4ed34d7405eae30c59c4e595
This commit is contained in:
Nikolay Egorov
2026-02-12 20:47:32 +00:00
committed by intellij-monorepo-bot
parent fe76e2f705
commit 0a47e3e278
3 changed files with 34 additions and 0 deletions
@@ -65,6 +65,8 @@
interface="com.intellij.debugger.impl.ThreadDumpItemsProviderFactory" dynamic="true"/>
<extensionPoint qualifiedName="com.intellij.debugger.agentParametersModifier"
interface="com.intellij.debugger.engine.DebuggerAgentParametersModifier" dynamic="true"/>
<extensionPoint qualifiedName="com.intellij.debugger.hotSwapSourceFileFilterProvider"
interface="com.intellij.debugger.impl.hotswap.HotSwapSourceFileFilterProvider" dynamic="true"/>
</extensionPoints>
<extensions defaultExtensionNs="com.intellij">
@@ -0,0 +1,30 @@
// 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.debugger.impl.hotswap
import com.intellij.debugger.impl.DebuggerSession
import com.intellij.openapi.extensions.ExtensionPointName
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.xdebugger.hotswap.HotSwapProvider
import com.intellij.xdebugger.hotswap.SourceFileChangesCollector
import com.intellij.xdebugger.impl.hotswap.SourceFileChangeFilter
import org.jetbrains.annotations.ApiStatus
/**
* The aim of this interface is to allow different plugins to provide custom filtering of changes staged for HotSwap.
*
* Implementations of [HotSwapProvider] should call EPs of this interface upon
* creation of [SourceFileChangesCollector] to propagate filters.
*/
@ApiStatus.Experimental
@ApiStatus.Internal
interface HotSwapSourceFileFilterProvider {
fun provideFiltersForSession(debuggerSession: DebuggerSession): List<SourceFileChangeFilter<VirtualFile>>
companion object {
private val EP_NAME: ExtensionPointName<HotSwapSourceFileFilterProvider> = ExtensionPointName("com.intellij.debugger.hotSwapSourceFileFilterProvider")
fun findSourceFiltersForSession(debuggerSession: DebuggerSession): List<SourceFileChangeFilter<VirtualFile>> {
return EP_NAME.extensionsIfPointIsRegistered.flatMap { it.provideFiltersForSession(debuggerSession) }
}
}
}
@@ -25,10 +25,12 @@ internal class JvmHotSwapProvider(private val debuggerSession: DebuggerSession)
): SourceFileChangesCollector<VirtualFile> {
val jvmExtensions = Language.findInstance(JvmMetaLanguage::class.java).getMatchingLanguages()
.mapNotNull { it.associatedFileType?.defaultExtension }
val filtersFromProviders = HotSwapSourceFileFilterProvider.findSourceFiltersForSession(debuggerSession)
return SourceFileChangesCollectorImpl(
coroutineScope, listener,
FileExtensionFilter(jvmExtensions),
InProjectFilter(session.project),
*filtersFromProviders.toTypedArray(),
)
}