mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-82925 ('Surround with cast' for conditional, polyadic and assignment expressions should parenthesize those expressions)
This commit is contained in:
+7
@@ -0,0 +1,7 @@
|
||||
class Test {
|
||||
void foo(int a, double b) {
|
||||
if (<selection><caret>a = b</selection>) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class Test {
|
||||
void foo(int a, double b) {
|
||||
if (((<caret>) (a = b))) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
class Test {
|
||||
void foo(int a, double b) {
|
||||
if (<selection><caret>a + b</selection>) {
|
||||
if (<selection><caret>a + b + 1</selection>) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
class Test {
|
||||
void foo(int a, double b) {
|
||||
if (((<caret>) (a + b))) {
|
||||
if (((<caret>) (a + b + 1))) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class Test {
|
||||
void foo(int a, double b) {
|
||||
if (<selection><caret>true ? a : b</selection>) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class Test {
|
||||
void foo(int a, double b) {
|
||||
if (((<caret>) (true ? a : b))) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
@@ -117,6 +117,28 @@ public class JavaSurroundWithTest extends LightCodeInsightTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testSurroundConditionalWithCast() {
|
||||
final TemplateManagerImpl templateManager = (TemplateManagerImpl)TemplateManager.getInstance(getProject());
|
||||
templateManager.setTemplateTesting(true);
|
||||
try {
|
||||
doTest(getTestName(false), new JavaWithCastSurrounder());
|
||||
}
|
||||
finally {
|
||||
templateManager.setTemplateTesting(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void testSurroundAssignmentWithCast() {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user