mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] fixes automatic closing of a not-alone text block (IDEA-217252)
GitOrigin-RevId: cb9a0e482384295d8708faa680deed5ea3a7aeb8
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1f7b3cce9c
commit
37b1c312fc
@@ -1,8 +1,10 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.codeInsight.editorActions;
|
||||
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.highlighter.HighlighterIterator;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
@@ -106,6 +108,17 @@ public class JavaQuoteHandler extends SimpleTokenSetQuoteHandler implements Java
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNonClosedLiteral(Editor editor, HighlighterIterator iterator, int offset) {
|
||||
if (iterator.getTokenType() == JavaTokenType.TEXT_BLOCK_LITERAL) {
|
||||
Document document = iterator.getDocument();
|
||||
if (document != null && StringUtil.equals(document.getCharsSequence().subSequence(iterator.getStart(), offset + 1), "\"\"\"")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.hasNonClosedLiteral(editor, iterator, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertClosingQuote(@NotNull Editor editor, int offset, @NotNull CharSequence closingQuote) {
|
||||
if (closingQuote.charAt(0) == '`') {
|
||||
|
||||
+1
@@ -30,6 +30,7 @@ class JavaQuoteTest extends LightJavaCodeInsightFixtureTestCase {
|
||||
doTest ' """."<caret>"" ', ' """.""<caret>" '
|
||||
doTest ' """.""<caret>" ', ' """."""<caret> '
|
||||
}
|
||||
void testPrecedingTextBlock() { doTest 'f(""<caret> + """\n .""")', 'f("""\n<caret>""" + """\n .""")' }
|
||||
|
||||
private void doTest(String before, String after, char c = '"') {
|
||||
myFixture.configureByText("a.java", "class C {{\n ${before}\n}}")
|
||||
|
||||
Reference in New Issue
Block a user