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 255214

Summary: [81cat] Inconsistent behavior od generate getter/setter
Product: java Reporter: muellermi <muellermi>
Component: RefactoringAssignee: Ralph Ruijs <ralphbenjamin>
Status: RESOLVED FIXED    
Severity: normal CC: dbalek, ralphbenjamin, sdedic
Priority: P3 Keywords: API_REVIEW_FAST
Version: 8.1   
Hardware: PC   
OS: Windows 7   
Issue Type: DEFECT Exception Reporter:
Attachments: IDE log
Proposed API change
Proposed Impl
Proposed API change v2

Description muellermi 2015-09-11 12:15:43 UTC
Product Version = NetBeans IDE 8.1 dev (Build 201509100002)
Operating System = Windows 7 version 6.1 running on amd64
Java; VM; Vendor = 1.8.0_60
Runtime = Java HotSpot(TM) 64-Bit Server VM 25.60-b23

a class containing code like this

[omitted imports, class etc]

int myVar;

<some other code>

Now place the caret / cursor onto myVar and invoke Alt+Inst (insert code)
tick myVar and choose create getter/setter

NetBeans creates getter and setter methods below myVar and above <some other code>

Undo these changes (revert code to get it as listed above)

Now place the caret / cursor onto myVar and invoke Alt+Inst (insert code)
tick myVar, tick "encapulate fields" and choose create getter/setter

NetBeans creates getter and setter methods below <some other code>

--> NetBeans should always insert code at the same position, which might correlate to the posistion the user has last choosen on refactor, encapsulate field.
Comment 1 muellermi 2015-09-11 12:15:49 UTC
Created attachment 156095 [details]
IDE log
Comment 2 Jiri Kovalsky 2015-09-11 14:20:48 UTC
Reassigned for further evaluation.
Comment 3 Dusan Balek 2015-09-15 08:23:38 UTC
EncapsulateFieldRefactoringPlugin should respect 'CodeStyle.getClassMemberInsertionPoint() == CodeStyle.InsertionPoint.CARET_LOCATION' when inserting getters and setters.
Comment 4 Ralph Ruijs 2015-09-21 09:06:22 UTC
Created attachment 156313 [details]
Proposed API change
Comment 5 Ralph Ruijs 2015-09-21 09:07:11 UTC
Created attachment 156314 [details]
Proposed Impl
Comment 6 Ralph Ruijs 2015-09-21 09:09:31 UTC
Please review attached API change. Thanks!
Comment 7 Svata Dedic 2015-09-21 09:13:59 UTC
Please do not introduce dependency on editor.lib in java.source.base; it would break Tailwind project.

Instead of directly using GuardedDocument, please use DocumentGuards API (or extend it as necessary); see for example GeneratorUtilities::insertClassMember
Comment 8 Ralph Ruijs 2015-09-21 10:48:12 UTC
Created attachment 156316 [details]
Proposed API change v2

S1 - The added dependency is removed and impl is updated
Comment 9 Ralph Ruijs 2015-10-05 09:17:59 UTC
changeset:   9843a2c01921
user:        Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org>
date:        Mon Oct 05 11:16:51 2015 +0200
summary:     #255214 - [81cat] Inconsistent behavior od generate getter/setter
Comment 10 Quality Engineering 2015-10-06 01:23:24 UTC
Integrated into 'main-silver', will be available in build *201510060002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/9843a2c01921
User: Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org>
Log: #255214 - [81cat] Inconsistent behavior od generate getter/setter