Bug 518619 - [quick assist] Enhanced for loop's loop variable name should take getters into account
Summary: [quick assist] Enhanced for loop's loop variable name should take getters int...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.7   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-22 05:25 EDT by Andreas Sewe CLA
Modified: 2017-06-22 06:31 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Sewe CLA 2017-06-22 05:25:51 EDT
The "Create enhanced 'for' loop" quick fix is ATM less smart than its "Assign statement to local variable" cousin.

A real life example:

  classHierarchy.getUnresolvedClasses();

    - Assign statement to local variable ->

  Set<TypeReference> unresolvedClasses = classHierarchy.getUnresolvedClasses();

This is great. But this could be better:

  classHierarchy.getUnresolvedClasses();

    - Create enhanced 'for' loop ->

  for (TypeReference typeReference : classHierarchy.getUnresolvedClasses()) {
  }

I realize, of course, that the latter requires some heuristics to convert the plural "UnresolvedClasses" into the singular "unresolvedClass", but covering 95% of the cases in English should be possible (just a gut feeling, though).