- All Superinterfaces:
PsiElement,PsiExternalReferenceHost
Marks PSI element as (potentially) containing text in another language.
Injected language PSI does not embed into the PSI tree of the hosting element,
but is used by the IDE for highlighting, completion and other code insight actions.
In order to do the injection, you have to
- Implement
com.intellij.psi.LanguageInjectorto describe exact place where injection should occur. - Register injection in
com.intellij.psi.LanguageInjector#EXTENSION_POINT_NAMEextension point.
You don't have to implement PsiLanguageInjectionHost by yourself, unless you want to inject something into your own custom PSI.
For all returned injected PSI elements, InjectedLanguageManager#getInjectionHost(PsiElement) returns PsiLanguageInjectionHost they were injected into.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacestatic interface -
Field Summary
Fields inherited from interface com.intellij.psi.PsiElement
EMPTY_ARRAY -
Method Summary
Modifier and TypeMethodDescription@NotNull LiteralTextEscaper<? extends PsiLanguageInjectionHost>booleanupdateText(@NotNull String text) Update the host element using the provided text of the injected file.Methods inherited from interface com.intellij.psi.PsiElement
add, addAfter, addBefore, addRange, addRangeAfter, addRangeBefore, checkAdd, checkDelete, copy, delete, deleteChildRange, findElementAt, findReferenceAt, getChildren, getContainingFile, getContext, getFirstChild, getLanguage, getLastChild, getNavigationElement, getNextSibling, getNode, getOriginalElement, getParent, getPrevSibling, getReference, getStartOffsetInParent, getText, getTextLength, getTextOffset, getTextRange, isEquivalentTo, isPhysical, isValid, isWritable, replace, textContains, textMatches, textMatches, textToCharArray, toString
-
Method Details
-
isValidHost
boolean isValidHost()- Returns:
trueif this instance can accept injections,falseotherwise
-
updateText
Update the host element using the provided text of the injected file. It may be required to escape characters fromtextin accordance with the host language syntax. The implementation may delegate toElementManipulators#handleContentChange(PsiElement, String)ifElementManipulatorimplementation is registered for this element class.- Parameters:
text- text of the injected file- Returns:
- the updated instance
-
createLiteralTextEscaper
- Returns:
LiteralTextEscaperinstance which will be used to convert the content of this host element to the content of injected file
-