Java: Implemented "Inline 'else' code branch" intention (IDEA-165428)

This commit is contained in:
Pavel Dolgov
2017-01-13 14:42:07 +03:00
parent 03250557c9
commit 37b6fb9405
17 changed files with 230 additions and 4 deletions
@@ -0,0 +1,9 @@
// "Inline 'else' branch" "true"
class T {
void f(boolean b) {
if (b)
System.out.println("When true");
System.out.println("Otherwise");
}
}
@@ -0,0 +1,12 @@
// "Inline 'else' branch" "true"
class T {
void f(boolean b) {
if (b) {
System.out.println("When true");
}
// Before
System.out.println("Otherwise");
// After
}
}
@@ -0,0 +1,11 @@
// "Inline 'else' branch" "true"
class T {
void f(boolean b) {
if (b)
System.out.println("When true");
// Before
System.out.println("Otherwise");
// After
}
}
@@ -0,0 +1,10 @@
// "Inline 'else' branch" "true"
class T {
void f(boolean b) {
if (b) {
System.out.println("When true");
}
System.out.println("Otherwise");
}
}
@@ -0,0 +1,11 @@
// "Inline 'else' branch" "true"
class T {
void f(boolean b) {
if (b)
System.out.println("When true");
<caret>else {
System.out.println("Otherwise");
}
}
}
@@ -0,0 +1,13 @@
// "Inline 'else' branch" "true"
class T {
void f(boolean b) {
if (b) {
System.out.println("When true");
} <caret>else {
// Before
System.out.println("Otherwise");
// After
}
}
}
@@ -0,0 +1,12 @@
// "Inline 'else' branch" "false"
class T {
void f(boolean a, boolean b) {
if (a)
if (b) {
System.out.println("When true");
} <caret>else {
System.out.println("Otherwise");
}
}
}
@@ -0,0 +1,12 @@
// "Inline 'else' branch" "true"
class T {
void f(boolean b) {
if (b)
System.out.println("When true");
<caret>else
// Before
System.out.println("Otherwise");
// After
}
}
@@ -0,0 +1,11 @@
// "Inline 'else' branch" "true"
class T {
void f(boolean b) {
if (b) {
System.out.println("When true");
} <caret>else {
System.out.println("Otherwise");
}
}
}
@@ -0,0 +1,33 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.intention;
import com.intellij.codeInsight.daemon.LightIntentionActionTestCase;
/**
* @author Pavel.Dolgov
*/
public class InlineElseBranchTest extends LightIntentionActionTestCase {
@Override
protected String getBasePath() {
return "/codeInsight/inlineElseBranch/";
}
public void test() throws Exception {
doAllTests();
}
}