mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-07 22:09:38 +07:00
test++
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class ExtractMethods { }
|
||||
abstract class MyButton
|
||||
extends JButton
|
||||
{
|
||||
protected MyButton( String text ) {
|
||||
super( text );
|
||||
}
|
||||
}
|
||||
class Foo {
|
||||
private JButton createOKButton() {
|
||||
return new MyButton( "OK" ) {
|
||||
public void actionPerformed( ActionEvent e ) {
|
||||
<selection> setVisible( false ); </selection>
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class ExtractMethods { }
|
||||
abstract class MyButton
|
||||
extends JButton
|
||||
{
|
||||
protected MyButton( String text ) {
|
||||
super( text );
|
||||
}
|
||||
}
|
||||
class Foo {
|
||||
private JButton createOKButton() {
|
||||
return new MyButton( "OK" ) {
|
||||
public void actionPerformed( ActionEvent e ) {
|
||||
newMethod();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void newMethod() {
|
||||
setVisible( false );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class Test {
|
||||
void foo(String[] ss) {
|
||||
for(int i = 0; i < ss.length; i++) {
|
||||
<selection>System.out.println(ss[i]);
|
||||
System.out.println(ss[i] + ss[i]);</selection>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Test {
|
||||
void foo(String[] ss, String[] bb) {
|
||||
for(int i = 0; i < ss.length; i++) {
|
||||
<selection>
|
||||
System.out.println(ss[i]);
|
||||
System.out.println(bb[i]);
|
||||
</selection>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class Test {
|
||||
void foo(String[] ss, String[] bb) {
|
||||
for(int i = 0; i < ss.length; i++) {
|
||||
|
||||
newMethod(ss[i], bb[i]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void newMethod(String s, String x) {
|
||||
System.out.println(s);
|
||||
System.out.println(x);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class Test {
|
||||
void foo(String[] ss) {
|
||||
<selection>System.out.println(ss[0]);</selection>
|
||||
System.out.println(ss[0]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Test {
|
||||
void foo(String[] ss) {
|
||||
newMethod(ss[0]);
|
||||
newMethod(ss[0]);
|
||||
}
|
||||
|
||||
private void newMethod(String s) {
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class Test {
|
||||
void foo(String[] ss) {
|
||||
for(int i = 0; i < ss.length; i++) {
|
||||
newMethod(ss[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void newMethod(String s) {
|
||||
System.out.println(s);
|
||||
System.out.println(s + s);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class Test {
|
||||
void method(int i) {
|
||||
boolean isDirty = <selection>i == 0</selection> || otherTests();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Test {
|
||||
void method(int i) {
|
||||
boolean isDirty = newMethod(i) || otherTests();
|
||||
}
|
||||
|
||||
private boolean newMethod(int i) {
|
||||
return i == 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class A {
|
||||
private int i;
|
||||
private int j;
|
||||
|
||||
public A(int i, int j) {
|
||||
<selection>this.i = i;</selection>
|
||||
this.j = j;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class A {
|
||||
private int i;
|
||||
private int j;
|
||||
private int s;
|
||||
|
||||
public A(int i, int j) {
|
||||
<selection>this.i = i;</selection>
|
||||
this.j = j;
|
||||
}
|
||||
|
||||
public A(int i, String s) {
|
||||
this.i = i;
|
||||
this.s = s;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
class A {
|
||||
private int i;
|
||||
private int j;
|
||||
private int s;
|
||||
|
||||
public A(int i, int j) {
|
||||
this(i);
|
||||
this.j = j;
|
||||
}
|
||||
|
||||
private A(int i) {
|
||||
this.i = i;
|
||||
}
|
||||
|
||||
public A(int i, String s) {
|
||||
this(i);
|
||||
this.s = s;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class A {
|
||||
private int i;
|
||||
private int j;
|
||||
private int s;
|
||||
|
||||
public A(int i, int j) {
|
||||
<selection>this.i = i;</selection>
|
||||
this.j = j;
|
||||
}
|
||||
|
||||
public A(int i, String s) {
|
||||
this.s = s;
|
||||
this.i = i;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
class A {
|
||||
private int i;
|
||||
private int j;
|
||||
private int s;
|
||||
|
||||
public A(int i, int j) {
|
||||
this(i);
|
||||
this.j = j;
|
||||
}
|
||||
|
||||
private A(int i) {
|
||||
this.i = i;
|
||||
}
|
||||
|
||||
public A(int i, String s) {
|
||||
this.s = s;
|
||||
this.i = i;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
class A {
|
||||
private int i;
|
||||
private int j;
|
||||
|
||||
public A(int i, int j) {
|
||||
this(i);
|
||||
this.j = j;
|
||||
}
|
||||
|
||||
private A(int i) {
|
||||
this.i = i;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
{
|
||||
int i;
|
||||
|
||||
<selection>System.out.println(i);</selection>
|
||||
System.out.println(128);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class C {
|
||||
{
|
||||
Object[] array;
|
||||
|
||||
<selection>for (int i = 0; i < array.length; i++) {
|
||||
System.out.println(array[i]);
|
||||
}</selection>
|
||||
|
||||
|
||||
Object[] array1;
|
||||
for (int i = 0; i < array1.length; i++) {
|
||||
System.out.println(array[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
class C {
|
||||
{
|
||||
Object[] array;
|
||||
|
||||
newMethod(array);
|
||||
|
||||
|
||||
Object[] array1;
|
||||
for (int i = 0; i < array1.length; i++) {
|
||||
System.out.println(array[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void newMethod(Object[] array) {
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
System.out.println(array[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class C {
|
||||
{
|
||||
Object[] array;
|
||||
|
||||
<selection>for (int i = 0; i < array.length; i++) {
|
||||
System.out.println(array[i]);
|
||||
}</selection>
|
||||
|
||||
|
||||
Object[] array1;
|
||||
for (int i = 0; i < array1.length; i++) {
|
||||
System.out.println(array1[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
class C {
|
||||
{
|
||||
Object[] array;
|
||||
|
||||
newMethod(array);
|
||||
|
||||
|
||||
Object[] array1;
|
||||
newMethod(array1);
|
||||
}
|
||||
|
||||
private void newMethod(Object[] array) {
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
System.out.println(array[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class C {
|
||||
{
|
||||
Object[] array;
|
||||
|
||||
<selection>for (int i = 0; i < array.length; i++) {
|
||||
System.out.println(array[i]);
|
||||
}</selection>
|
||||
|
||||
|
||||
Object[] array1;
|
||||
for (int j = 0; j < array1.length; j++) {
|
||||
System.out.println(array1[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
class C {
|
||||
{
|
||||
Object[] array;
|
||||
|
||||
newMethod(array);
|
||||
|
||||
|
||||
Object[] array1;
|
||||
newMethod(array1);
|
||||
}
|
||||
|
||||
private void newMethod(Object[] array) {
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
System.out.println(array[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
class D {}
|
||||
class C extends D {
|
||||
int myField = 10;
|
||||
int myOtherField = 10;
|
||||
|
||||
{
|
||||
int i = 5;
|
||||
<selection>myField = i;
|
||||
myOtherField = i;</selection>
|
||||
|
||||
C c = new C();
|
||||
|
||||
c.myField = 12;
|
||||
c.myOtherField = 12;
|
||||
|
||||
C c1 = new C();
|
||||
c1.myField = 12;
|
||||
myOtherField = 12;
|
||||
|
||||
|
||||
//not a duplicate: method is not visible with qualifer class
|
||||
D d1 = new D();
|
||||
d1.myField = 12;
|
||||
d1.myOtherField = 12;
|
||||
|
||||
|
||||
c.myField = 15;
|
||||
c1.myOtherField = 15;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
class D {}
|
||||
class C extends D {
|
||||
int myField = 10;
|
||||
int myOtherField = 10;
|
||||
|
||||
{
|
||||
int i = 5;
|
||||
newMethod(i);
|
||||
|
||||
C c = new C();
|
||||
|
||||
c.newMethod(12);
|
||||
|
||||
C c1 = new C();
|
||||
c1.myField = 12;
|
||||
myOtherField = 12;
|
||||
|
||||
|
||||
//not a duplicate: method is not visible with qualifer class
|
||||
D d1 = new D();
|
||||
d1.myField = 12;
|
||||
d1.myOtherField = 12;
|
||||
|
||||
|
||||
c.myField = 15;
|
||||
c1.myOtherField = 15;
|
||||
}
|
||||
|
||||
private void newMethod(int i) {
|
||||
myField = i;
|
||||
myOtherField = i;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
class Test {
|
||||
private List<Object> list1 = new ArrayList<Object>();
|
||||
|
||||
private List<Object> list2 = new ArrayList<Object>();
|
||||
|
||||
public void method1()
|
||||
{
|
||||
list1.add(null);
|
||||
// add to list2
|
||||
list2.add(true);
|
||||
}
|
||||
|
||||
public void method2()
|
||||
{
|
||||
<selection>list1.add(null);
|
||||
// add to list2
|
||||
list2.add(true);</selection>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
class Test {
|
||||
private List<Object> list1 = new ArrayList<Object>();
|
||||
|
||||
private List<Object> list2 = new ArrayList<Object>();
|
||||
|
||||
public void method1()
|
||||
{
|
||||
newMethod();
|
||||
}
|
||||
|
||||
public void method2()
|
||||
{
|
||||
newMethod();
|
||||
}
|
||||
|
||||
private void newMethod() {
|
||||
list1.add(null);
|
||||
// add to list2
|
||||
list2.add(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class C {
|
||||
void foo() {
|
||||
for(int i = 0; i < 10; i++){
|
||||
<selection>if (i < 10){ continue;}</selection>
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
for(int i = 0; i < 10; i++){
|
||||
if (i < 10){ continue;}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
class C {
|
||||
void foo() {
|
||||
for(int i = 0; i < 10; i++){
|
||||
<selection>if (i < 10){ continue;}</selection>
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
for(int i = 0; i < 10; i++){
|
||||
if (i < 10){ continue;}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
class C {
|
||||
void foo() {
|
||||
for(int i = 0; i < 10; i++){
|
||||
newMethod(i);
|
||||
}
|
||||
}
|
||||
|
||||
private void newMethod(int i) {
|
||||
if (i < 10){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
for(int i = 0; i < 10; i++){
|
||||
newMethod(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
class C {
|
||||
void foo() {
|
||||
for(int i = 0; i < 10; i++){
|
||||
if (newMethod(i)) continue;
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean newMethod(int i) {
|
||||
if (i < 10){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
for(int i = 0; i < 10; i++){
|
||||
if (newMethod(i)) continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class A {
|
||||
int foo (Object o) {
|
||||
<selection>if (o == null) return 0;</selection>
|
||||
if (o == null) return 0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class A {
|
||||
int foo (Object o) {
|
||||
if (newMethod(o)) return 0;
|
||||
if (newMethod(o)) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
private boolean newMethod(Object o) {
|
||||
if (o == null) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import java.util.*;
|
||||
|
||||
class C {
|
||||
{
|
||||
Object[] array;
|
||||
|
||||
<selection>List l1 = new ArrayList(Arrays.asList(array));</selection>
|
||||
|
||||
List l2 = new ArrayList(Arrays.asList(getObjects()));
|
||||
|
||||
System.out.println("l1 = " + l1 + ", l2 = " + l2);
|
||||
}
|
||||
|
||||
String[] getObjects() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import java.util.*;
|
||||
|
||||
class C {
|
||||
{
|
||||
Object[] array;
|
||||
|
||||
<selection>List l1 = null;
|
||||
l1 = new ArrayList(Arrays.asList(array));</selection>
|
||||
|
||||
List l2 = null;
|
||||
l2 = new ArrayList(Arrays.asList(getObjects()));
|
||||
|
||||
System.out.println("l1 = " + l1 + ", l2 = " + l2);
|
||||
}
|
||||
|
||||
|
||||
String[] getObjects() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import java.util.*;
|
||||
|
||||
class C {
|
||||
{
|
||||
Object[] array;
|
||||
|
||||
List l1 = newMethod(array);
|
||||
|
||||
List l2 = newMethod(getObjects());
|
||||
|
||||
System.out.println("l1 = " + l1 + ", l2 = " + l2);
|
||||
}
|
||||
|
||||
private List newMethod(Object[] array) {
|
||||
List l1 = null;
|
||||
l1 = new ArrayList(Arrays.asList(array));
|
||||
return l1;
|
||||
}
|
||||
|
||||
|
||||
String[] getObjects() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import java.util.*;
|
||||
|
||||
class C {
|
||||
{
|
||||
Object[] array;
|
||||
|
||||
List l1 = newMethod(array);
|
||||
|
||||
List l2 = newMethod(getObjects());
|
||||
|
||||
System.out.println("l1 = " + l1 + ", l2 = " + l2);
|
||||
}
|
||||
|
||||
private List newMethod(Object[] array) {
|
||||
List l1 = new ArrayList(Arrays.asList(array));
|
||||
return l1;
|
||||
}
|
||||
|
||||
String[] getObjects() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
class C {
|
||||
String method(Object o) {
|
||||
System.out.println(o);
|
||||
<selection>Integer i = new Integer(o.hashCode());
|
||||
return i.toString();</selection>
|
||||
}
|
||||
|
||||
{
|
||||
String k;
|
||||
Integer j = new Integer(Boolean.TRUE.hashCode());
|
||||
k = j.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class C {
|
||||
String method(Object o) {
|
||||
System.out.println(o);
|
||||
<selection>Integer i = new Integer(o.hashCode());
|
||||
return i.toString();</selection>
|
||||
}
|
||||
|
||||
{
|
||||
Integer j = new Integer(Boolean.TRUE.hashCode());
|
||||
String k = j.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class C {
|
||||
String method(Object o) {
|
||||
System.out.println(o);
|
||||
return newMethod(o);
|
||||
}
|
||||
|
||||
private String newMethod(Object o) {
|
||||
Integer i = new Integer(o.hashCode());
|
||||
return i.toString();
|
||||
}
|
||||
|
||||
{
|
||||
String k = newMethod(Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
class C {
|
||||
String method(Object o) {
|
||||
System.out.println(o);
|
||||
return newMethod(o);
|
||||
}
|
||||
|
||||
private String newMethod(Object o) {
|
||||
Integer i = new Integer(o.hashCode());
|
||||
return i.toString();
|
||||
}
|
||||
|
||||
{
|
||||
String k;
|
||||
k = newMethod(Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
class C {
|
||||
static C c;
|
||||
static {
|
||||
java.util.ArrayList<C> l = null;
|
||||
l.add(c);
|
||||
}
|
||||
|
||||
void foo() {
|
||||
System.out.println(<selection>c</selection>);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class C {
|
||||
static C c;
|
||||
static {
|
||||
java.util.ArrayList<C> l = null;
|
||||
l.add(newMethod());
|
||||
}
|
||||
|
||||
void foo() {
|
||||
System.out.println(newMethod());
|
||||
}
|
||||
|
||||
private static C newMethod() {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class C {
|
||||
{
|
||||
int i;
|
||||
|
||||
newMethod(i);
|
||||
newMethod(128);
|
||||
}
|
||||
|
||||
private void newMethod(int i) {
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
public /*abstract*/ class WillWorkTest {
|
||||
int opera() {
|
||||
int i = 0;
|
||||
<selection>
|
||||
int k;
|
||||
if (true) k = i;
|
||||
return k;</selection>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
public /*abstract*/ class WillWorkTest {
|
||||
int opera() {
|
||||
int i = 0;
|
||||
|
||||
return newMethod(i);
|
||||
}
|
||||
|
||||
private int newMethod(int i) {
|
||||
int k;
|
||||
if (true) k = i;
|
||||
return k;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Test{
|
||||
public void foo() {
|
||||
if (cond1){
|
||||
<selection>if (cond2) return;</selection>
|
||||
}
|
||||
else if (cond3){
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Test{
|
||||
public void foo() {
|
||||
if (cond1){
|
||||
<selection>if (cond2) return;</selection>
|
||||
}
|
||||
else if (cond3){
|
||||
}
|
||||
x();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class Test{
|
||||
public void foo() {
|
||||
if (cond1){
|
||||
if (newMethod()) return;
|
||||
}
|
||||
else if (cond3){
|
||||
}
|
||||
x();
|
||||
}
|
||||
|
||||
private boolean newMethod() {
|
||||
if (cond2) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Test{
|
||||
void foo() {
|
||||
if (cond1){
|
||||
<selection>if (cond2) return;
|
||||
x();</selection>
|
||||
}
|
||||
else if (cond3){
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class Test {
|
||||
int method() {
|
||||
<selection>try {
|
||||
if(cond1) return 0;
|
||||
else if(cond2) return 1;
|
||||
System.out.println("Text");
|
||||
} finally {
|
||||
doSomething();
|
||||
}</selection>
|
||||
return 12;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class Test {
|
||||
int method() {
|
||||
<selection>try {
|
||||
if(cond1) return 0;
|
||||
else if(cond2) return 1;
|
||||
return 27;
|
||||
} finally {
|
||||
doSomething();
|
||||
}</selection>
|
||||
return 12;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
class Test {
|
||||
int method() {
|
||||
return newMethod();
|
||||
return 12;
|
||||
}
|
||||
|
||||
private int newMethod() {
|
||||
try {
|
||||
if(cond1) return 0;
|
||||
else if(cond2) return 1;
|
||||
return 27;
|
||||
} finally {
|
||||
doSomething();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// multiple output values: one for modelling control flow + output value
|
||||
class K {
|
||||
int f(Object o) {
|
||||
<selection>if (o == null) return 0;
|
||||
o = new Object();</selection>
|
||||
Object oo = o;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
class Foo {
|
||||
public Object createBean(Object parent) {
|
||||
try {
|
||||
<selection>if (parent != null) {
|
||||
try {
|
||||
}
|
||||
catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Object tag = null;</selection>
|
||||
|
||||
tag = foo(tag);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Object foo(final Object tag) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class C {
|
||||
public Object m() {
|
||||
<selection>for (Object o : new ArrayList<Object>()) {
|
||||
if (o != null) {
|
||||
return o;
|
||||
}
|
||||
}</selection>
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
class Result {
|
||||
private String _message;
|
||||
|
||||
public Result(String _message) {
|
||||
this._message = _message;
|
||||
}
|
||||
}
|
||||
|
||||
class Main {
|
||||
public static Result doIt(String name) {
|
||||
Result result;
|
||||
|
||||
<selection>if (name == null) {
|
||||
result = new Result("Name is null");
|
||||
return result;
|
||||
}
|
||||
if (name.length() == 0) {
|
||||
result = new Result("Name is empty");
|
||||
return result;
|
||||
}</selection>
|
||||
|
||||
result = new Result("Name is " + name);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class s {
|
||||
void f(boolean b) {
|
||||
for (;;) {
|
||||
<selection>if (b) {
|
||||
break;
|
||||
}</selection>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import java.util.*;
|
||||
|
||||
class C {
|
||||
{
|
||||
Object[] o = null;
|
||||
List l = <selection>new ArrayList(Arrays.asList(o))</selection>;
|
||||
|
||||
List l1 = new ArrayList(Arrays.asList(new Object[0]));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import java.util.*;
|
||||
|
||||
class C {
|
||||
{
|
||||
Object[] o = null;
|
||||
List l = newMethod(o);
|
||||
|
||||
List l1 = newMethod(new Object[0]);
|
||||
}
|
||||
|
||||
private ArrayList newMethod(Object[] o) {
|
||||
return new ArrayList(Arrays.asList(o));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Test {
|
||||
public static void main() {
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
<selection>System.out</selection>.println("Text");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import java.io.PrintStream;
|
||||
|
||||
class Test {
|
||||
public static void main() {
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
newMethod().println("Text");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static PrintStream newMethod() {
|
||||
return System.out;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Test {
|
||||
void method() {
|
||||
System.out.println("1");
|
||||
<selection>{
|
||||
System.out.println("2");
|
||||
System.out.println("3");
|
||||
}</selection>
|
||||
System.out.println("4");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class Test {
|
||||
void method() {
|
||||
System.out.println("1");
|
||||
newMethod();
|
||||
System.out.println("4");
|
||||
}
|
||||
|
||||
private void newMethod() {
|
||||
System.out.println("2");
|
||||
System.out.println("3");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
public class Test {
|
||||
int method() {
|
||||
try {
|
||||
System.out.println("Text");
|
||||
return 0;
|
||||
} finally {
|
||||
<selection>System.out.println("!!!");
|
||||
return 1;</selection>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
public class Test {
|
||||
int method() {
|
||||
try {
|
||||
System.out.println("Text");
|
||||
return 0;
|
||||
} finally {
|
||||
return newMethod();
|
||||
}
|
||||
}
|
||||
|
||||
private int newMethod() {
|
||||
System.out.println("!!!");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
public class S {
|
||||
{
|
||||
String s;
|
||||
try {
|
||||
<selection>s = "";</selection>
|
||||
} finally {
|
||||
}
|
||||
System.out.print(s);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class Tester {
|
||||
String x() {
|
||||
String o = "";
|
||||
<selection>String s;
|
||||
try {
|
||||
s = o;
|
||||
}
|
||||
finally {
|
||||
}
|
||||
return s;</selection>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
class Tester {
|
||||
String x() {
|
||||
String o = "";
|
||||
return newMethod(o);
|
||||
}
|
||||
|
||||
private String newMethod(String o) {
|
||||
String s;
|
||||
try {
|
||||
s = o;
|
||||
}
|
||||
finally {
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
public class S {
|
||||
{
|
||||
String s;
|
||||
try {
|
||||
s = newMethod();
|
||||
} finally {
|
||||
}
|
||||
System.out.print(s);
|
||||
}
|
||||
|
||||
private String newMethod() {
|
||||
String s;
|
||||
s = "";
|
||||
return s;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
{
|
||||
<selection>final int i = 128;</selection>
|
||||
System.out.println("i = " + i);
|
||||
|
||||
final int j = 128;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
class C {
|
||||
{
|
||||
final int i = newMethod();
|
||||
System.out.println("i = " + i);
|
||||
|
||||
final int j = newMethod();
|
||||
}
|
||||
|
||||
private int newMethod() {
|
||||
final int i = 128;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
final String s = "dude";
|
||||
<selection>Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
System.out.println(s);
|
||||
}
|
||||
};
|
||||
new Thread(runnable).start();</selection>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
final String s = "dude";
|
||||
newMethod(s);
|
||||
}
|
||||
|
||||
private static void newMethod(final String s) {
|
||||
Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
System.out.println(s);
|
||||
}
|
||||
};
|
||||
new Thread(runnable).start();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
class Test {
|
||||
void method(){
|
||||
<selection>try {
|
||||
process.waitFor();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
process.destroy();
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
myParsingThread.join();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
}
|
||||
compilerHandler.processTerminated();
|
||||
}
|
||||
synchronized (this) {
|
||||
myParsingThread = null;
|
||||
}</selection>
|
||||
someOtherCode();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
class Test {
|
||||
void method(){
|
||||
newMethod();
|
||||
someOtherCode();
|
||||
}
|
||||
|
||||
private void newMethod() {
|
||||
try {
|
||||
process.waitFor();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
process.destroy();
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
myParsingThread.join();
|
||||
}
|
||||
catch(InterruptedException e) {
|
||||
}
|
||||
compilerHandler.processTerminated();
|
||||
}
|
||||
synchronized (this) {
|
||||
myParsingThread = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Foo {
|
||||
{
|
||||
String[] args = getArgs();
|
||||
|
||||
for(String arg : args) {
|
||||
<selection>System.out.println("arg = " + arg);</selection>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
class Foo {
|
||||
{
|
||||
String[] args = getArgs();
|
||||
|
||||
for(String arg : args) {
|
||||
newMethod(arg);
|
||||
}
|
||||
}
|
||||
|
||||
private void newMethod(String arg) {
|
||||
System.out.println("arg = " + arg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Xtract {
|
||||
void me(int i) {
|
||||
<selection>if (i ==10) {
|
||||
return;
|
||||
}</selection>
|
||||
|
||||
System.out.println("i: " + i);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
class Xtract {
|
||||
void me(int i) {
|
||||
if (newMethod(i)) {
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println("i: " + i);
|
||||
}
|
||||
|
||||
private boolean newMethod(int i) {
|
||||
if (i ==10) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class Test {
|
||||
public final <T> Class<T> findClass(final String className) throws ClassNotFoundException {
|
||||
return (Class<T>)Class.forName(className, true, <selection>getClass().getClassLoader()</selection>);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Test {
|
||||
public final <T> Class<T> findClass(final String className) throws ClassNotFoundException {
|
||||
return (Class<T>)Class.forName(className, true, newMethod());
|
||||
}
|
||||
|
||||
private ClassLoader newMethod() {
|
||||
return getClass().getClassLoader();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
class Test
|
||||
{
|
||||
public Object foo() {
|
||||
Object result = null;
|
||||
<selection>if(test1()) return null;
|
||||
if(test2()) return null;</selection>
|
||||
return result;
|
||||
}
|
||||
public int foo1() {
|
||||
int result = 1;
|
||||
if(test1()) return 0;
|
||||
if(test2()) return 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean test1() {return false;}
|
||||
private boolean test2() {return false;}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
public class Test {
|
||||
public Object foo() {
|
||||
Object result = null; // line1
|
||||
<selection>if (test1()) return result;
|
||||
if (test2()) return result;</selection>
|
||||
if (test3()) return result; // line4
|
||||
return result;
|
||||
}
|
||||
|
||||
public int foo1() {
|
||||
Object result = null; // line1
|
||||
if (test1()) return 1; // ssss
|
||||
if (test2()) return 1; //eee
|
||||
if (test3()) return 2; // line4
|
||||
return 3;
|
||||
}
|
||||
|
||||
private boolean test1() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean test2() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean test3() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
public class Test {
|
||||
public Object foo() {
|
||||
Object result = null; // line1
|
||||
if (newMethod()) return result;
|
||||
if (test3()) return result; // line4
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean newMethod() {
|
||||
Object result;
|
||||
if (test1()) return true;
|
||||
if (test2()) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public int foo1() {
|
||||
Object result = null; // line1
|
||||
if (newMethod()) return 1;
|
||||
if (test3()) return 2; // line4
|
||||
return 3;
|
||||
}
|
||||
|
||||
private boolean test1() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean test2() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean test3() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
class Test
|
||||
{
|
||||
public Object foo() {
|
||||
Object result = null;
|
||||
if (newMethod()) return null;
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean newMethod() {
|
||||
if(test1()) return true;
|
||||
if(test2()) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public int foo1() {
|
||||
int result = 1;
|
||||
if (newMethod()) return 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean test1() {return false;}
|
||||
private boolean test2() {return false;}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class MyClass {
|
||||
public void newMethod(long i) {
|
||||
}
|
||||
{
|
||||
int i = 0;
|
||||
<selection>System.out.println(i);</selection>
|
||||
newMethod(14);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
class MyClass {
|
||||
public void newMethod(long i) {
|
||||
}
|
||||
{
|
||||
int i = 0;
|
||||
newMethod(i);
|
||||
newMethod((long) 14);
|
||||
}
|
||||
|
||||
private void newMethod(int i) {
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class Test {
|
||||
public static String bar(int x , int y) {
|
||||
while (true) {
|
||||
<selection>if (x == y) {
|
||||
continue;
|
||||
}
|
||||
System.out.println("HW");</selection>
|
||||
}
|
||||
}
|
||||
|
||||
private static int g() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
class Test {
|
||||
public static String bar(int x , int y) {
|
||||
while (true) {
|
||||
newMethod(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
private static void newMethod(int x, int y) {
|
||||
if (x == y) {
|
||||
return;
|
||||
}
|
||||
System.out.println("HW");
|
||||
}
|
||||
|
||||
private static int g() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
class Container {
|
||||
static class X {
|
||||
boolean x = false;
|
||||
|
||||
void foo(String s, String t) {
|
||||
<selection>x = true;</selection>
|
||||
|
||||
x = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class Container {
|
||||
static class X {
|
||||
boolean x = false;
|
||||
|
||||
void foo(String s, String t) {
|
||||
newMethod();
|
||||
|
||||
newMethod();
|
||||
}
|
||||
|
||||
private void newMethod() {
|
||||
x = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
class Test {
|
||||
void m(boolean b) {
|
||||
int x = 42;
|
||||
try {
|
||||
<selection>
|
||||
if(b) {
|
||||
x = 23;
|
||||
throw new Exception();
|
||||
}
|
||||
</selection>
|
||||
} catch(Exception e) {
|
||||
System.out.println(x);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
class Test {
|
||||
void m(boolean b) {
|
||||
int x = 42;
|
||||
try {
|
||||
|
||||
x = newMethod(b, x);
|
||||
|
||||
} catch(Exception e) {
|
||||
System.out.println(x);
|
||||
}
|
||||
}
|
||||
|
||||
private int newMethod(boolean b, int x) throws Exception {
|
||||
if(b) {
|
||||
x = 23;
|
||||
throw new Exception();
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class Tester {
|
||||
void method(Object... array) {
|
||||
Object object = null;
|
||||
<selection>array.equals(object);</selection>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Tester {
|
||||
void method(Object... array) {
|
||||
Object object = null;
|
||||
newMethod(object, array);
|
||||
}
|
||||
|
||||
private void newMethod(Object object, Object[] array) {
|
||||
array.equals(object);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class Class1 {
|
||||
public static int staticMethod() {
|
||||
int a = 1;
|
||||
int b = 2;
|
||||
|
||||
int temp = a + b;
|
||||
return temp * 2;
|
||||
}
|
||||
|
||||
public int foo(int a, int b) {
|
||||
<selection>int temp = a + b;
|
||||
return temp * 2;</selection>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
class Class1 {
|
||||
public static int staticMethod() {
|
||||
int a = 1;
|
||||
int b = 2;
|
||||
|
||||
return newMethod(a, b);
|
||||
}
|
||||
|
||||
public int foo(int a, int b) {
|
||||
return newMethod(a, b);
|
||||
}
|
||||
|
||||
private static int newMethod(int a, int b) {
|
||||
int temp = a + b;
|
||||
return temp * 2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
class UUU {
|
||||
int myValue;
|
||||
|
||||
UUU() {
|
||||
System.out.println(<selection>myValue</selection>);
|
||||
}
|
||||
|
||||
void init() {
|
||||
myValue = 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class UUU {
|
||||
int myValue;
|
||||
|
||||
UUU() {
|
||||
System.out.println(newMethod());
|
||||
}
|
||||
|
||||
private int newMethod() {
|
||||
return myValue;
|
||||
}
|
||||
|
||||
void init() {
|
||||
myValue = 0;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user