[R-1508] simplify InlayStateCustomizer

GitOrigin-RevId: e20455537a5bdb104f828a50d83c4e95c5f20def
This commit is contained in:
Igor Slobodskov
2024-07-01 15:40:13 +02:00
committed by intellij-monorepo-bot
parent beebabe85b
commit ae6c8dfb5c
2 changed files with 7 additions and 10 deletions

View File

@@ -321,9 +321,7 @@ abstract class NotebookInlayComponent(protected val editor: EditorImpl)
shouldLimitMaxHeight = false
}
InlayStateCustomizer.EP.extensionList
.filter { it.isApplicableTo(output::class.java) }
.forEach { customizer -> customizer.customize(output) }
InlayStateCustomizer.customize(output)
if (UiCustomizer.instance.isResizeOutputToPreviewHeight && size.height == InlayDimensions.smallHeight) {
deltaSize(0, InlayDimensions.previewHeight - size.height)
@@ -354,9 +352,7 @@ abstract class NotebookInlayComponent(protected val editor: EditorImpl)
resizable = true
(state as? NotebookInlayMultiOutput)?.also { st ->
st.onOutputs(inlayOutputs)
InlayStateCustomizer.EP.extensionList
.filter { it.isApplicableTo(st::class.java) }
.forEach { customizer -> customizer.customize(st) }
InlayStateCustomizer.customize(st)
}
}

View File

@@ -14,13 +14,14 @@ import org.jetbrains.annotations.ApiStatus.Experimental
* */
@Experimental
interface InlayStateCustomizer {
/** Checks if a customizer can customize an inlay output of the given type. */
fun <T : NotebookInlayState> isApplicableTo(klass: Class<T>): Boolean = true
/** Applies customizations and return the inlay output. */
fun customize(state: NotebookInlayState): NotebookInlayState
companion object {
val EP = ExtensionPointName.create<InlayStateCustomizer>("com.intellij.datavis.inlays.components.inlayStateCustomizer")
private val EP = ExtensionPointName.create<InlayStateCustomizer>("com.intellij.datavis.inlays.components.inlayStateCustomizer")
fun customize(state: NotebookInlayState) {
EP.extensionList.forEach { customizer -> customizer.customize(state) }
}
}
}