mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
[java-typing] IDEA-333031 Auto-multilining for String doesn't work if there is a string template in the code
GitOrigin-RevId: 86ca76290687aeb3c0023c745069dfd897145af6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8bab980bbd
commit
7014be59fd
@@ -102,12 +102,13 @@ public class JavaQuoteHandler extends SimpleTokenSetQuoteHandler implements Java
|
||||
@Nullable
|
||||
@Override
|
||||
public CharSequence getClosingQuote(@NotNull HighlighterIterator iterator, int offset) {
|
||||
return iterator.getTokenType() == JavaTokenType.TEXT_BLOCK_LITERAL && offset == iterator.getStart() + 3 ? "\"\"\"" : null;
|
||||
return (iterator.getTokenType() == JavaTokenType.TEXT_BLOCK_LITERAL || iterator.getTokenType() == JavaTokenType.TEXT_BLOCK_TEMPLATE_BEGIN)
|
||||
&& offset == iterator.getStart() + 3 ? "\"\"\"" : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNonClosedLiteral(Editor editor, HighlighterIterator iterator, int offset) {
|
||||
if (iterator.getTokenType() == JavaTokenType.TEXT_BLOCK_LITERAL) {
|
||||
if (iterator.getTokenType() == JavaTokenType.TEXT_BLOCK_LITERAL || iterator.getTokenType() == JavaTokenType.TEXT_BLOCK_TEMPLATE_BEGIN) {
|
||||
Document document = editor.getDocument();
|
||||
Project project = editor.getProject();
|
||||
PsiFile file = project == null ? null : PsiDocumentManager.getInstance(project).getPsiFile(document);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.intellij.java.codeInsight.editorActions;
|
||||
|
||||
import com.intellij.codeInsight.AbstractBasicJavaQuoteTest;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
|
||||
public class JavaQuoteTest extends AbstractBasicJavaQuoteTest {
|
||||
//requires formatter
|
||||
@@ -11,6 +13,25 @@ public class JavaQuoteTest extends AbstractBasicJavaQuoteTest {
|
||||
doTest("f(\"\"<caret> + \"\"\"\n .\"\"\")", "f(\"\"\"\n <caret>\"\"\" + \"\"\"\n .\"\"\")");
|
||||
}
|
||||
|
||||
//requires formatter
|
||||
public void testTextBlockBeforeTemplate() {
|
||||
IdeaTestUtil.withLevel(getModule(), LanguageLevel.JDK_21_PREVIEW, () -> {
|
||||
doTest("""
|
||||
Integer i = 5;
|
||||
|
||||
String s1 = ""<caret>
|
||||
|
||||
String s = STR."\\{i}";""",
|
||||
"""
|
||||
Integer i = 5;
|
||||
|
||||
String s1 = ""\"
|
||||
""\"
|
||||
|
||||
String s = STR."\\{i}";""");
|
||||
});
|
||||
}
|
||||
|
||||
//basic highlighter doesn't support document data out-of-box
|
||||
public void testJavadocSnippetAttributeDouble() {
|
||||
doFileTest("/**\n* {@snippet <caret> :}\n*/\nclass A {\n}", "/**\n* {@snippet \"<caret>\" :}\n*/\nclass A {\n}");
|
||||
|
||||
Reference in New Issue
Block a user