public abstract class LiteralTextEscaper<T extends PsiLanguageInjectionHost>
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
protected |
LiteralTextEscaper(T host) |
Modifier and Type | Method and Description |
---|---|
static <T extends PsiLanguageInjectionHost> |
createSimple(T element) |
abstract boolean |
decode(TextRange rangeInsideHost,
java.lang.StringBuilder outChars)
Add decoded and unescaped characters from the host element to
outChars buffer. |
abstract int |
getOffsetInHost(int offsetInDecoded,
TextRange rangeInsideHost)
This method is called only after
decode(com.intellij.openapi.util.TextRange, java.lang.StringBuilder) , so it's possible to prepare necessary data in decode(com.intellij.openapi.util.TextRange, java.lang.StringBuilder) and then use it here. |
TextRange |
getRelevantTextRange() |
abstract boolean |
isOneLine() |
protected final T extends PsiLanguageInjectionHost myHost
protected LiteralTextEscaper(T host)
public abstract boolean decode(TextRange rangeInsideHost, java.lang.StringBuilder outChars)
outChars
buffer. 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 return false
rangeInsideHost
- range to be decoded. It's guarantied to be inside getRelevantTextRange()
outChars
- buffer for output chars. Use append
methods only, it's forbidden to modify or remove existing characterstrue
if whole range was successfully decoded, false
otherwisepublic abstract int getOffsetInHost(int offsetInDecoded, TextRange rangeInsideHost)
decode(com.intellij.openapi.util.TextRange, java.lang.StringBuilder)
, so it's possible to prepare necessary data in decode(com.intellij.openapi.util.TextRange, java.lang.StringBuilder)
and then use it here.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)public TextRange getRelevantTextRange()
public abstract boolean isOneLine()
true
if the host cannot accept multiline content, false
otherwisepublic static <T extends PsiLanguageInjectionHost> LiteralTextEscaper<T> createSimple(T element)