// Path: src/main/java/org/antlr/jetbrains/st4plugin/STLanguage.java
// public class STLanguage extends Language {
// 
//     public static final STLanguage INSTANCE = new STLanguage();
// 
//     private STLanguage() {
//         super("ST");
//     }
// }
// 
// Path: src/main/java/org/antlr/jetbrains/st4plugin/parsing/LexerAdaptor.java
// public static final char DELIMITERS_PREFIX = '\u0001';
// 
// Path: src/main/java/org/antlr/jetbrains/st4plugin/psi/STGroupTokenTypes.java
// public static RuleIElementType getRuleElementType(@MagicConstant(valuesFromClass = STGParser.class) int ruleIndex) {
//     return RULE_ELEMENT_TYPES.get(ruleIndex);
// }
// 
// Path: src/main/java/org/antlr/jetbrains/st4plugin/psi/STGroupTokenTypes.java
// public static TokenIElementType getTokenElementType(@MagicConstant(valuesFromClass = STGLexer.class) int ruleIndex) {
//     return TOKEN_ELEMENT_TYPES.get(ruleIndex);
// }


import com.intellij.lang.ASTNode;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.InjectedLanguagePlaces;
import com.intellij.psi.LanguageInjector;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiLanguageInjectionHost;
import com.intellij.psi.tree.TokenSet;
import org.antlr.jetbrains.st4plugin.STLanguage;
import org.antlr.jetbrains.st4plugin.parsing.STGLexer;
import org.antlr.jetbrains.st4plugin.parsing.STGParser;
import org.jetbrains.annotations.NotNull;
import static org.antlr.jetbrains.st4plugin.parsing.LexerAdaptor.DELIMITERS_PREFIX;
import static org.antlr.jetbrains.st4plugin.psi.STGroupTokenTypes.getRuleElementType;
import static org.antlr.jetbrains.st4plugin.psi.STGroupTokenTypes.getTokenElementType;
package org.antlr.jetbrains.st4plugin.psi;



/**
 * Inject the {@link STLanguage} in {@link org.antlr.jetbrains.st4plugin.STGroupLanguage} subtemplates.
 */
public class STLanguageInjector implements LanguageInjector {

    @Override
    public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost host,
                                     @NotNull InjectedLanguagePlaces injectionPlacesRegistrar) {

        if (host instanceof TemplateContentElement) {
            PsiElement firstChild = host.getFirstChild();

            String delimiters = detectDelimiters(host);

            if (firstChild != null
// Path: src/main/java/org/antlr/jetbrains/st4plugin/STLanguage.java
// public class STLanguage extends Language {
// 
//     public static final STLanguage INSTANCE = new STLanguage();
// 
//     private STLanguage() {
//         super("ST");
//     }
// }
// 
// Path: src/main/java/org/antlr/jetbrains/st4plugin/parsing/LexerAdaptor.java
// public static final char DELIMITERS_PREFIX = '\u0001';
// 
// Path: src/main/java/org/antlr/jetbrains/st4plugin/psi/STGroupTokenTypes.java
// public static RuleIElementType getRuleElementType(@MagicConstant(valuesFromClass = STGParser.class) int ruleIndex) {
//     return RULE_ELEMENT_TYPES.get(ruleIndex);
// }
// 
// Path: src/main/java/org/antlr/jetbrains/st4plugin/psi/STGroupTokenTypes.java
// public static TokenIElementType getTokenElementType(@MagicConstant(valuesFromClass = STGLexer.class) int ruleIndex) {
//     return TOKEN_ELEMENT_TYPES.get(ruleIndex);
// }


// Path: src/main/java/org/antlr/jetbrains/st4plugin/psi/STLanguageInjector.java
import com.intellij.lang.ASTNode;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.InjectedLanguagePlaces;
import com.intellij.psi.LanguageInjector;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiLanguageInjectionHost;
import com.intellij.psi.tree.TokenSet;
import org.antlr.jetbrains.st4plugin.STLanguage;
import org.antlr.jetbrains.st4plugin.parsing.STGLexer;
import org.antlr.jetbrains.st4plugin.parsing.STGParser;
import org.jetbrains.annotations.NotNull;
import static org.antlr.jetbrains.st4plugin.parsing.LexerAdaptor.DELIMITERS_PREFIX;
import static org.antlr.jetbrains.st4plugin.psi.STGroupTokenTypes.getRuleElementType;
import static org.antlr.jetbrains.st4plugin.psi.STGroupTokenTypes.getTokenElementType;

package org.antlr.jetbrains.st4plugin.psi;



/**
 * Inject the {@link STLanguage} in {@link org.antlr.jetbrains.st4plugin.STGroupLanguage} subtemplates.
 */
public class STLanguageInjector implements LanguageInjector {

    @Override
    public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost host,
                                     @NotNull InjectedLanguagePlaces injectionPlacesRegistrar) {

        if (host instanceof TemplateContentElement) {
            PsiElement firstChild = host.getFirstChild();

            String delimiters = detectDelimiters(host);

            if (firstChild != null
                    && (firstChild.getNode().getElementType() == getTokenElementType(STGLexer.BIGSTRING) || firstChild.getNode().getElementType() == getTokenElementType(STGLexer.BIGSTRING_NO_NL))