extract method test: separate formatting tests

GitOrigin-RevId: 26fd0636cfc3cba75f1c09cc6ff0ceaab43d40ae
This commit is contained in:
Alexandr Suhinin
2020-03-31 12:32:01 +00:00
committed by intellij-monorepo-bot
parent 9349c42ebe
commit 9c7991944f
17 changed files with 109 additions and 40 deletions
@@ -1,20 +1,21 @@
class Box {
private void test(String str1, String str2) {
Data data = <selection>new Data() {
@Override
public String getA() {
return str1;
}
@Override
public String getB() {
return str2;
}
}</selection>;
System.out.println(data);
}
private void test(String str1, String str2) {
Data data = <selection>new Data() {
@Override
public String getA() {
return str1;
}
static interface Data {
String getA();
String getB();
}
@Override
public String getB() {
return str2;
}
}</selection>;
System.out.println(data);
}
static interface Data {
String getA();
String getB();
}
}
@@ -1,27 +1,28 @@
import org.jetbrains.annotations.NotNull;
class Box {
private void test(String str1, String str2) {
Data data = newMethod(str1, str2);
System.out.println(data);
}
private void test(String str1, String str2) {
Data data = newMethod(str1, str2);
System.out.println(data);
}
@NotNull
private Data newMethod(String str1, String str2) {
return new Data() {
@Override
public String getA() {
return str1;
}
@Override
public String getB() {
return str2;
}
@Override
public String getA() {
return str1;
}
@Override
public String getB() {
return str2;
}
};
}
static interface Data {
String getA();
String getB();
}
String getA();
String getB();
}
}
@@ -0,0 +1,5 @@
class C {
void foo(Object o) {
<selection>((Runnable)(() -> System.out.println()))</selection>.run();
}
}
@@ -0,0 +1,12 @@
import org.jetbrains.annotations.NotNull;
class C {
void foo(Object o) {
newMethod().run();
}
@NotNull
private Runnable newMethod() {
return (Runnable)(() -> System.out.println());
}
}
@@ -0,0 +1,7 @@
import java.util.*;
class Test extends GregorianCalendar {
public boolean isSaturday() {
return <selection>get ( Calendar .DAY_OF_WEEK )</selection> == SATURDAY;
}
}
@@ -0,0 +1,11 @@
import java.util.*;
class Test extends GregorianCalendar {
public boolean isSaturday() {
return newMethod() == SATURDAY;
}
private int newMethod() {
return get ( Calendar .DAY_OF_WEEK );
}
}
@@ -4,7 +4,7 @@ import org.jetbrains.annotations.Nullable;
class C {
void foo(@Nullable Object o) {
if (o != null)
<selection>((Runnable)(() -> bar(o)))</selection>.run();
<selection>((Runnable) (() -> bar(o)))</selection>.run();
}
void bar(@NotNull Object o) {
@@ -9,7 +9,7 @@ class C {
@NotNull
private Runnable newMethod(@NotNull Object o) {
return (Runnable)(() -> bar(o));
return (Runnable) (() -> bar(o));
}
void bar(@NotNull Object o) {
@@ -4,7 +4,7 @@ import org.jetbrains.annotations.Nullable;
class C {
void foo(@Nullable Object o) {
while (o != null)
<selection>((Runnable)(() -> bar(o)))</selection>.run();
<selection>((Runnable) (() -> bar(o)))</selection>.run();
}
void bar(@NotNull Object o) {
@@ -9,7 +9,7 @@ class C {
@NotNull
private Runnable newMethod(@NotNull Object o) {
return (Runnable)(() -> bar(o));
return (Runnable) (() -> bar(o));
}
void bar(@NotNull Object o) {
@@ -0,0 +1,8 @@
class Test {
void foo(String[] ss) {
int x = 42;
<selection>
System.out.println(x+1);
</selection>
}
}
@@ -0,0 +1,12 @@
class Test {
void foo(String[] ss) {
int x = 42;
newMethod(x);
}
private void newMethod(int x) {
System.out.println(x+1);
}
}
@@ -2,6 +2,6 @@ import java.util.*;
class Test extends GregorianCalendar {
public boolean isSaturday() {
return <selection>get( Calendar.DAY_OF_WEEK )</selection> == SATURDAY;
return <selection>get(Calendar.DAY_OF_WEEK)</selection> == SATURDAY;
}
}
@@ -6,6 +6,6 @@ class Test extends GregorianCalendar {
}
private int newMethod() {
return get( Calendar.DAY_OF_WEEK );
return get(Calendar.DAY_OF_WEEK);
}
}
@@ -3,7 +3,7 @@ class Test {
for(int i = 0; i < ss.length; i++) {
<selection>
System.out.println(ss[i]);
System.out.println(ss[i+1]);
System.out.println(ss[i + 1]);
</selection>
}
}
@@ -9,6 +9,6 @@ class Test {
private void newMethod(String[] ss, int i) {
System.out.println(ss[i]);
System.out.println(ss[i+1]);
System.out.println(ss[i + 1]);
}
}
@@ -618,6 +618,18 @@ public class ExtractMethodNewTest extends LightJavaCodeInsightTestCase {
doTest();
}
public void testParameterFormatting() throws Exception {
doTest();
}
public void testNoExpressionFormatting1() throws Exception {
doTest();
}
public void testNoExpressionFormatting2() throws Exception {
doTest();
}
public void testReturnStatementFolding() throws Exception {
doTest();
}