IDEA-50592 'Surround with cast' for binary expressions (e.g. a+b) should parenthesize those expressions

This commit is contained in:
peter
2012-03-08 15:17:42 +04:00
parent 18579ef6bd
commit e51edaedf7
8 changed files with 35 additions and 4 deletions
@@ -0,0 +1,7 @@
class Test {
void foo(int a, double b) {
if (<selection><caret>a + b</selection>) {
}
}
}
@@ -0,0 +1,7 @@
class Test {
void foo(int a, double b) {
if (((<caret>) (a + b))) {
}
}
}
@@ -1,7 +1,7 @@
class Test {
void foo() {
String a = "", b = "", c = "";
if (a + (() b + c)) {
if (a + (() (b + c))) {
}
}
@@ -106,7 +106,18 @@ public class JavaSurroundWithTest extends LightCodeInsightTestCase {
doTest(getTestName(false), new JavaWithNotSurrounder());
}
private void doTest(@NotNull String fileName, final Surrounder surrounder) throws Exception {
public void testSurroundBinaryWithCast() {
final TemplateManagerImpl templateManager = (TemplateManagerImpl)TemplateManager.getInstance(getProject());
templateManager.setTemplateTesting(true);
try {
doTest(getTestName(false), new JavaWithCastSurrounder());
}
finally {
templateManager.setTemplateTesting(false);
}
}
private void doTest(@NotNull String fileName, final Surrounder surrounder) {
configureByFile(BASE_PATH + fileName + ".java");
SurroundWithHandler.invoke(getProject(), getEditor(), getFile(), surrounder);
checkResultByFile(BASE_PATH + fileName + "_after.java");