mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-17979 Reverted controversial fix for the PY-13304
Continuation indent is used for function arguments only to avoid structure ambiguity.
This commit is contained in:
@@ -323,8 +323,13 @@ public class PyBlock implements ASTBlock {
|
||||
if (childType == PyTokenTypes.RPAR) {
|
||||
childIndent = Indent.getNoneIndent();
|
||||
}
|
||||
else if (childType != PyTokenTypes.LPAR){
|
||||
childIndent = Indent.getContinuationIndent();
|
||||
else {
|
||||
if (parentType == PyElementTypes.PARAMETER_LIST || argumentMayHaveSameIndentAsFollowingStatementList()) {
|
||||
childIndent = Indent.getContinuationIndent();
|
||||
}
|
||||
else {
|
||||
childIndent = Indent.getNormalIndent();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (parentType == PyElementTypes.SUBSCRIPTION_EXPRESSION) {
|
||||
@@ -421,6 +426,19 @@ public class PyBlock implements ASTBlock {
|
||||
return node.getPsi() instanceof PySequenceExpression && ((PySequenceExpression)node.getPsi()).isEmpty();
|
||||
}
|
||||
|
||||
private boolean argumentMayHaveSameIndentAsFollowingStatementList() {
|
||||
if (myNode.getElementType() != PyElementTypes.ARGUMENT_LIST) {
|
||||
return false;
|
||||
}
|
||||
// This check is supposed to prevent PEP8's error: Continuation line with the same indent as next logical line
|
||||
final PsiElement header = getControlStatementHeader(myNode);
|
||||
if (header instanceof PyStatementListContainer) {
|
||||
final PyStatementList statementList = ((PyStatementListContainer)header).getStatementList();
|
||||
return PyUtil.onSameLine(header, myNode.getPsi()) && !PyUtil.onSameLine(header, statementList);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check https://www.python.org/dev/peps/pep-0008/#indentation
|
||||
private static boolean hasHangingIndent(@NotNull PsiElement elem) {
|
||||
if (elem instanceof PyCallExpression) {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
with raises_assertion(
|
||||
has_string('Missing download_urls: {}, {}'.format(
|
||||
self.other_download_url, self.another_download_url))):
|
||||
self.other_download_url, self.another_download_url))):
|
||||
fixture.assert_detail_page_yields_expected()
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
funcWithLongName(x=[
|
||||
],
|
||||
y=42)
|
||||
y=42)
|
||||
|
||||
@@ -2,4 +2,4 @@ def long_method_name(bar, baz): pass
|
||||
|
||||
|
||||
long_method_name("long string one",
|
||||
"long string two")
|
||||
"long string two")
|
||||
|
||||
@@ -4,4 +4,4 @@ def foo():
|
||||
if comments:
|
||||
for comment in comments:
|
||||
record += ' <comment ' + "".join(
|
||||
ca + '=' + quoteattr(comment[ca]) + ' ' for ca in comment) + '/>\n'
|
||||
ca + '=' + quoteattr(comment[ca]) + ' ' for ca in comment) + '/>\n'
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
self.assertEqual(
|
||||
{"000000000000", "111111111111"},
|
||||
foo['bar']['baz'])
|
||||
{"000000000000", "111111111111"},
|
||||
foo['bar']['baz'])
|
||||
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
import subprocess as sp
|
||||
|
||||
a = sp.check_output(
|
||||
args=['python', '-c', 'print("Spam")'],
|
||||
# read errors too
|
||||
stderr=sp.STDOUT
|
||||
args=['python', '-c', 'print("Spam")'],
|
||||
# read errors too
|
||||
stderr=sp.STDOUT
|
||||
)
|
||||
print(a)
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.jetbrains.python;
|
||||
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.jetbrains.python.fixtures.PyTestCase;
|
||||
|
||||
@@ -199,7 +200,7 @@ public class PyIndentTest extends PyTestCase {
|
||||
public void testEnterInNonEmptyArgList() { // PY-1947
|
||||
doTest("Task(<caret>params=1)",
|
||||
"Task(\n" +
|
||||
" <caret>params=1)");
|
||||
" <caret>params=1)");
|
||||
}
|
||||
|
||||
public void testEnterInNonClosedArgList() { // PY-4863
|
||||
|
||||
Reference in New Issue
Block a user