IDEA-117252 Extract variable bug

This commit is contained in:
anna
2013-11-29 18:24:22 +01:00
parent 4920da736f
commit 19ac5df6f2
8 changed files with 158 additions and 2 deletions
@@ -0,0 +1,27 @@
import java.io.PrintStream;
class Foo {
public static void bazz(int i) {
Foo j = new Foo(new IBar() {
public void doSomething(PrintStream out) {
out.println("hello");
}
});
final Foo foo = i != 0 ? j : j;
foo.bla();
}
private final IBar bar;
public Foo(IBar bar) {
this.bar = bar;
}
public void bla() {
bar.doSomething(System.out);
}
public interface IBar {
void doSomething(PrintStream out);
}
}
@@ -0,0 +1,30 @@
import java.io.PrintStream;
class Foo {
public static void bazz(int i) {
final Foo foo = i != 0 ? <selection>new Foo(new IBar() {
public void doSomething(PrintStream out) {
out.println("hello");
}
})</selection> : new Foo(new IBar() {
public void doSomething(PrintStream out) {
out.println("hello");
}
});
foo.bla();
}
private final IBar bar;
public Foo(IBar bar) {
this.bar = bar;
}
public void bla() {
bar.doSomething(System.out);
}
public interface IBar {
void doSomething(PrintStream out);
}
}
@@ -0,0 +1,22 @@
import java.util.ArrayList;
import java.util.Collection;
public class ExtractVariableSample {
public static void main(String[] args) {
Collection<String> strings = new ArrayList<>();
new Object() {
public void foo(String s) {
System.out.println( s.hashCode());
}
};
for (String s : strings) {
int j = s.hashCode();
System.out.println(j);
}
}
}
@@ -0,0 +1,21 @@
import java.util.ArrayList;
import java.util.Collection;
public class ExtractVariableSample {
public static void main(String[] args) {
Collection<String> strings = new ArrayList<>();
new Object() {
public void foo(String s) {
System.out.println( s.hashCode());
}
};
for (String s : strings) {
System.out.println(<selection>s.hashCode()</selection>);
}
}
}
@@ -0,0 +1,20 @@
import java.util.ArrayList;
import java.util.Collection;
public class ExtractVariableSample {
public static void main(String[] args, String s) {
Collection<String> strings = new ArrayList<>();
new Object() {
public void foo(String s) {
System.out.println( s.hashCode());
}
};
int j = s.hashCode();
System.out.println(j);
}
}
@@ -0,0 +1,19 @@
import java.util.ArrayList;
import java.util.Collection;
public class ExtractVariableSample {
public static void main(String[] args, String s) {
Collection<String> strings = new ArrayList<>();
new Object() {
public void foo(String s) {
System.out.println( s.hashCode());
}
};
System.out.println(<selection>s.hashCode()</selection>);
}
}