Language Injection
JarriqTheTechie opened this issue · 2 comments
JarriqTheTechie commented
Is it possible to get a language injection example?
Yoskaldyr commented
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?
Yoskaldyr commented
I'm trying to register example from here:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/18009280429202-Injecting-PHP-in-HTML-in-PHP-files