idea-plugin / arrow.meta.ide.dsl.extensions / ExtensionProviderSyntax / extensionProvider

extensionProvider

open fun <E> IdeMetaPlugin.extensionProvider(EP_NAME: ExtensionPointName<E>, impl: E, loadingOrder: LoadingOrder = LoadingOrder.ANY): ExtensionPhase

The extensionProvider function registers a concrete implementation for Extensions with an ExtensionPointName. Or builds higher-level API’s such as IconProviderSyntax.addIcon, which registers a FileIcon to a File and StructureView using IconProvider.EXTENSION_POINT_NAME.

import arrow.meta.internal.Noop
import arrow.meta.phases.ExtensionPhase
import arrow.meta.ide.IdeMetaPlugin
import com.intellij.ide.IconProvider
import com.intellij.openapi.extensions.LoadingOrder
import com.intellij.openapi.project.DumbAware
import com.intellij.psi.PsiElement
import javax.swing.Icon

//sampleStart
fun <A : PsiElement> IdeMetaPlugin.addIcon(
  icon: Icon? = null,
  transform: (psiElement: PsiElement, flag: Int) -> A? = Noop.nullable2()
 ): ExtensionPhase =
  extensionProvider(
    IconProvider.EXTENSION_POINT_NAME,
    object : IconProvider(), DumbAware {
    // [DumbAware] signifies that this implementation is available when the editor performs an index update.
      override fun getIcon(p0: PsiElement, p1: Int): Icon? =
        transform(p0, p1)?.run { icon }
     },
    LoadingOrder.FIRST
  )
//sampleEnd

More importantly, using extensionProvider and all its variations lifts any ide workflow for Extension's to Meta and is evident to all derived instances like LineMarkerSyntax, InspectionSyntax, SearchSyntax and many more. Hence, if a costum workflow, doesn’t exist in Meta, using the aforementioned technique does so. We’re always open for PR’s to extend Meta.

Parameters

impl - is the concrete implementation

loadingOrder - has to be set as LoadingOrder.FIRST, whenever we introduce visual changes

See Also

ExtensionProviderSyntax

open fun <E> IdeMetaPlugin.extensionProvider(LE: LanguageExtension<E>, impl: E, lang: Language = KotlinLanguage.INSTANCE): ExtensionPhase

The extensionProvider extension registers a concrete implementation for LanguageExtension’s.

See Also

extensionProvider

open fun <E> IdeMetaPlugin.extensionProvider(FE: FileTypeExtension<E>, impl: E, fileType: LanguageFileType = KotlinFileType.INSTANCE): ExtensionPhase

The extensionProvider function registers a concrete implementation for FileTypeExtension’s.

See Also

extensionProvider

open fun <E> IdeMetaPlugin.extensionProvider(CE: ClassExtension<E>, forClass: Class<*>, impl: E): ExtensionPhase

The extensionProvider extension registers a concrete implementation for ClassExtension’s.

See Also

extensionProvider

Do you like Arrow?

Arrow Org
<