Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 572240

Summary: Lost code after "Pull down common code from if/else statement" clean up
Product: [Eclipse Project] JDT Reporter: Dennis <hkdennis2k+eclipse>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: critical    
Priority: P3    
Version: 4.19   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Dennis CLA 2021-03-23 23:09:34 EDT
It is a private project and I cannot share code.
But In same case, that rule could result in deleted wrong code.


Given:

```java
if( a < CONST){
   foo.bar();
   foo.foo();
   //many lines
   line1358();
   foobar.clear();
   foobar.add(x);
   something.setVisible(true);
} else {
   if ( a >= Math.abs(CONST) ) {
      // something 
   }
   // more code here
   line1393();
   foobar.clear();
   foobar.add(x);
   something.setVisible(true);
}
```

Expected:
```java
if( a < CONST){
   foo.bar();
   foo.foo();
   //many lines
   line1358();
} else {
   if ( a >= Math.abs(CONST) ) {
      // something 
   }
   // more code here
   line1393();
}
foobar.clear();
foobar.add(x);
something.setVisible(true);
```


Actual:
```java
if( a < CONST){
   foo.bar();
   foo.foo();
   //many lines
   line1358();
} else {
   if ( a >= Math.abs(CONST) ) {
      // something 
   }
   // more code here
   line1393();
}
```
Comment 1 Dennis CLA 2021-03-23 23:24:05 EDT

*** This bug has been marked as a duplicate of bug 571809 ***