Search in sources :

Example 1 with TemporaryPlacesRegistry

use of org.intellij.plugins.intelliLang.inject.TemporaryPlacesRegistry in project intellij-community by JetBrains.

the class PyTemporaryInjector method getInjectedLanguage.

@Nullable
@Override
public Language getInjectedLanguage(@NotNull PsiElement context) {
    final TemporaryPlacesRegistry registry = TemporaryPlacesRegistry.getInstance(context.getProject());
    if (context instanceof PsiLanguageInjectionHost) {
        final PsiFile file = context.getContainingFile();
        final InjectedLanguage injectedLanguage = registry.getLanguageFor((PsiLanguageInjectionHost) context, file);
        if (injectedLanguage != null) {
            return injectedLanguage.getLanguage();
        }
    }
    return null;
}
Also used : TemporaryPlacesRegistry(org.intellij.plugins.intelliLang.inject.TemporaryPlacesRegistry) InjectedLanguage(org.intellij.plugins.intelliLang.inject.InjectedLanguage) PsiLanguageInjectionHost(com.intellij.psi.PsiLanguageInjectionHost) PsiFile(com.intellij.psi.PsiFile) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with TemporaryPlacesRegistry

use of org.intellij.plugins.intelliLang.inject.TemporaryPlacesRegistry in project intellij-community by JetBrains.

the class PyTemporaryInjector method getLanguagesToInject.

@Override
public void getLanguagesToInject(@NotNull MultiHostRegistrar registrar, @NotNull PsiElement context) {
    final PyInjectionUtil.InjectionResult result = registerInjection(registrar, context);
    if (result.isInjected()) {
        final TemporaryPlacesRegistry registry = TemporaryPlacesRegistry.getInstance(context.getProject());
        InjectorUtils.registerSupport(registry.getLanguageInjectionSupport(), false, registrar);
        if (!result.isStrict()) {
            InjectorUtils.putInjectedFileUserData(registrar, InjectedLanguageUtil.FRANKENSTEIN_INJECTION, Boolean.TRUE);
        }
    }
}
Also used : TemporaryPlacesRegistry(org.intellij.plugins.intelliLang.inject.TemporaryPlacesRegistry) PyInjectionUtil(com.jetbrains.python.codeInsight.PyInjectionUtil)

Example 3 with TemporaryPlacesRegistry

use of org.intellij.plugins.intelliLang.inject.TemporaryPlacesRegistry in project intellij-plugins by JetBrains.

the class CodeFenceTemporaryLangInjector method findLangForInjection.

@Nullable
@Override
protected Language findLangForInjection(@NotNull MarkdownCodeFenceImpl element) {
    final TemporaryPlacesRegistry registry = TemporaryPlacesRegistry.getInstance(element.getProject());
    final InjectedLanguage language = registry.getLanguageFor(element, element.getContainingFile());
    if (language != null) {
        return language.getLanguage();
    }
    return null;
}
Also used : TemporaryPlacesRegistry(org.intellij.plugins.intelliLang.inject.TemporaryPlacesRegistry) InjectedLanguage(org.intellij.plugins.intelliLang.inject.InjectedLanguage) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

TemporaryPlacesRegistry (org.intellij.plugins.intelliLang.inject.TemporaryPlacesRegistry)3 InjectedLanguage (org.intellij.plugins.intelliLang.inject.InjectedLanguage)2 Nullable (org.jetbrains.annotations.Nullable)2 PsiFile (com.intellij.psi.PsiFile)1 PsiLanguageInjectionHost (com.intellij.psi.PsiLanguageInjectionHost)1 PyInjectionUtil (com.jetbrains.python.codeInsight.PyInjectionUtil)1