Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language Injection #173

Open
JarriqTheTechie opened this issue Jan 6, 2024 · 2 comments
Open

Language Injection #173

JarriqTheTechie opened this issue Jan 6, 2024 · 2 comments

Comments

@JarriqTheTechie
Copy link

Is it possible to get a language injection example?

@Yoskaldyr
Copy link

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
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants