Search in sources :

Example 16 with GoStringLiteral

use of com.goide.psi.GoStringLiteral in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoStringLiteralEscaperTest method testEscaperOffsetInSingleEscapedCharString.

public void testEscaperOffsetInSingleEscapedCharString() {
    GoStringLiteral expr = createStringFromText("\\n");
    assertNotNull(expr);
    LiteralTextEscaper<? extends PsiLanguageInjectionHost> escaper = expr.createLiteralTextEscaper();
    TextRange range = TextRange.create(1, 3);
    escaper.decode(range, new StringBuilder());
    assertEquals(1, escaper.getOffsetInHost(0, range));
    assertEquals(3, escaper.getOffsetInHost(1, range));
    assertEquals(-1, escaper.getOffsetInHost(2, range));
}
Also used : GoStringLiteral(com.goide.psi.GoStringLiteral) TextRange(com.intellij.openapi.util.TextRange)

Aggregations

GoStringLiteral (com.goide.psi.GoStringLiteral)16 TextRange (com.intellij.openapi.util.TextRange)5 GoConditionalExpr (com.goide.psi.GoConditionalExpr)1 PsiElement (com.intellij.psi.PsiElement)1