Search in sources :

Example 1 with PerlHeredocLanguageInjector

use of com.perl5.lang.perl.idea.intellilang.PerlHeredocLanguageInjector in project Perl5-IDEA by Camelcade.

the class PerlHeredocInjectionTestCase method getHeredocDecodedText.

protected String getHeredocDecodedText(@Nullable PerlHeredocElementImpl heredocElement) {
    assertNotNull(heredocElement);
    StringBuilder sb = new StringBuilder();
    LiteralTextEscaper<PerlHeredocElementImpl> escaper = heredocElement.createLiteralTextEscaper();
    // host MUST be auto-injected with our own injector
    new PerlHeredocLanguageInjector().getLanguagesToInject(new MultiHostRegistrar() {

        @NotNull
        @Override
        public MultiHostRegistrar startInjecting(@NotNull Language language) {
            return this;
        }

        @NotNull
        @Override
        public MultiHostRegistrar addPlace(@Nullable String prefix, @Nullable String suffix, @NotNull PsiLanguageInjectionHost host, @NotNull TextRange rangeInsideHost) {
            escaper.decode(rangeInsideHost, sb);
            return this;
        }

        @Override
        public void doneInjecting() {
        }
    }, heredocElement);
    return sb.toString();
}
Also used : PerlHeredocLanguageInjector(com.perl5.lang.perl.idea.intellilang.PerlHeredocLanguageInjector) Language(com.intellij.lang.Language) PsiLanguageInjectionHost(com.intellij.psi.PsiLanguageInjectionHost) TextRange(com.intellij.openapi.util.TextRange) MultiHostRegistrar(com.intellij.lang.injection.MultiHostRegistrar) NotNull(org.jetbrains.annotations.NotNull) PerlHeredocElementImpl(com.perl5.lang.perl.psi.impl.PerlHeredocElementImpl)

Aggregations

Language (com.intellij.lang.Language)1 MultiHostRegistrar (com.intellij.lang.injection.MultiHostRegistrar)1 TextRange (com.intellij.openapi.util.TextRange)1 PsiLanguageInjectionHost (com.intellij.psi.PsiLanguageInjectionHost)1 PerlHeredocLanguageInjector (com.perl5.lang.perl.idea.intellilang.PerlHeredocLanguageInjector)1 PerlHeredocElementImpl (com.perl5.lang.perl.psi.impl.PerlHeredocElementImpl)1 NotNull (org.jetbrains.annotations.NotNull)1