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 231133

Summary: Change The Hint Order Of Unknown Variables
Product: java Reporter: abien <abien>
Component: HintsAssignee: markiewb
Status: RESOLVED FIXED    
Severity: normal CC: markiewb, sdedic
Priority: P3 Keywords: PATCH_AVAILABLE
Version: 7.4   
Hardware: Macintosh   
OS: Mac OS X   
Issue Type: ENHANCEMENT Exception Reporter:
Attachments: Proposed patch
Patch in action

Description abien 2013-06-12 12:10:52 UTC
Product Version = NetBeans IDE Dev (Build 201306100004)
Operating System = Mac OS X version 10.8.4 running on x86_64
Java; VM; Vendor = 1.7.0_21
Runtime = Java HotSpot(TM) 64-Bit Server VM 23.21-b01

Usually I write code like:

        this.name = "hugo";

then press alt-enter and use NB for the creation of fields (=less typing).

However NB suggests "Search Dependency at Maven Repositories" first, then create field. I would like to change the order of the hints, because it is more likely to choose the "create field". Then one could just press alt+enter then enter without hitting the down button.
Comment 1 markiewb 2013-11-16 13:01:14 UTC
@Svata: Could be solved via https://netbeans.org/bugzilla/show_bug.cgi?id=125577
Comment 2 markiewb 2014-04-02 17:42:36 UTC
Created attachment 146510 [details]
Proposed patch

@Svata: I like to propose a patch to solve this issue.

Hints can be sorted by implementing EnhancedFix#getSortText().
See its usage at org.netbeans.modules.editor.hints.FixData.getSortText(org.netbeans.spi.editor.hints.Fix):java.lang.CharSequence

a) So I updated AddParameterOrLocalFix and CreateFieldFix to implement EnhancedFix.

b) I also introduced a new default ordering with hackish "hardcoded prefix string" approach.
* create local variable
* create field
* create parameter

If you do not want the ordering of the "create XXX" fixes (because [1] will be implemented soon?) then simply return getText() in getSortText().

[1] https://netbeans.org/bugzilla/show_bug.cgi?id=125577
Comment 3 markiewb 2014-04-02 17:43:24 UTC
Created attachment 146511 [details]
Patch in action
Comment 4 Svata Dedic 2014-04-11 13:34:22 UTC
I think that #125577 is not a good solution here, as the parameter/field/variable decision highly depends on the exact context and may vary. Using ranking is a good choice for fix alternatives, which respect different code styles.

IMHO the fixes should be grouped into scope groups (local text fixes, environment fixes (like imports), project fixes, hint configuration), then maybe even more grouped so the infrastructure gets a clue what are really alternatives.

Integrated as jet-main#f4404bba495a; 
Thanks, markiewb :)
Comment 5 Quality Engineering 2014-04-24 02:11:10 UTC
Integrated into 'main-silver', will be available in build *201404240001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/f4404bba495a
User: Svata Dedic <sdedic@netbeans.org>
Log: #231133: increased priority of create* fixes over imports