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 229684

Summary: Patch for: [Create Field hint] show fieldname in hint label
Product: java Reporter: markiewb
Component: HintsAssignee: markiewb
Status: RESOLVED FIXED    
Severity: normal CC: sdedic
Priority: P3 Keywords: PATCH_AVAILABLE
Version: 7.4   
Hardware: PC   
OS: Windows 7   
Issue Type: ENHANCEMENT Exception Reporter:
Attachments: Proposed patch
Patch in action

Description markiewb 2013-05-13 21:40:56 UTC
The "Create Field" hint should display the field name too.

Example A)
----------
public class NewClass { 
    public NewClass(String a|, String b, String c ) {
    }
}

Note: | defines the current position of the caret

* invoke fix code, all suitable hints are displayed
ACTUAL:   hint with label "Create Field" is shown
EXPECTED: hint with label "Create Field 'a'" is shown

Example B)
----------
public class NewClass { 
    private final String a;
    public NewClass(String a|, String b, String c ) {
    }
}

Note: | defines the current position of the caret

* invoke fix code, all suitable hints are displayed
ACTUAL:   hint with label "Assign to Existing Field" is shown
EXPECTED: hint with label "Assign to Existing Field 'a'" is shown
Comment 1 markiewb 2013-05-13 21:43:55 UTC
Created attachment 134396 [details]
Proposed patch

I like to propose a patch to solve the issue. It shows the fieldname in the label of the hint. See the screenshot (to be attached)

@Jan: Please review and commit, if appropriate. Thank you!
Comment 2 markiewb 2013-05-13 21:45:16 UTC
Created attachment 134397 [details]
Patch in action
Comment 3 markiewb 2013-05-13 21:52:53 UTC
@Jan: If you like/you have time, you could also add the target class in the label too and thus resolve https://netbeans.org/bugzilla/show_bug.cgi?id=135962 ?!
Comment 4 Jan Lahoda 2013-06-01 20:04:00 UTC
Looks good, thanks, except I don't think the "if (treePath.getLeaf().getKind() == Kind.VARIABLE)" is needed - treePath.getLeaf() is already casted to VariableTree before, and a local variable exists for it ("var"). I can simplify the patch for you, if you wish.

I am also thinking if the warning message should not be dropped (the warning messages for suggestions are typically only confusing to users), but that does not need to be decided/resolved here.
Comment 5 markiewb 2013-06-01 20:55:24 UTC
(In reply to comment #4)
> Looks good, thanks, except I don't think the "if (treePath.getLeaf().getKind()
> == Kind.VARIABLE)" is needed - treePath.getLeaf() is already casted to
> VariableTree before, and a local variable exists for it ("var"). I can simplify
> the patch for you, if you wish.
> 
> I am also thinking if the warning message should not be dropped (the warning
> messages for suggestions are typically only confusing to users), but that does
> not need to be decided/resolved here.

Hi Jan. Feel free to change the patch as you need/like. The visible result is more important for me - not the tiny details. If you want me to provide a more suitable patch then tell me and i will provide it...
Comment 6 markiewb 2014-07-09 21:55:10 UTC
@Svata: Please review the patch
Comment 7 Svata Dedic 2014-07-17 12:00:27 UTC
Patch applied as jet-main#a2295e25a223
(minor polishing).
Comment 8 markiewb 2014-07-26 10:23:49 UTC
@Dusan: Not yet integrated? I cannot see the issue fixed in Product Version: NetBeans IDE Dev (Build 201407260001)
Comment 9 Quality Engineering 2014-07-30 02:33:50 UTC
Integrated into 'main-silver', will be available in build *201407300001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/a2295e25a223
User: Svata Dedic <sdedic@netbeans.org>
Log: #229684: field names displayed in hint label (patch by Markiweb)