diff --git a/python/src/META-INF/python-core-common.xml b/python/src/META-INF/python-core-common.xml
index e3632161f23c..23118b32b9bb 100644
--- a/python/src/META-INF/python-core-common.xml
+++ b/python/src/META-INF/python-core-common.xml
@@ -452,7 +452,7 @@
-
+
diff --git a/python/src/com/jetbrains/python/refactoring/rename/RenamePyLiteralExpressionProcessor.java b/python/src/com/jetbrains/python/refactoring/rename/RenameUnsupportedExpressionProcessor.java
similarity index 75%
rename from python/src/com/jetbrains/python/refactoring/rename/RenamePyLiteralExpressionProcessor.java
rename to python/src/com/jetbrains/python/refactoring/rename/RenameUnsupportedExpressionProcessor.java
index 8910129755b5..221d87c85d0c 100644
--- a/python/src/com/jetbrains/python/refactoring/rename/RenamePyLiteralExpressionProcessor.java
+++ b/python/src/com/jetbrains/python/refactoring/rename/RenameUnsupportedExpressionProcessor.java
@@ -22,14 +22,23 @@ import com.intellij.refactoring.listeners.RefactoringElementListener;
import com.intellij.usageView.UsageInfo;
import com.intellij.util.IncorrectOperationException;
import com.jetbrains.python.codeInsight.PyCodeInsightSettings;
-import com.jetbrains.python.psi.PyLiteralExpression;
+import com.jetbrains.python.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-public class RenamePyLiteralExpressionProcessor extends RenamePyElementProcessor {
+public class RenameUnsupportedExpressionProcessor extends RenamePyElementProcessor {
@Override
public boolean canProcessElement(@NotNull PsiElement element) {
- return PsiTreeUtil.instanceOf(element, PyLiteralExpression.class);
+ return PsiTreeUtil.instanceOf(element,
+ PyStringLiteralExpression.class,
+ PyNumericLiteralExpression.class,
+ PyListLiteralExpression.class,
+ PyDictLiteralExpression.class,
+ PySetLiteralExpression.class,
+ PyStarArgument.class,
+ PyCallExpression.class,
+ PyBinaryExpression.class,
+ PySubscriptionExpression.class);
}
@Override
diff --git a/python/testData/refactoring/rename/binaryAsPercentArg.py b/python/testData/refactoring/rename/binaryAsPercentArg.py
new file mode 100644
index 000000000000..737d2dccdc17
--- /dev/null
+++ b/python/testData/refactoring/rename/binaryAsPercentArg.py
@@ -0,0 +1 @@
+"%s" % (1+1)
\ No newline at end of file
diff --git a/python/testData/refactoring/rename/callAsPercentArg.py b/python/testData/refactoring/rename/callAsPercentArg.py
new file mode 100644
index 000000000000..9bbb82edfd8c
--- /dev/null
+++ b/python/testData/refactoring/rename/callAsPercentArg.py
@@ -0,0 +1,3 @@
+def f():
+ return (1, 2)
+"%s" % f()
\ No newline at end of file
diff --git a/python/testData/refactoring/rename/dictAsPercentArg.py b/python/testData/refactoring/rename/dictAsPercentArg.py
new file mode 100644
index 000000000000..d5596674a5a1
--- /dev/null
+++ b/python/testData/refactoring/rename/dictAsPercentArg.py
@@ -0,0 +1 @@
+"%s" % {"a": 1}
\ No newline at end of file
diff --git a/python/testData/refactoring/rename/listAsPercentArg.py b/python/testData/refactoring/rename/listAsPercentArg.py
new file mode 100644
index 000000000000..bc950f1fe285
--- /dev/null
+++ b/python/testData/refactoring/rename/listAsPercentArg.py
@@ -0,0 +1 @@
+"%s" % [1, 2, 3]
\ No newline at end of file
diff --git a/python/testData/refactoring/rename/setAsPercentArg.py b/python/testData/refactoring/rename/setAsPercentArg.py
new file mode 100644
index 000000000000..6c0867dd9fcc
--- /dev/null
+++ b/python/testData/refactoring/rename/setAsPercentArg.py
@@ -0,0 +1 @@
+"%s" % {"foo"}
\ No newline at end of file
diff --git a/python/testData/refactoring/rename/starAsFormatFunctionArg.py b/python/testData/refactoring/rename/starAsFormatFunctionArg.py
new file mode 100644
index 000000000000..36250e569619
--- /dev/null
+++ b/python/testData/refactoring/rename/starAsFormatFunctionArg.py
@@ -0,0 +1,4 @@
+def f():
+ return (1,2)
+
+"{}".format(*f())
\ No newline at end of file
diff --git a/python/testData/refactoring/rename/stringAsPositionalFormatFunctionArgument.py b/python/testData/refactoring/rename/stringAsPositionalFormatFunctionArgument.py
new file mode 100644
index 000000000000..d737836dd674
--- /dev/null
+++ b/python/testData/refactoring/rename/stringAsPositionalFormatFunctionArgument.py
@@ -0,0 +1 @@
+"{}".format("str")
\ No newline at end of file
diff --git a/python/testData/refactoring/rename/subscriptionAsPercentArg.py b/python/testData/refactoring/rename/subscriptionAsPercentArg.py
new file mode 100644
index 000000000000..698a90784c96
--- /dev/null
+++ b/python/testData/refactoring/rename/subscriptionAsPercentArg.py
@@ -0,0 +1 @@
+"%s" % [1, 2][0]
\ No newline at end of file
diff --git a/python/testSrc/com/jetbrains/python/refactoring/PyRenameTest.java b/python/testSrc/com/jetbrains/python/refactoring/PyRenameTest.java
index 88bbd18ca102..7764d3aa6cdc 100644
--- a/python/testSrc/com/jetbrains/python/refactoring/PyRenameTest.java
+++ b/python/testSrc/com/jetbrains/python/refactoring/PyRenameTest.java
@@ -21,6 +21,7 @@ import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.refactoring.BaseRefactoringProcessor;
import com.intellij.testFramework.PlatformTestUtil;
+import com.intellij.util.IncorrectOperationException;
import com.jetbrains.python.PythonTestUtil;
import com.jetbrains.python.documentation.docstrings.DocStringFormat;
import com.jetbrains.python.fixtures.PyTestCase;
@@ -236,39 +237,61 @@ public class PyRenameTest extends PyTestCase {
renameWithDocStringFormat(DocStringFormat.NUMPY, "bar");
}
- //PY-2748
+ // PY-2748
public void testFormatStringKeyword() {
doTest("renamed");
}
- //PY-2748
+ // PY-2748
public void testFormatStringDictLiteral() {
- myFixture.configureByFile(RENAME_DATA_PATH + getTestName(true) + ".py");
- try {
- myFixture.renameElementAtCaret("renamed");
- }
- catch (RuntimeException e) {
- if ("com.intellij.util.IncorrectOperationException".equals(e.getMessage())) {
- return;
- }
- }
- fail();
+ doUnsupportedOperationTest();
}
- //PY-2748
+ // PY-2748
public void testFormatStringNumericLiteralExpression() {
- myFixture.configureByFile(RENAME_DATA_PATH + getTestName(true) + ".py");
- try {
- myFixture.renameElementAtCaret("renamed");
- }
- catch (RuntimeException e) {
- if ("com.intellij.util.IncorrectOperationException".equals(e.getMessage())) {
- return;
- }
- }
- fail();
+ doUnsupportedOperationTest();
}
-
+
+ // PY-19000
+ public void testStringAsPositionalFormatFunctionArgument() {
+ doUnsupportedOperationTest();
+ }
+
+ // PY-19000
+ public void testSetAsPercentArg() {
+ doUnsupportedOperationTest();
+ }
+
+ // PY-19000
+ public void testListAsPercentArg() {
+ doUnsupportedOperationTest();
+ }
+
+ // PY-19000
+ public void testCallAsPercentArg() {
+ doUnsupportedOperationTest();
+ }
+
+ // PY-19000
+ public void testStarAsFormatFunctionArg() {
+ doUnsupportedOperationTest();
+ }
+
+ // PY-19000
+ public void testSubscriptionAsPercentArg() {
+ doUnsupportedOperationTest();
+ }
+
+ // PY-19000
+ public void testBinaryAsPercentArg() {
+ doUnsupportedOperationTest();
+ }
+
+ // PY-19000
+ public void testDictAsPercentArg() {
+ doUnsupportedOperationTest();
+ }
+
private void renameWithDocStringFormat(DocStringFormat format, final String newName) {
runWithDocStringFormat(format, new Runnable() {
public void run() {
@@ -277,6 +300,19 @@ public class PyRenameTest extends PyTestCase {
});
}
+ private void doUnsupportedOperationTest() {
+ myFixture.configureByFile(RENAME_DATA_PATH + getTestName(true) + ".py");
+ try {
+ myFixture.renameElementAtCaret("renamed");
+ }
+ catch (RuntimeException e) {
+ if (e.getCause() instanceof IncorrectOperationException) {
+ return;
+ }
+ }
+ fail();
+ }
+
private void doRenameConflictTest(String newName, String expectedConflict) {
myFixture.configureByFile(RENAME_DATA_PATH + getTestName(true) + ".py");
try {