Java Code Examples for com.intellij.psi.PsiLanguageInjectionHost

The following examples show how to use com.intellij.psi.PsiLanguageInjectionHost. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: idea-php-typo3-plugin   Source File: FluidInjector.java    License: MIT License 6 votes vote down vote up
@Override
public void getLanguagesToInject(@NotNull MultiHostRegistrar registrar, @NotNull PsiElement context) {
    if (context.getLanguage() == XMLLanguage.INSTANCE) return;
    final Project project = context.getProject();
    if (!FluidIndexUtil.hasFluid(project)) return;

    final PsiElement parent = context.getParent();
    if (context instanceof XmlAttributeValueImpl && parent instanceof XmlAttribute) {
        final int length = context.getTextLength();
        final String name = ((XmlAttribute) parent).getName();

        if (isInjectableAttribute(project, length, name)) {
            registrar
                .startInjecting(FluidLanguage.INSTANCE)
                .addPlace(null, null, (PsiLanguageInjectionHost) context, ElementManipulators.getValueTextRange(context))
                .doneInjecting();
        }
    }
}
 
Example 2
@Test
public void testEncoding() throws Exception {
    PsiFile psiFile = myFixture.configureByText(BashFileType.BASH_FILE_TYPE, " 'abc\n'");

    BashWordImpl word = PsiTreeUtil.findChildOfType(psiFile, BashWordImpl.class);
    Assert.assertNotNull(word);

    LiteralTextEscaper<? extends PsiLanguageInjectionHost> escaper = word.createLiteralTextEscaper();
    Assert.assertTrue(escaper instanceof BashIdentityStringLiteralEscaper<?>);

    TextRange range = TextRange.allOf(word.getUnwrappedCharSequence());
    Assert.assertEquals(0, escaper.getOffsetInHost(0, range));
    Assert.assertEquals(1, escaper.getOffsetInHost(1, range));
    Assert.assertEquals(2, escaper.getOffsetInHost(2, range));
    Assert.assertEquals(3, escaper.getOffsetInHost(3, range));
    Assert.assertEquals(4, escaper.getOffsetInHost(4, range));
}
 
Example 3
Source Project: BashSupport   Source File: InjectionReferenceTest.java    License: Apache License 2.0 6 votes vote down vote up
@NotNull
private PsiElement findInjectedBashReference(String fileName, String lookupText) {
    PsiElement javaLiteral = configurePsiAtCaret(fileName);
    Assert.assertTrue(javaLiteral instanceof PsiLanguageInjectionHost);

    //inject bash into the literal
    InjectLanguageAction.invokeImpl(getProject(), myFixture.getEditor(), javaLiteral.getContainingFile(), Injectable.fromLanguage(BashFileType.BASH_LANGUAGE));

    String fileContent = javaLiteral.getContainingFile().getText();
    PsiElement bashPsiLeaf = InjectedLanguageManager.getInstance(getProject()).findInjectedElementAt(myFixture.getFile(), fileContent.indexOf(lookupText) + 1);
    Assert.assertNotNull(bashPsiLeaf);

    PsiElement reference = PsiTreeUtil.findFirstParent(bashPsiLeaf, psiElement -> psiElement.getReference() != null);
    Assert.assertNotNull(reference);

    return reference;
}
 
Example 4
@Test
public void testEscaped1() throws Exception {
    BashWordImpl psiElement = (BashWordImpl) BashPsiElementFactory.createWord(myProject, "$'a\\'a'");
    Assert.assertNotNull(psiElement);

    LiteralTextEscaper<? extends PsiLanguageInjectionHost> textEscaper = psiElement.createLiteralTextEscaper();

    StringBuilder content = new StringBuilder();
    TextRange range = psiElement.getTextContentRange();
    textEscaper.decode(range, content);
    Assert.assertEquals("a'a", content.toString());

    //check the offsets
    Assert.assertEquals(2, textEscaper.getOffsetInHost(0, range)); // a at 2
    Assert.assertEquals(3, textEscaper.getOffsetInHost(1, range)); // ' at 3-4
    Assert.assertEquals(5, textEscaper.getOffsetInHost(2, range)); // a at 5
}
 
Example 5
@Test
public void testEscaped2() throws Exception {
    // unescpaed content: a\\"'a
    // java escapes \\ to \\\\
    // bash escapes \\\\ to \\\\\\\\
    BashWordImpl psiElement = (BashWordImpl) BashPsiElementFactory.createWord(myProject, "$'a\\\\\\\\\"\\'a\\'");
    Assert.assertNotNull(psiElement);

    LiteralTextEscaper<? extends PsiLanguageInjectionHost> textEscaper = psiElement.createLiteralTextEscaper();

    StringBuilder content = new StringBuilder();
    TextRange range = psiElement.getTextContentRange();
    textEscaper.decode(range, content);

    //decoded text is a\\"'a
    Assert.assertEquals("a\\\\\"'a", content.toString());

    //check the offsets
    Assert.assertEquals(2, textEscaper.getOffsetInHost(0, range)); // a at 2
    Assert.assertEquals(3, textEscaper.getOffsetInHost(1, range)); // \ at 3-4
    Assert.assertEquals(5, textEscaper.getOffsetInHost(2, range)); // \ at 5-6
    Assert.assertEquals(7, textEscaper.getOffsetInHost(3, range)); // " at 7
    Assert.assertEquals(8, textEscaper.getOffsetInHost(4, range)); // ' at 8-9
    Assert.assertEquals(10, textEscaper.getOffsetInHost(5, range)); // a at 10
}
 
Example 6
Source Project: dbunit-extractor   Source File: SQLInjector.java    License: MIT License 6 votes vote down vote up
@Override
public void getLanguagesToInject(@NotNull final PsiLanguageInjectionHost host,
                                 @NotNull final InjectedLanguagePlaces places) {
    final boolean isSelectQuery = host.getText().trim().toUpperCase().startsWith("SELECT");
    final boolean isDataSetFile = host.getContainingFile().getText().startsWith("<dataset>");
    if (isDataSetFile && isSelectQuery) {
        final Language language = Language.findLanguageByID("SQL");
        if (language != null) {
            try {
                places.addPlace(language, TextRange.from(0, host.getTextLength()), null, null);
            } catch (Throwable e) {
                e.printStackTrace();
            }
        }
    }
}
 
Example 7
Source Project: idea-php-laravel-plugin   Source File: BladeInjectTypeProvider.java    License: MIT License 6 votes vote down vote up
/**
 *  Resolve PHP language injection in Blade
 *
 *  @see BladeVariableTypeProvider#getHostPhpFileForInjectedIfExists
 */
@Nullable
private static BladeFileImpl getHostBladeFileForInjectionIfExists(PsiElement element) {
    PsiFile file = element.getContainingFile();
    InjectedLanguageManager injectedLanguageManager = InjectedLanguageManager.getInstance(element.getProject());
    if (injectedLanguageManager.isInjectedFragment(file)) {
        PsiLanguageInjectionHost host = injectedLanguageManager.getInjectionHost(element);
        if (host instanceof BladePsiLanguageInjectionHost && host.isValidHost()) {
            PsiFile bladeFile = host.getContainingFile();
            if (bladeFile instanceof BladeFileImpl) {
                return (BladeFileImpl) bladeFile;
            }
        }
    }

    return null;
}
 
Example 8
Source Project: idea-php-laravel-plugin   Source File: BladeDirectiveReferences.java    License: MIT License 6 votes vote down vote up
@NotNull
@Override
public Collection<PsiElement> getPsiTargets(StringLiteralExpression element) {

    PsiLanguageInjectionHost host = InjectedLanguageManager.getInstance(getProject()).getInjectionHost(getElement());
    if (!(host instanceof BladePsiLanguageInjectionHost)) {
        return Collections.emptyList();
    }

    final String sectionNameSource = element.getContents();
    if(StringUtils.isBlank(sectionNameSource)) {
        return Collections.emptyList();
    }

    final Set<PsiElement> uniqueSet = new HashSet<>();
    BladeTemplateUtil.visitUpPath(host.getContainingFile(), 10, parameter -> {
        if(sectionNameSource.equalsIgnoreCase(parameter.getContent())) {
            uniqueSet.add(parameter.getPsiElement());
        }
    }, this.visitElements);

    return uniqueSet;
}
 
Example 9
public ShaderLabCGCompletionContributor()
{
	extend(CompletionType.BASIC, StandardPatterns.psiElement().withLanguage(CGLanguage.INSTANCE), new CompletionProvider()
	{
		@RequiredReadAction
		@Override
		public void addCompletions(@Nonnull CompletionParameters parameters, ProcessingContext context, @Nonnull final CompletionResultSet result)
		{
			Place shreds = InjectedLanguageUtil.getShreds(parameters.getOriginalFile());

			for(PsiLanguageInjectionHost.Shred shred : shreds)
			{
				PsiLanguageInjectionHost host = shred.getHost();
				if(host instanceof ShaderCGScript)
				{
					ShaderLabFile containingFile = (ShaderLabFile) host.getContainingFile();
					ShaderReference.consumeProperties(containingFile, result::addElement);
				}
			}
		}
	});
}
 
Example 10
@Nonnull
@Override
@RequiredReadAction
public LiteralTextEscaper<? extends PsiLanguageInjectionHost> createLiteralTextEscaper()
{
	IElementType elementType = getLiteralType();
	if(elementType == CSharpTokens.STRING_LITERAL)
	{
		return new CSharpStringLiteralEscaper<>(this);
	}
	else if(elementType == CSharpTokens.VERBATIM_STRING_LITERAL)
	{
		return LiteralTextEscaper.createSimple(this);
	}
	throw new IllegalArgumentException("Unknown " + elementType);
}
 
Example 11
Source Project: consulo   Source File: QuickEditAction.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
protected Pair<PsiElement, TextRange> getRangePair(final PsiFile file, final Editor editor) {
  final int offset = editor.getCaretModel().getOffset();
  final PsiLanguageInjectionHost host =
          PsiTreeUtil.getParentOfType(file.findElementAt(offset), PsiLanguageInjectionHost.class, false);
  if (host == null || ElementManipulators.getManipulator(host) == null) return null;
  final List<Pair<PsiElement, TextRange>> injections = InjectedLanguageManager.getInstance(host.getProject()).getInjectedPsiFiles(host);
  if (injections == null || injections.isEmpty()) return null;
  final int offsetInElement = offset - host.getTextRange().getStartOffset();
  final Pair<PsiElement, TextRange> rangePair = ContainerUtil.find(injections, new Condition<Pair<PsiElement, TextRange>>() {
    @Override
    public boolean value(final Pair<PsiElement, TextRange> pair) {
      return pair.second.containsRange(offsetInElement, offsetInElement);
    }
  });
  if (rangePair != null) {
    final Language language = rangePair.first.getContainingFile().getLanguage();
    final Object action = language.getUserData(EDIT_ACTION_AVAILABLE);
    if (action != null && action.equals(false)) return null;

    myLastLanguageName = language.getDisplayName();
  }
  return rangePair;
}
 
Example 12
Source Project: consulo   Source File: DocumentWindowImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public int getLineStartOffset(int line) {
  LOG.assertTrue(line >= 0, line);
  if (line == 0) return 0;
  String hostText = myDelegate.getText();

  int[] pos = new int[2]; // pos[0] = curLine; pos[1] == offset;
  synchronized (myLock) {
    for (PsiLanguageInjectionHost.Shred shred : myShreds) {
      Segment hostRange = shred.getHostRangeMarker();
      if (hostRange == null) continue;

      int found = countNewLinesIn(shred.getPrefix(), pos, line);
      if (found != -1) return found;

      CharSequence text = hostText.subSequence(hostRange.getStartOffset(), hostRange.getEndOffset());
      found = countNewLinesIn(text, pos, line);
      if (found != -1) return found;

      found = countNewLinesIn(shred.getSuffix(), pos, line);
      if (found != -1) return found;
    }
  }

  return pos[1];
}
 
Example 13
Source Project: consulo   Source File: DocumentWindowImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
private String calcText() {
  StringBuilder text = new StringBuilder();
  CharSequence hostText = myDelegate.getCharsSequence();
  synchronized (myLock) {
    for (PsiLanguageInjectionHost.Shred shred : myShreds) {
      Segment hostRange = shred.getHostRangeMarker();
      if (hostRange != null) {
        text.append(shred.getPrefix());
        text.append(hostText, hostRange.getStartOffset(), hostRange.getEndOffset());
        text.append(shred.getSuffix());
      }
    }
  }
  return text.toString();
}
 
Example 14
Source Project: consulo   Source File: DocumentWindowImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean areRangesEqual(@Nonnull DocumentWindow other) {
  DocumentWindowImpl window = (DocumentWindowImpl)other;
  Place shreds = getShreds();
  Place otherShreds = window.getShreds();
  if (shreds.size() != otherShreds.size()) return false;
  for (int i = 0; i < shreds.size(); i++) {
    PsiLanguageInjectionHost.Shred shred = shreds.get(i);
    PsiLanguageInjectionHost.Shred otherShred = otherShreds.get(i);
    if (!shred.getPrefix().equals(otherShred.getPrefix())) return false;
    if (!shred.getSuffix().equals(otherShred.getSuffix())) return false;

    Segment hostRange = shred.getHostRangeMarker();
    Segment otherRange = otherShred.getHostRangeMarker();
    if (hostRange == null || otherRange == null || !TextRange.areSegmentsEqual(hostRange, otherRange)) return false;
  }
  return true;
}
 
Example 15
Source Project: consulo   Source File: DocumentWindowImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean isValid() {
  Place shreds;
  synchronized (myLock) {
    shreds = myShreds; // assumption: myShreds list is immutable
  }
  // can grab PsiLock in SmartPsiPointer.restore()
  // will check the 0th element manually (to avoid getting .getHost() twice)
  for (int i = 1; i < shreds.size(); i++) {
    PsiLanguageInjectionHost.Shred shred = shreds.get(i);
    if (!shred.isValid()) return false;
  }

  PsiLanguageInjectionHost.Shred firstShred = shreds.get(0);
  PsiLanguageInjectionHost host = firstShred.getHost();
  if (host == null || firstShred.getHostRangeMarker() == null) return false;
  VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(this);
  return virtualFile != null && ((PsiManagerEx)host.getManager()).getFileManager().findCachedViewProvider(virtualFile) != null;
}
 
Example 16
Source Project: reasonml-idea-plugin   Source File: PsiRawBody.java    License: MIT License 5 votes vote down vote up
@NotNull
@Override
public PsiLanguageInjectionHost updateText(@NotNull String text) {
    ASTNode valueNode = getNode().getFirstChildNode();
    assert valueNode instanceof LeafElement;

    ((LeafElement) valueNode).replaceWithText(text);
    return this;
}
 
Example 17
Source Project: reasonml-idea-plugin   Source File: PsiRawBody.java    License: MIT License 5 votes vote down vote up
@NotNull
@Override
public LiteralTextEscaper<? extends PsiLanguageInjectionHost> createLiteralTextEscaper() {
    return new JSStringLiteralEscaper<PsiLanguageInjectionHost>(this) {
        @Override
        protected boolean isRegExpLiteral() {
            return false;
        }
    };
}
 
Example 18
Source Project: reasonml-idea-plugin   Source File: JsInjector.java    License: MIT License 5 votes vote down vote up
public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost host,
                                 @NotNull InjectedLanguagePlaces injectionPlacesRegistrar) {
    if (host instanceof PsiRawBody) {
        FileType jsFileType = FileTypeManager.getInstance().getFileTypeByExtension("js");
        if (jsFileType instanceof LanguageFileType) {
            Language jsLanguage = ((LanguageFileType) jsFileType).getLanguage();
            PsiRawBody macroHost = (PsiRawBody) host;
            TextRange macroTextRange = macroHost.getMacroTextRange();
            injectionPlacesRegistrar.addPlace(jsLanguage, macroTextRange, null, null);
        }
    }
}
 
Example 19
Source Project: idea-php-typo3-plugin   Source File: FluidStringLiteralMixin.java    License: MIT License 5 votes vote down vote up
@Override
public PsiLanguageInjectionHost updateText(@NotNull String text) {
    ASTNode valueNode = getNode().getFirstChildNode();
    assert valueNode instanceof LeafElement;
    ((LeafElement) valueNode).replaceWithText(text);
    return this;
}
 
Example 20
Source Project: idea-php-typo3-plugin   Source File: FluidStringLiteralMixin.java    License: MIT License 5 votes vote down vote up
@NotNull
@Override
public LiteralTextEscaper<? extends PsiLanguageInjectionHost> createLiteralTextEscaper() {
    return new JSStringLiteralEscaper<PsiLanguageInjectionHost>(this) {
        @Override
        protected boolean isRegExpLiteral() {
            return false;
        }
    };
}
 
Example 21
private void registrarInjecting(Language language, MultiHostRegistrar registrar, List<PsiElement> els, String prefix, String suffix) {
    if (els.size() > 0) {
        registrar.startInjecting(language);
        els.forEach(el -> registrar.addPlace(prefix, suffix, (PsiLanguageInjectionHost) el, ElementManipulators.getValueTextRange(el)));
        registrar.doneInjecting();
    }
}
 
Example 22
Source Project: mule-intellij-plugins   Source File: MuleBreakpointType.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean canPutAt(@NotNull VirtualFile file, int line, @NotNull Project project)
{
    final Document document = FileDocumentManager.getInstance().getDocument(file);
    if (document != null)
    {
        final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document);
        if (psiFile != null)
        {
            final boolean isMuleAndXml = MuleConfigUtils.isMuleFile(psiFile);
            if (isMuleAndXml)
            {
                final XmlTag xmlTagAt = MuleConfigUtils.getXmlTagAt(project, XDebuggerUtil.getInstance().createPosition(file, line));
                if (xmlTagAt != null)
                {
                    return MuleConfigUtils.getMuleElementTypeFromXmlElement(xmlTagAt) == MuleElementType.MESSAGE_PROCESSOR;
                }
                else
                {
                    final PsiElement firstWeaveElement = WeavePsiUtils.getFirstWeaveElement(project, document, line);
                    if (firstWeaveElement != null)
                    {
                        PsiLanguageInjectionHost parent = PsiTreeUtil.getParentOfType(firstWeaveElement, PsiLanguageInjectionHost.class);
                        if (parent != null)
                        {
                            final PsiElement elementInInjected = InjectedLanguageUtil.findElementInInjected(parent, line);
                            final Language language = elementInInjected.getLanguage();
                            return language == WeaveLanguage.getInstance();
                        }
                    }
                }
            }
        }
    }
    return false;
}
 
Example 23
@Override
public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost host,
                                 @NotNull InjectedLanguagePlaces injectedLanguagePlaces) {
    if (MuleConfigUtils.isMuleFile(host.getContainingFile())) {
        if (host instanceof XmlAttributeValue) {
            // Try to inject a language, somewhat abusing the lazy evaluation of predicates :(
            for (Pair<String, String> language : languages) {
                if (tryInjectLanguage(language.getFirst(), language.getSecond(), host, injectedLanguagePlaces)) {
                    break;
                }
            }
        } else if (host instanceof XmlText) {
            final XmlTag tag = ((XmlText) host).getParentTag();
            if (tag != null) {
                final QName tagName = MuleConfigUtils.getQName(tag);
                if (tagName.equals(globalFunctions) || tagName.equals(expressionComponent) || tagName.equals(expressionTransformer)) {
                    final String scriptingName = MelLanguage.MEL_LANGUAGE_ID;
                    injectLanguage(host, injectedLanguagePlaces, scriptingName);
                } else if (tagName.equals(scriptingScript)) {
                    final String engine = tag.getAttributeValue("engine");
                    if (engine != null) {
                        injectLanguage(host, injectedLanguagePlaces, StringUtil.capitalize(engine));
                    }
                } else if (tagName.equals(dwSetPayload) || tagName.equals(dwSetProperty) || tagName.equals(dwSetVariable) || tagName.equals(dwSetSessionVar)) {
                    injectLanguage(host, injectedLanguagePlaces, WEAVE_LANGUAGE_ID);
                }
            }
        }
    }
}
 
Example 24
private void injectLanguage(@NotNull PsiLanguageInjectionHost host, @NotNull InjectedLanguagePlaces injectedLanguagePlaces, String scriptingName) {
    final Language requiredLanguage = Language.findLanguageByID(scriptingName);
    if (requiredLanguage != null) {
        final TextRange range = TextRange.from(0, host.getTextRange().getLength());
        injectedLanguagePlaces.addPlace(requiredLanguage, range, null, null);
    }
}
 
Example 25
private boolean tryInjectLanguage(@NotNull String langPrefix,
                                  @NotNull String languageId,
                                  @NotNull PsiLanguageInjectionHost host,
                                  @NotNull InjectedLanguagePlaces injectedLanguagePlaces) {
    if (isExpectedLocalName(langPrefix, host)) {
        injectLanguage(langPrefix, languageId, host, injectedLanguagePlaces);
        return true;
    }
    return false;
}
 
Example 26
private boolean isExpectedLocalName(@NotNull String langPrefix,
                                    @NotNull PsiLanguageInjectionHost psiLanguageInjectionHost) {

    final XmlAttributeValue attributeValue = (XmlAttributeValue) psiLanguageInjectionHost;
    final String expressionText = attributeValue.getValue();
    return expressionText.startsWith(getLanguagePrefix(langPrefix)) && expressionText.endsWith("]");
}
 
Example 27
private void injectLanguage(String langPrefix, @NotNull String languageId,
                            @NotNull PsiLanguageInjectionHost host,
                            @NotNull InjectedLanguagePlaces injectedLanguagePlaces) {
    // Find the required Language
    final Language requiredLanguage = Language.findLanguageByID(languageId);
    if (requiredLanguage == null) {
        return;
    }
    final TextRange textRange = ((XmlAttributeValue) host).getValueTextRange();
    final int length = getLanguagePrefix(langPrefix).length() + 1;
    final TextRange expressionTextRange = TextRange.from(length, textRange.getLength() - length);
    injectedLanguagePlaces.addPlace(requiredLanguage, expressionTextRange, null, null);
}
 
Example 28
@Override
public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost host, @NotNull InjectedLanguagePlaces injectionPlacesRegistrar) {
    for (BaseInjection injection : Configuration.getInstance().getInjections(FusionLanguageInjectionSupport.SUPPORT_ID)) {
        if (injection.acceptsPsiElement(host)) {
            Language language = InjectedLanguage.findLanguageById(injection.getInjectedLanguageId());
            if (language != null) {
                injectionPlacesRegistrar.addPlace(language, new TextRange(0, host.getTextLength()), "", "");
            }
        }
    }
}
 
Example 29
/**
 * Gets the values of other documentation tags that are immediate siblings
 *
 * @param comment the comment to use as a staring point
 */
public static List<String> getOtherDocTagValues(PsiComment comment) {


	final Project project = comment.getProject();
	final InjectedLanguageManager injectedLanguageManager = InjectedLanguageManager.getInstance(project);

	final List<PsiComment> siblings = Lists.newArrayList();
	getDocumentationCommentSiblings(comment, siblings, PsiElement::getPrevSibling);
	getDocumentationCommentSiblings(comment, siblings, PsiElement::getNextSibling);

	final List<String> values = Lists.newArrayList();

	for (PsiComment sibling : siblings) {
		if (sibling instanceof PsiLanguageInjectionHost) {
			List<Pair<PsiElement, TextRange>> injected = injectedLanguageManager.getInjectedPsiFiles(sibling);
			if (injected != null) {
				for (Pair<PsiElement, TextRange> pair : injected) {
					PsiFile injectedFile = pair.first.getContainingFile();
					final JSGraphQLEndpointDocTag tag = PsiTreeUtil.findChildOfType(injectedFile, JSGraphQLEndpointDocTag.class);
					if (tag != null && tag.getDocValue() != null) {
						values.add(tag.getDocValue().getText());
					}
				}
			}
		}
	}
	return values;
}
 
Example 30
@Override
public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost host, @NotNull InjectedLanguagePlaces injectionPlacesRegistrar) {
	if(ApplicationManager.getApplication().isUnitTestMode()) {
		// intellij unit test env doesn't properly support language injection in combination with formatter tests, so skip injection in that case
		return;
	}
	if (host instanceof PsiComment && host.getLanguage() == JSGraphQLEndpointLanguage.INSTANCE) {
		injectionPlacesRegistrar.addPlace(JSGraphQLEndpointDocLanguage.INSTANCE, TextRange.create(0, host.getTextLength()), "", "");
	}
}