mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Hanging indent detection takes into account named parameters and default values of arguments
This commit is contained in:
@@ -398,7 +398,16 @@ public class PyBlock implements ASTBlock {
|
||||
return !PyTokenTypes.CLOSE_BRACES.contains(elem.getLastChild().getNode().getElementType());
|
||||
}
|
||||
else {
|
||||
return hasHangingIndent(items[0]);
|
||||
final PsiElement firstItem = items[0];
|
||||
if (firstItem instanceof PyNamedParameter) {
|
||||
final PyExpression defaultValue = ((PyNamedParameter)firstItem).getDefaultValue();
|
||||
return defaultValue != null && hasHangingIndent(defaultValue);
|
||||
}
|
||||
else if (firstItem instanceof PyKeywordArgument) {
|
||||
final PyExpression valueExpression = ((PyKeywordArgument)firstItem).getValueExpression();
|
||||
return valueExpression != null && hasHangingIndent(valueExpression);
|
||||
}
|
||||
return hasHangingIndent(firstItem);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
funcWithLongName(x=[
|
||||
],
|
||||
y=42)
|
||||
@@ -0,0 +1,3 @@
|
||||
funcWithLongName(x=[
|
||||
],
|
||||
y=42)
|
||||
@@ -0,0 +1,5 @@
|
||||
def funcWithLongName(x=[
|
||||
|
||||
],
|
||||
y=42):
|
||||
pass
|
||||
@@ -0,0 +1,5 @@
|
||||
def funcWithLongName(x=[
|
||||
|
||||
],
|
||||
y=42):
|
||||
pass
|
||||
@@ -546,6 +546,14 @@ public class PyFormatterTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testHangingIndentInNamedArgumentValue() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testHangingIndentInParameterDefaultValue() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private CommonCodeStyleSettings getCommonSettings() {
|
||||
return settings().getCommonSettings(PythonLanguage.getInstance());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user