mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
DS-1584 DS-2583 Reformat breaks IPython magic commands and shell commands
GitOrigin-RevId: 949528c951d6c9174b1bad21452a90fbdb07b418
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6acb447706
commit
6df5bfd10d
@@ -485,7 +485,11 @@ public abstract class PythonCommonFormatterTest extends PythonCommonTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void doTest(final boolean reformatText) {
|
private void doTest(final boolean reformatText) {
|
||||||
myFixture.configureByFile("formatter/" + getTestName(true) + ".py");
|
doTest(reformatText, "formatter/", ".py");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doTest(final boolean reformatText, final String filePath, final String fileExtension) {
|
||||||
|
myFixture.configureByFile(filePath + getTestName(true) + fileExtension);
|
||||||
WriteCommandAction.runWriteCommandAction(null, () -> {
|
WriteCommandAction.runWriteCommandAction(null, () -> {
|
||||||
CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(myFixture.getProject());
|
CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(myFixture.getProject());
|
||||||
PsiFile file = myFixture.getFile();
|
PsiFile file = myFixture.getFile();
|
||||||
@@ -496,7 +500,7 @@ public abstract class PythonCommonFormatterTest extends PythonCommonTestCase {
|
|||||||
codeStyleManager.reformat(file);
|
codeStyleManager.reformat(file);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
myFixture.checkResultByFile("formatter/" + getTestName(true) + "_after.py");
|
myFixture.checkResultByFile(filePath + getTestName(true) + "_after" + fileExtension);
|
||||||
}
|
}
|
||||||
|
|
||||||
// PY-12861
|
// PY-12861
|
||||||
@@ -588,6 +592,14 @@ public abstract class PythonCommonFormatterTest extends PythonCommonTestCase {
|
|||||||
doTest();
|
doTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//DS-1584
|
||||||
|
public void testSpaceIPythonMagicCommands() { doTest(); }
|
||||||
|
|
||||||
|
public void testSpaceIPythonMagicCommandsJupyter() { doTest(false, "formatter/jupyter/", ".ipynb"); }
|
||||||
|
|
||||||
|
//DS-2583
|
||||||
|
public void testSpaceShellCommandsJupyter() { doTest(false, "formatter/jupyter/", ".ipynb"); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test merely checks that call to {@link com.intellij.psi.codeStyle.CodeStyleManager#reformat(com.intellij.psi.PsiElement)}
|
* This test merely checks that call to {@link com.intellij.psi.codeStyle.CodeStyleManager#reformat(com.intellij.psi.PsiElement)}
|
||||||
* is possible for Python sources.
|
* is possible for Python sources.
|
||||||
|
|||||||
@@ -132,6 +132,9 @@ public class PythonFormattingModelBuilder implements FormattingModelBuilder, Cus
|
|||||||
.aroundInside(STAR_OPERATORS, STAR_PARAMETERS).none()
|
.aroundInside(STAR_OPERATORS, STAR_PARAMETERS).none()
|
||||||
.aroundInside(STAR_OPERATORS, STAR_PATTERNS).none()
|
.aroundInside(STAR_OPERATORS, STAR_PATTERNS).none()
|
||||||
.between(EXCEPT_KEYWORD, MULT).none()
|
.between(EXCEPT_KEYWORD, MULT).none()
|
||||||
|
.between(PERC, TokenSet.create(PERC, IDENTIFIER, EXPRESSION_STATEMENT)).none()
|
||||||
|
.between(DIV, IDENTIFIER).spaces(0)
|
||||||
|
.between(IDENTIFIER, DIV).spaces(0)
|
||||||
.around(MULTIPLICATIVE_OPERATIONS).spaceIf(commonSettings.SPACE_AROUND_MULTIPLICATIVE_OPERATORS)
|
.around(MULTIPLICATIVE_OPERATIONS).spaceIf(commonSettings.SPACE_AROUND_MULTIPLICATIVE_OPERATORS)
|
||||||
.around(EXP).spaceIf(pySettings.SPACE_AROUND_POWER_OPERATOR)
|
.around(EXP).spaceIf(pySettings.SPACE_AROUND_POWER_OPERATOR)
|
||||||
.around(SHIFT_OPERATIONS).spaceIf(commonSettings.SPACE_AROUND_SHIFT_OPERATORS)
|
.around(SHIFT_OPERATIONS).spaceIf(commonSettings.SPACE_AROUND_SHIFT_OPERATORS)
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": true
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"%%time\n",
|
||||||
|
"%dirs"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 2
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython2",
|
||||||
|
"version": "2.7.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 0
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": true
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"%%time\n",
|
||||||
|
"%dirs"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 2
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython2",
|
||||||
|
"version": "2.7.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 0
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": true
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"!rm -r path/to/folder"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 2
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython2",
|
||||||
|
"version": "2.7.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 0
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": true
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"!rm -r path/to/folder"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 2
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython2",
|
||||||
|
"version": "2.7.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 0
|
||||||
|
}
|
||||||
2
python/testData/formatter/spaceIPythonMagicCommands.py
Normal file
2
python/testData/formatter/spaceIPythonMagicCommands.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
%%time
|
||||||
|
%dirs
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
%%time
|
||||||
|
%dirs
|
||||||
Reference in New Issue
Block a user