use of com.goide.psi.GoStringLiteral in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoStringLiteralEscaperTest method testEscaperOffsetInStringHost.
public void testEscaperOffsetInStringHost() {
GoStringLiteral expr = createStringFromText("\\nfoo");
assertNotNull(expr);
LiteralTextEscaper<? extends PsiLanguageInjectionHost> escaper = expr.createLiteralTextEscaper();
TextRange newLineFoo = TextRange.create(1, 6);
escaper.decode(newLineFoo, new StringBuilder());
assertEquals(1, escaper.getOffsetInHost(0, newLineFoo));
assertEquals(3, escaper.getOffsetInHost(1, newLineFoo));
assertEquals(4, escaper.getOffsetInHost(2, newLineFoo));
assertEquals(5, escaper.getOffsetInHost(3, newLineFoo));
assertEquals(6, escaper.getOffsetInHost(4, newLineFoo));
assertEquals(-1, escaper.getOffsetInHost(5, newLineFoo));
}
use of com.goide.psi.GoStringLiteral in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoStringLiteralEscaperTest method testEscaperOffsetInRawStringHost.
public void testEscaperOffsetInRawStringHost() {
GoStringLiteral expr = createRawStringFromText("\nfoo");
assertNotNull(expr);
LiteralTextEscaper<? extends PsiLanguageInjectionHost> escaper = expr.createLiteralTextEscaper();
TextRange newLineFoo = TextRange.create(1, 5);
escaper.decode(newLineFoo, new StringBuilder());
assertEquals(1, escaper.getOffsetInHost(0, newLineFoo));
assertEquals(2, escaper.getOffsetInHost(1, newLineFoo));
assertEquals(3, escaper.getOffsetInHost(2, newLineFoo));
assertEquals(4, escaper.getOffsetInHost(3, newLineFoo));
assertEquals(5, escaper.getOffsetInHost(4, newLineFoo));
assertEquals(-1, escaper.getOffsetInHost(5, newLineFoo));
}
use of com.goide.psi.GoStringLiteral in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoStringLiteralEscaperTest method testDecodeEscapedBellString.
public void testDecodeEscapedBellString() {
GoStringLiteral expr = createStringFromText("\\a");
assertNotNull(expr);
String a = decodeRange(expr, TextRange.create(1, 3));
assertEquals("\007", a);
}
use of com.goide.psi.GoStringLiteral in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoStringLiteralEscaperTest method testEscaperOffsetInRawStringHostSubString.
public void testEscaperOffsetInRawStringHostSubString() {
GoStringLiteral expr = createRawStringFromText("\nfoo");
assertNotNull(expr);
LiteralTextEscaper<? extends PsiLanguageInjectionHost> escaper = expr.createLiteralTextEscaper();
TextRange fooOnly = TextRange.create(2, 5);
escaper.decode(fooOnly, new StringBuilder());
assertEquals(2, escaper.getOffsetInHost(0, fooOnly));
assertEquals(3, escaper.getOffsetInHost(1, fooOnly));
assertEquals(4, escaper.getOffsetInHost(2, fooOnly));
assertEquals(5, escaper.getOffsetInHost(3, fooOnly));
assertEquals(-1, escaper.getOffsetInHost(4, fooOnly));
}
use of com.goide.psi.GoStringLiteral in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoStringLiteralEscaperTest method testQuote.
public void testQuote() {
PlatformTestUtil.withEncoding(CharsetToolkit.UTF8, () -> {
GoStringLiteral expr = createStringFromText("import \\\"fmt\\\"");
assertNotNull(expr);
assertEquals("\"fmt\"", decodeRange(expr, TextRange.create(8, 15)));
});
}
Aggregations