mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inline method: missed braces (IDEA-133700)
This commit is contained in:
@@ -1269,7 +1269,7 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
|
||||
if (parentStatement != null) {
|
||||
PsiElement parent = ref.getParent();
|
||||
while (!parent.equals(parentStatement)) {
|
||||
if (parent instanceof PsiExpressionStatement) {
|
||||
if (parent instanceof PsiExpressionStatement || parent instanceof PsiReturnStatement) {
|
||||
String text = "{\n}";
|
||||
PsiBlockStatement blockStatement = (PsiBlockStatement)myFactory.createStatementFromText(text, null);
|
||||
blockStatement = (PsiBlockStatement)myCodeStyleManager.reformat(blockStatement);
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
class JavaClass {
|
||||
String bar() {
|
||||
return "bar";
|
||||
}
|
||||
|
||||
String baz(boolean condition) {
|
||||
if (condition)
|
||||
return b<caret>ar();
|
||||
|
||||
return "default";
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class JavaClass {
|
||||
String bar() {
|
||||
return "bar";
|
||||
}
|
||||
|
||||
String baz(boolean condition) {
|
||||
if (condition)
|
||||
return "bar";
|
||||
|
||||
return "default";
|
||||
}
|
||||
}
|
||||
@@ -272,6 +272,10 @@ public class InlineMethodTest extends LightRefactoringTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testReturnStatementWithoutBraces() throws Exception {
|
||||
doTestInlineThisOnly();
|
||||
}
|
||||
|
||||
private void doTestInlineThisOnly() {
|
||||
@NonNls String fileName = "/refactoring/inlineMethod/" + getTestName(false) + ".java";
|
||||
configureByFile(fileName);
|
||||
|
||||
Reference in New Issue
Block a user