mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
handle backslashes in introduce variable initializer correctly (PY-6908); formatter removes spaces around dot
This commit is contained in:
@@ -69,6 +69,7 @@ public class PythonFormattingModelBuilder implements FormattingModelBuilder, Cus
|
||||
.before(COLON).spaceIf(pySettings.SPACE_BEFORE_PY_COLON)
|
||||
.after(COMMA).spaceIf(commonSettings.SPACE_AFTER_COMMA)
|
||||
.before(COMMA).spaceIf(commonSettings.SPACE_BEFORE_COMMA)
|
||||
.around(DOT).spaces(0)
|
||||
.before(SEMICOLON).spaceIf(commonSettings.SPACE_BEFORE_SEMICOLON)
|
||||
.withinPairInside(LPAR, RPAR, ARGUMENT_LIST).spaceIf(commonSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES)
|
||||
.before(LBRACKET).spaceIf(pySettings.SPACE_BEFORE_LBRACKET)
|
||||
|
||||
@@ -435,7 +435,7 @@ abstract public class IntroduceHandler implements RefactoringActionHandler {
|
||||
|
||||
@Override
|
||||
public void visitWhiteSpace(PsiWhiteSpace space) {
|
||||
myResult.append(space.getText().replace('\n', ' '));
|
||||
myResult.append(space.getText().replace('\n', ' ').replace("\\", ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
foo . bar
|
||||
@@ -0,0 +1 @@
|
||||
foo.bar
|
||||
@@ -0,0 +1,3 @@
|
||||
def f(x):
|
||||
a = x.foo.bar
|
||||
return a.baz()
|
||||
@@ -0,0 +1,3 @@
|
||||
def f(x):
|
||||
return <selection>x.foo\
|
||||
.bar</selection>.baz()
|
||||
@@ -50,13 +50,13 @@ public class PyFormatterTest extends PyTestCase {
|
||||
public void testBlankLineBeforeFunction() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
public void testStarArgument() { // PY-1395
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testDictLiteral() { // PY-1461
|
||||
doTest();
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testListAssignment() { // PY-1522
|
||||
@@ -121,12 +121,12 @@ public class PyFormatterTest extends PyTestCase {
|
||||
CodeStyleSettingsManager.getInstance().getSettings(myFixture.getProject()).SPACE_BEFORE_METHOD_PARENTHESES = true;
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
public void testOptionalAlignForMethodParameters() { // PY-3995
|
||||
CodeStyleSettingsManager.getInstance().getSettings(myFixture.getProject()).ALIGN_MULTILINE_PARAMETERS = false;
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
public void testNoAlignForMethodArguments() { // PY-3995
|
||||
doTest();
|
||||
}
|
||||
@@ -135,7 +135,7 @@ public class PyFormatterTest extends PyTestCase {
|
||||
CodeStyleSettingsManager.getInstance().getSettings(myFixture.getProject()).ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
public void testLambdaColon() {
|
||||
doTest();
|
||||
}
|
||||
@@ -148,6 +148,10 @@ public class PyFormatterTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSpaceAroundDot() { // PY-6908
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPsiFormatting() { // IDEA-69724
|
||||
String initial =
|
||||
"def method_name(\n" +
|
||||
@@ -158,7 +162,7 @@ public class PyFormatterTest extends PyTestCase {
|
||||
" # Extract from here to ...\n" +
|
||||
" desired_impulse_response = {'dirac, 'gaussian', logistic_derivative'}\n" +
|
||||
"return desired, o";
|
||||
|
||||
|
||||
final PsiFile file = PyElementGenerator.getInstance(myFixture.getProject()).createDummyFile(LanguageLevel.PYTHON30, initial);
|
||||
final PsiElement reformatted = CodeStyleManager.getInstance(myFixture.getProject()).reformat(file);
|
||||
|
||||
@@ -176,7 +180,7 @@ public class PyFormatterTest extends PyTestCase {
|
||||
assertEquals(expected, reformatted.getText());
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
private void doTest() {
|
||||
myFixture.configureByFile("formatter/" + getTestName(true) + ".py");
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
|
||||
@@ -80,6 +80,10 @@ public class PyIntroduceVariableTest extends PyIntroduceTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testBackslash() { // PY-6908
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTestCannotPerform() {
|
||||
boolean thrownExpectedException = false;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user