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 227566 - Patch for: Code completion should propose singular variable names
Summary: Patch for: Code completion should propose singular variable names
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.3
Hardware: PC Windows 7
: P3 normal with 1 vote (vote)
Assignee: Dusan Balek
URL:
Keywords: PATCH_AVAILABLE
Depends on:
Blocks:
 
Reported: 2013-03-16 22:59 UTC by markiewb
Modified: 2014-07-17 02:18 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


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.