Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 350335 - [qf] Create local variable quick fix looses comments and distorts unrelated code
Summary: [qf] Create local variable quick fix looses comments and distorts unrelated code
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-refactoring (show other bugs)
Version: 8.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 8.1.0   Edit
Assignee: Sergey Prigogin CLA
QA Contact: Sergey Prigogin CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-24 19:36 EDT by Sergey Prigogin CLA
Modified: 2012-02-23 11:33 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.