This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 180328 - "Encapsulate Fields" wizard adds method definition into wrong place
Summary: "Encapsulate Fields" wizard adds method definition into wrong place
Status: RESOLVED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: PC Linux
: P3 normal (vote)
Assignee: Vladimir Voskresensky
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-05 04:19 UTC by soldatov
Modified: 2011-02-06 16:16 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description soldatov 2010-02-05 04:19:48 UTC
Scenario:
- Create Quote project
- Open customer.h file
- Call "Refactor|Encapsulate Fields" context menu in Customer class
- Press "Select Setters" button
- Select "Last Method" in "Insert Point" combobox
- Press "Refactor" button
- Open customer.cc file
==>

#include "customer.h"

Customer::Customer(const string initName, int initDiscount) :
    name(initName),
    discount(initDiscount) {
}

int Customer::GetDiscount() const {
    return discount;
}
void Customer::SetDiscount(int discount) {
    this->discount = discount;
}
void Customer::SetName(string name) {
    this->name = name;
}

string Customer::GetName() const {
    return name;
}

ostream& operator <<(ostream& output, const Customer& customer) {
    output << customer.name << " has discount " << customer.discount << '%';
    return output;
}
Comment 1 Vladimir Voskresensky 2010-02-05 19:17:47 UTC
I'm lost what is expected here :-)
setter were inserted in header after GetDiscount() => in cpp they were tried to be inserted after the same function.
Comment 2 soldatov 2010-02-08 03:40:28 UTC
Ok. Other sample.

Source files in project
====== main.cpp ============
#include "class1.hpp"

int main() {
  Class1 c1;
  c1.method1(1);
  return 0;
}

====== class1.cpp ============

#include "class1.hpp"

Class1::Class1() {

}

void Class1::method1(int a) {
    i = a;
    return;
}

void Class1::method2(int a) {
    j = a;
    return;
}

void Class1::method3() {
    return;
}

====== class1.hpp ============

class Class1 {
public:
    Class1();
    void method1(int a);
    void method2(int a);
private:
    void method3();
    int i;
    int j;
};

=============================

Scenario:
- Call "Refactor|Encapsulate Fields" context menu in Class1 class
- Press "Select All" button
- Select "After method3(): void" in "Insert Point" combobox
- Press "Refactor" button
==> expected result:

====== class1.cpp ============

void Class1::method3() {
    return;
}
<-- new getters and setters should be added

====== class1.hpp ============

private:
    void method3();
    <-- new getters and setters should be added
    int i;
    int j;
=============================
Comment 3 Vladimir Voskresensky 2011-02-06 16:16:37 UTC
fixed:
http://hg.netbeans.org/cnd-main/rev/87faa112f42a