[java] text blocks: skipping opening whitespaces (IDEA-215312)

GitOrigin-RevId: 8561a8ac4a415146a8e971937a99a9900df41401
This commit is contained in:
Roman Shevchenko
2019-06-11 17:38:49 +03:00
committed by intellij-monorepo-bot
parent 29ae5908d7
commit ab07305151
2 changed files with 9 additions and 4 deletions
@@ -1146,15 +1146,15 @@ public class HighlightUtil extends HighlightUtilBase {
}
else if (type == JavaTokenType.TEXT_BLOCK_LITERAL) {
if (value == null) {
if (text.charAt(3) != '\n') {
String message = JavaErrorMessages.message("text.block.new.line");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
if (!text.endsWith("\"\"\"")) {
String message = JavaErrorMessages.message("text.block.unclosed");
int p = expression.getTextRange().getEndOffset();
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(p, p).endOfLine().descriptionAndTooltip(message).create();
}
else {
String message = JavaErrorMessages.message("text.block.new.line");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
}
}
@@ -11,6 +11,11 @@ class LightJava13HighlightingTest : LightCodeInsightFixtureTestCase() {
fun testTextBlocks() = doTest()
fun testUnclosedTextBlock() = doTest()
fun testTextBlockOpeningSpaces() {
myFixture.configureByText(getTestName(false) + ".java", "class C {\n String spaces = \"\"\" \t \u000C \n \"\"\";\n}")
myFixture.checkHighlighting()
}
private fun doTest() {
myFixture.configureByFile(getTestName(false) + ".java")
myFixture.checkHighlighting()