Module aya.ij.parsing.core
Package com.intellij.psi
Class LiteralTextEscaper<T extends PsiLanguageInjectionHost>
java.lang.Object
com.intellij.psi.LiteralTextEscaper<T>
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends PsiLanguageInjectionHost>
@NotNull LiteralTextEscaper<T>createSimple(T element) abstract booleandecode(@NotNull com.intellij.openapi.util.TextRange rangeInsideHost, @NotNull StringBuilder outChars) Add decoded and unescaped characters from the host element tooutCharsbuffer.abstract intgetOffsetInHost(int offsetInDecoded, @NotNull com.intellij.openapi.util.TextRange rangeInsideHost) This method is called only afterdecode(com.intellij.openapi.util.TextRange, java.lang.StringBuilder), so it's possible to prepare necessary data indecode(com.intellij.openapi.util.TextRange, java.lang.StringBuilder)and then use it here.@NotNull com.intellij.openapi.util.TextRangeabstract boolean
-
Field Details
-
myHost
-
-
Constructor Details
-
LiteralTextEscaper
-
-
Method Details
-
decode
public abstract boolean decode(@NotNull @NotNull com.intellij.openapi.util.TextRange rangeInsideHost, @NotNull @NotNull StringBuilder outChars) Add decoded and unescaped characters from the host element tooutCharsbuffer. If it's impossible to properly decode some chars from the specified range (e.g. if the range starts or ends inside escaped sequence), decode the longest acceptable prefix of the range and returnfalse- Parameters:
rangeInsideHost- range to be decoded. It's guarantied to be insidegetRelevantTextRange()outChars- buffer for output chars. Useappendmethods only, it's forbidden to modify or remove existing characters- Returns:
trueif whole range was successfully decoded,falseotherwise
-
getOffsetInHost
public abstract int getOffsetInHost(int offsetInDecoded, @NotNull @NotNull com.intellij.openapi.util.TextRange rangeInsideHost) This method is called only afterdecode(com.intellij.openapi.util.TextRange, java.lang.StringBuilder), so it's possible to prepare necessary data indecode(com.intellij.openapi.util.TextRange, java.lang.StringBuilder)and then use it here.- Parameters:
offsetInDecoded- offset in the parsed injected filerangeInsideHost- range where injection is performed, E.g. if some language fragment xyz was injected into string literal expression "xyz", then rangeInsideHost = (1,4)- Returns:
- offset in the host PSI element, or -1 if offset is out of host range.
E.g. if some language fragment xyz was injected into string literal expression "xyz", then
getOffsetInHost(0)==1 (there is an 'x' at offset 0 in the injected fragment,
and that 'x' occurs in "xyz" string literal at offset 1
since string literal expression "xyz" starts with double quote)
getOffsetInHost(1)==2
getOffsetInHost(2)==3
getOffsetInHost(3)==-1 (out of range)
Similarly, for some language fragment xyz being injected into xml text inside xml tag 'tag':
xyz getOffsetInHost(0)==0 (there is an 'x' at offset 0 in injected fragment, and that 'x' occurs in xyz xml text at offset 0) getOffsetInHost(1)==1 getOffsetInHost(2)==2 getOffsetInHost(3)==-1 (out of range)
-
getRelevantTextRange
@NotNull public @NotNull com.intellij.openapi.util.TextRange getRelevantTextRange()- Returns:
- range inside the host where injection can be performed; usually it's range of text without boundary quotes
-
isOneLine
public abstract boolean isOneLine()- Returns:
trueif the host cannot accept multiline content,falseotherwise
-
createSimple
@NotNull public static <T extends PsiLanguageInjectionHost> @NotNull LiteralTextEscaper<T> createSimple(@NotNull T element)
-