mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
PY-75714 Fold single line match case clauses
Merge-request: IJ-MR-144163 Merged-by: Pavel Karateev <Pavel.Karateev@jetbrains.com> GitOrigin-RevId: 352d1111988371b6edd9fa1af71b345dbb7aee38
This commit is contained in:
committed by
intellij-monorepo-bot
parent
06a6f45bbe
commit
85c6eee402
@@ -176,14 +176,12 @@ public class PythonFoldingBuilder extends CustomFoldingBuilder implements DumbAw
|
||||
}
|
||||
|
||||
private static boolean checkFoldBlocks(@NotNull ASTNode statementList, @NotNull IElementType parentType) {
|
||||
if (!PyElementTypes.PARTS.contains(parentType) && parentType != PyElementTypes.WITH_STATEMENT && parentType != PyElementTypes.CASE_CLAUSE) {
|
||||
return false;
|
||||
}
|
||||
PsiElement element = statementList.getPsi();
|
||||
if (element instanceof PyStatementList) {
|
||||
return StringUtil.countNewLines(element.getText()) > 0;
|
||||
}
|
||||
return false;
|
||||
assert element instanceof PyStatementList;
|
||||
|
||||
return PyElementTypes.PARTS.contains(parentType) ||
|
||||
parentType == PyElementTypes.WITH_STATEMENT ||
|
||||
parentType == PyElementTypes.CASE_CLAUSE;
|
||||
}
|
||||
|
||||
private static void foldLongStrings(ASTNode node, List<FoldingDescriptor> descriptors) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
if True:
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
if True:<fold text='...'>
|
||||
pass</fold>
|
||||
else:<fold text='...'>
|
||||
pass</fold>
|
||||
|
||||
if True:<fold text='...'>
|
||||
pass
|
||||
@@ -15,8 +15,8 @@ else:<fold text='...'>
|
||||
|
||||
|
||||
x = []
|
||||
for i in x:
|
||||
pass
|
||||
for i in x:<fold text='...'>
|
||||
pass</fold>
|
||||
|
||||
for i in x:<fold text='...'>
|
||||
pass
|
||||
@@ -39,8 +39,8 @@ except ValueError:<fold text='...'>
|
||||
print('')
|
||||
print('')
|
||||
print('')</fold>
|
||||
except Exception:
|
||||
print('')
|
||||
except Exception:<fold text='...'>
|
||||
print('')</fold>
|
||||
else:<fold text='...'>
|
||||
print('')
|
||||
print('')
|
||||
|
||||
@@ -3,8 +3,8 @@ def f(data):<fold text='...'>
|
||||
case 1:<fold text='...'>
|
||||
pass
|
||||
pass</fold>
|
||||
case 2:
|
||||
pass
|
||||
case 2:<fold text='...'>
|
||||
pass</fold>
|
||||
case 3:<fold text='...'>
|
||||
pass
|
||||
pass</fold></fold></fold>
|
||||
@@ -15,5 +15,5 @@ match p:<fold text='...'>
|
||||
case 0:<fold text='...'>
|
||||
pass
|
||||
pass</fold>
|
||||
case 1:
|
||||
pass</fold>
|
||||
case 1:<fold text='...'>
|
||||
pass</fold></fold>
|
||||
|
||||
Reference in New Issue
Block a user