mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
[java-typing] Fix test and } handling in string templates (IDEA-333179)
GitOrigin-RevId: 318d7215f7aa80ec0bf7f2c4f3a2228856e23a1e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2ee3ec3072
commit
169a5849ac
@@ -17,6 +17,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.impl.source.BasicJavaAstTreeUtil;
|
||||
import com.intellij.psi.impl.source.BasicJavaElementType;
|
||||
import com.intellij.psi.tree.ParentAwareTokenSet;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
@@ -117,7 +118,7 @@ public abstract class AbstractBasicJavaTypedHandler extends TypedHandlerDelegate
|
||||
|
||||
HighlighterIterator iterator = editor.getHighlighter().createIterator(offset-1);
|
||||
CharSequence sequence = editor.getDocument().getCharsSequence();
|
||||
if (!iterator.atEnd() && iterator.getTokenType() == StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN &&
|
||||
if (!iterator.atEnd() && iterator.getTokenType() == JavaTokenType.STRING_TEMPLATE_BEGIN &&
|
||||
iterator.getEnd() == offset && sequence.subSequence(iterator.getStart(), iterator.getEnd()).toString().equals("\\{")) {
|
||||
if (sequence.length() > offset && sequence.charAt(offset) == '}') {
|
||||
editor.getCaretModel().moveToOffset(offset + 1);
|
||||
|
||||
@@ -121,18 +121,33 @@ public abstract class AbstractBasicJavaTypingTest extends BasePlatformTestCase {
|
||||
|
||||
public void testQuestionAfterPolyadicBoolean() { doTest('?'); }
|
||||
|
||||
public void testStartStringTemplate() { doTest('{'); }
|
||||
public void testStartStringTemplate() {
|
||||
setLanguageLevel(LanguageLevel.JDK_21_PREVIEW);
|
||||
doTest('{');
|
||||
}
|
||||
|
||||
public void testStartStringTemplateEof() { doTest('{'); }
|
||||
public void testStartStringTemplateEof() {
|
||||
setLanguageLevel(LanguageLevel.JDK_21_PREVIEW);
|
||||
doTest('{');
|
||||
}
|
||||
|
||||
public void testStartStringTemplateNoClosingQuote() { doTest('{'); }
|
||||
public void testStartStringTemplateNoClosingQuote() {
|
||||
setLanguageLevel(LanguageLevel.JDK_21_PREVIEW);
|
||||
doTest('{');
|
||||
}
|
||||
|
||||
public void testStartStringTemplateTextBlock() { doTest('{'); }
|
||||
public void testStartStringTemplateTextBlock() {
|
||||
setLanguageLevel(LanguageLevel.JDK_21_PREVIEW);
|
||||
doTest('{');
|
||||
}
|
||||
|
||||
public void testStartStringTemplateAlreadyBrace() { doTest('{'); }
|
||||
public void testStartStringTemplateAlreadyBrace() {
|
||||
setLanguageLevel(LanguageLevel.JDK_21_PREVIEW);
|
||||
doTest('{');
|
||||
}
|
||||
|
||||
public void testEndStringTemplate() {
|
||||
setLanguageLevel(LanguageLevel.JDK_21);
|
||||
setLanguageLevel(LanguageLevel.JDK_21_PREVIEW);
|
||||
doTest('}');
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ public class JavaCodeInsightSanityTest extends LightJavaCodeInsightFixtureTestCa
|
||||
new StripTestDataMarkup(file),
|
||||
new DeleteRange(file),
|
||||
new IntroduceVariableActionOnFile(file));
|
||||
PropertyChecker
|
||||
PropertyChecker.customized().rechecking("7++TxBXxwu2eFS3LBTwU6QUDAwQEAAEB4BAU2xEcBwQAAwIEXGsABAFzAgADEQ4BCwAMAeIDAA==")
|
||||
.checkScenarios(actionsOnJavaFiles(fileActions));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user