public static void registerInjection(@Nullable Language language,
                                       @NotNull PsiFile containingFile,
                                       @NotNull List<InjectionInfo> list,
                                       @NotNull MultiHostRegistrar registrar) {
    // if language isn't injected when length == 0, subsequent edits will not cause the language to be injected as well.
    // Maybe IDEA core is caching a bit too aggressively here?
    if (language == null/* && (pair.second.getLength() > 0*/) {
      return;
    }
    ParserDefinition parser = LanguageParserDefinitions.INSTANCE.forLanguage(language);
    ReferenceInjector injector = ReferenceInjector.findById(language.getID());
    if (parser == null && injector != null) {
      for (InjectionInfo trinity : list) {
        String prefix = trinity.language().getPrefix();
        String suffix = trinity.language().getSuffix();
        PsiLanguageInjectionHost host = trinity.host();
        TextRange textRange = trinity.range();
        InjectedLanguageUtil.injectReference(registrar, language, prefix, suffix, host, textRange);
        return;
      }
      return;
    }
    boolean injectionStarted = false;
    for (InjectionInfo t : list) {
      PsiLanguageInjectionHost host = t.host();
      if (host.getContainingFile() != containingFile || !host.isValidHost()) continue;

      TextRange textRange = t.range();
      InjectedLanguage injectedLanguage = t.language();

      if (!injectionStarted) {
        // TextMate language requires file extension
        if (!StringUtil.equalsIgnoreCase(language.getID(), t.language().getID())) {
          registrar.startInjecting(language, StringUtil.toLowerCase(t.language().getID()));
        }
        else {
          registrar.startInjecting(language);
        }
        injectionStarted = true;
      }
      registrar.addPlace(injectedLanguage.getPrefix(), injectedLanguage.getSuffix(), host, textRange);
    }
    if (injectionStarted) {
      registrar.doneInjecting();
    }
  }
public static void registerInjection(@Nullable Language language,
                                       @NotNull PsiFile containingFile,
                                       @NotNull List<InjectionInfo> list,
                                       @NotNull MultiHostRegistrar registrar)