mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-43053 Handle Complete Current Statement after a collection at the end of a file
It's weird, however, that Python implementation might query fixers for elements that are at completely different lines with the caret as in the originally reported case. This confusing and error-prone behavior needs to be revised separately. GitOrigin-RevId: 1f48fe0e0936fb2007022dfc889c44ad32e1eaf0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
62a91a1a1f
commit
13afc2cbfb
+3
-3
@@ -5,14 +5,12 @@ import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.jetbrains.python.PyPsiBundle;
|
||||
import com.jetbrains.python.codeInsight.editorActions.smartEnter.PySmartEnterProcessor;
|
||||
import com.jetbrains.python.codeInsight.editorActions.smartEnter.SmartEnterUtil;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.impl.PyPsiUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static com.jetbrains.python.psi.PyUtil.as;
|
||||
|
||||
@@ -30,7 +28,9 @@ public class PyCollectionLiteralFixer extends PyFixer<PySequenceExpression> {
|
||||
protected void doApply(@NotNull Editor editor, @NotNull PySmartEnterProcessor processor, @NotNull PySequenceExpression collection) {
|
||||
int caretOffset = editor.getCaretModel().getOffset();
|
||||
PsiElement collectionItemAnchor = collection.getContainingFile().findElementAt(caretOffset);
|
||||
assert collectionItemAnchor != null;
|
||||
if (collectionItemAnchor == null) {
|
||||
return;
|
||||
}
|
||||
if (collectionItemAnchor instanceof PsiWhiteSpace) {
|
||||
collectionItemAnchor = PyPsiUtils.getPrevNonWhitespaceSiblingOnSameLine(collectionItemAnchor);
|
||||
}
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
@(lambda: [lambda x: x][0])()
|
||||
def foo()<caret>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
@(lambda: [lambda x: x][0])()
|
||||
def foo():
|
||||
<caret>
|
||||
@@ -0,0 +1,3 @@
|
||||
xs = [
|
||||
|
||||
] <caret>
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
xs = [
|
||||
|
||||
]
|
||||
<caret>
|
||||
@@ -162,6 +162,11 @@ public class PySmartEnterTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-43053
|
||||
public void testMultilineListLiteralAfterClosingBracket() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-25001
|
||||
public void testMultilineSetLiteral() {
|
||||
doTest();
|
||||
@@ -207,6 +212,11 @@ public class PySmartEnterTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-43053
|
||||
public void testAfterFunctionDecoratedWithExpressionContainingCollectionLiteral() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testDocRest() {
|
||||
CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance();
|
||||
boolean oldStubOnEnter = codeInsightSettings.JAVADOC_STUB_ON_ENTER;
|
||||
|
||||
Reference in New Issue
Block a user