dkandalov/live-plugin

Language Injection

JarriqTheTechie opened this issue · 2 comments

Is it possible to get a language injection example?

I can register simple implementation via plugin.xml
But for my needs full plugin is overkill. LivePlugin is doing all small things now.

Example. I have a small implementation of MultiHostInjector

class PhpExampleInjector: MultiHostInjector {
    override fun getLanguagesToInject(registrar: MultiHostRegistrar, context: PsiElement) {
        val tag = context.parent
        if (tag is HtmlTag && tag.name.equals("php")) {
            registrar.startInjecting(PhpLanguage.INSTANCE)
            registrar.addPlace("<?php ", " ?>", context as XmlTextImpl, TextRange.create(0, context.textLength - 1))
            registrar.doneInjecting()
        }
    }
    override fun elementsToInjectIn(): List<Class<out PsiElement>> =
        listOf(XmlTextImpl::class.java)
}

is it possible to register it in runtime using Live Plugin?