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

Bug 350335

Summary: [qf] Create local variable quick fix looses comments and distorts unrelated code
Product: [Tools] CDT Reporter: Sergey Prigogin <eclipse.sprigogin>
Component: cdt-refactoringAssignee: Sergey Prigogin <eclipse.sprigogin>
Status: RESOLVED FIXED QA Contact: Sergey Prigogin <eclipse.sprigogin>
Severity: normal    
Priority: P3 CC: cdtdoug, kosashi, yevshif
Version: 8.0   
Target Milestone: 8.1.0   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Sergey Prigogin CLA 2011-06-24 19:36:15 EDT
In the following code create local variable for 'warning'.

bool h;
bool r;

void DemoFunction() {
  int errors = 0;

  // long if
  if (h) {
    printf("h\n");
  } else if (r) {
    printf("r\n");
  } else {
    printf("<none>\n");
  }

  // print comment
  printf("errors: %d, warnings: %d\n", errors, warnings);
}

The result is:

bool h;
bool r;

void DemoFunction() {
  int errors = 0;
    if(h){
        printf("h\n");
    }else
        if(r){
            printf("r\n");
        }else{
            printf("<none>\n");
        }

    int warnings;
  printf("errors: %d, warnings: %d\n", errors, warnings);
}

Comments should be preserved. Code above the declaration insertion point should be left intact.
Comment 1 Sergey Prigogin CLA 2011-12-14 16:20:50 EST
Fixed together with bug 363244.