mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-18486 Don't auto close quotes that start docstring, so PythonEnterHandler could complete it
This commit is contained in:
@@ -22,6 +22,7 @@ import com.intellij.openapi.editor.highlighter.HighlighterIterator;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.jetbrains.python.PyTokenTypes;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -34,7 +35,7 @@ public class BaseQuoteHandler extends SimpleTokenSetQuoteHandler implements Mult
|
||||
private final char[] ourAutoClosingChars; // we add auto-close quotes before these
|
||||
|
||||
public BaseQuoteHandler(TokenSet tokenSet, char[] autoClosingChars) {
|
||||
super(tokenSet);
|
||||
super(TokenSet.andNot(tokenSet, TokenSet.create(PyTokenTypes.DOCSTRING)));
|
||||
ourAutoClosingChars = autoClosingChars;
|
||||
Arrays.sort(ourAutoClosingChars);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
def f(x):
|
||||
"""
|
||||
|
||||
:param x:
|
||||
:return:
|
||||
"""
|
||||
return 42
|
||||
@@ -0,0 +1,3 @@
|
||||
def f(x):
|
||||
<caret>
|
||||
return 42
|
||||
@@ -44,7 +44,7 @@ public class PyEditingTest extends PyTestCase {
|
||||
}
|
||||
|
||||
public void testPairedQuotesInRawString() { // PY-263
|
||||
assertEquals("r''", doTestTyping("r", 1, '\''));
|
||||
assertEquals("x = r''", doTestTyping("x = r", 5, '\''));
|
||||
}
|
||||
|
||||
public void testQuotesInString() { // PY-5041
|
||||
@@ -60,23 +60,23 @@ public class PyEditingTest extends PyTestCase {
|
||||
}
|
||||
|
||||
public void testAutoClosingQuoteAtRBracket() {
|
||||
assertEquals("'']", doTestTyping("]", 0, '\''));
|
||||
assertEquals("x = '']", doTestTyping("x = ]", 4, '\''));
|
||||
}
|
||||
|
||||
public void testAutoClosingQuoteAtRParen() {
|
||||
assertEquals("'')", doTestTyping(")", 0, '\''));
|
||||
assertEquals("x = '')", doTestTyping("x = )", 4, '\''));
|
||||
}
|
||||
|
||||
public void testAutoClosingQuoteAtComma() {
|
||||
assertEquals("'',", doTestTyping(",", 0, '\''));
|
||||
assertEquals("x = '',", doTestTyping("x = ,", 4, '\''));
|
||||
}
|
||||
|
||||
public void testAutoClosingQuoteAtSpace() {
|
||||
assertEquals("'' ", doTestTyping(" ", 0, '\''));
|
||||
assertEquals("x = '' ", doTestTyping("x = ", 4, '\''));
|
||||
}
|
||||
|
||||
public void testAutoCloseTriple() {
|
||||
assertEquals("''''''", doTestTyping("''", 2, '\''));
|
||||
assertEquals("x = ''''''", doTestTyping("x = ''", 6, '\''));
|
||||
}
|
||||
|
||||
public void testAutoRemoveTriple() {
|
||||
@@ -84,7 +84,7 @@ public class PyEditingTest extends PyTestCase {
|
||||
}
|
||||
|
||||
public void testOvertypeFromInside() {
|
||||
assertEquals("''", doTestTyping("''", 1, '\''));
|
||||
assertEquals("x = ''", doTestTyping("x = ''", 5, '\''));
|
||||
}
|
||||
|
||||
public void testGreedyBackspace() { // PY-254
|
||||
@@ -213,6 +213,11 @@ public class PyEditingTest extends PyTestCase {
|
||||
});
|
||||
}
|
||||
|
||||
// PY-18486
|
||||
public void testTripleQuotesThenEnterInsertsDocstring() {
|
||||
doDocStringTypingTest("\"\"\"\n", DocStringFormat.REST);
|
||||
}
|
||||
|
||||
public void testEnterDocStringStubInClass() {
|
||||
doDocStringTypingTest("\n", DocStringFormat.REST);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user