Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 227566 - Patch for: Code completion should propose singular variable names
Patch for: Code completion should propose singular variable names
Status: RESOLVED FIXED
Product: java
Classification: Unclassified
Component: Editor
7.3
PC Windows 7
: P3 with 1 vote (vote)
: 8.0.1
Assigned To: Dusan Balek
issues@java
netfix801
: PATCH_AVAILABLE
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-03-16 22:59 UTC by markiewb
Modified: 2014-07-17 02:18 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
:


Attachments
Shows the current state, only proposes "s" and "string" (3.15 KB, image/png)
2013-03-16 22:59 UTC, markiewb
Details
Patch draft (6.02 KB, patch)
2013-11-30 19:50 UTC, markiewb
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description markiewb 2013-03-16 22:59:53 UTC
Created attachment 132693 [details]
Shows the current state, only proposes "s" and "string"

<code>
	List<String> projects = new ArrayList<String>();
	for (String | : projects) { // | defines the current caret
	    
	}
</code>
Code complete at the given caret...

ACTUAL: code completion suggests "s" or "string"
EXPECTED: code completion suggests "project" (and the old ones "s" or "string")

<code>

	List<String> projects = new ArrayList<String>();
	for (String project : projects) { 
	    
	}
</code>

Please suggest the singular form for the variable name when iterating on a variable which looks like a plural form

For example:

XXXs-> XXX:
projects -> project
items -> item
strings -> string
actions -> action
...

XXXies->XXXy:
entries -> entry
tries -> try

IMHO: This addition would make the code completion even more useful and the CC looks more intelligent. You do not have to implement all the grammatically specifics of the English language, IMHO these two cases are sufficient in most cases.
Comment 1 markiewb 2013-11-30 19:50:46 UTC
Created attachment 142750 [details]
Patch draft

@Dusan: Please review the proposed patch. Please note that is only a draft - no code cleanup yet.

But it works in my manual tests.

Create and use a new code template with includes the newly introduced "iterableElementVarName"

for (${TYPE iterableElementType default="Object" editable=false} ${ELEM iterableElementVarName default="elem"} : ${ITER iterable default="col"}) {
${selection}${cursor}
}

I like to get your feedback. Thank you in advance!
Comment 2 markiewb 2014-07-09 21:50:24 UTC
@Dusan: Please review the patch
Comment 3 Dusan Balek 2014-07-10 08:00:13 UTC
More general fix created. Should cover also the following cases:

for(int i = 0; i < args.length; i++) {
    String | = args[i];
} ==> arg

String | = getProjectName(); ==> projectName

Fixed in jet-main. 

http://hg.netbeans.org/jet-main/rev/e0a2163c3e03
Comment 4 Quality Engineering 2014-07-17 02:18:01 UTC
Integrated into 'main-silver', will be available in build *201407170001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/e0a2163c3e03
User: Dusan Balek <dbalek@netbeans.org>
Log: Issue #227566: Code completion should propose singular variable names - fixed.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo