Bug 250719 - [templates] Text selection as substitute for ${iterable}
Summary: [templates] Text selection as substitute for ${iterable}
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.4.1   Edit
Hardware: All All
: P5 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2008-10-14 02:51 EDT by Matt Whitlock CLA
Modified: 2008-10-14 03:10 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 Matt Whitlock CLA 2008-10-14 02:51:47 EDT
If the current text selection is an expression that evaluates to an Iterable or array, then any templates containing ${iterable} (for example, the 'foreach' template) should be offered when the templates content assist is invoked.

Example:

void printMappings(Map<?, ?> map) {
    map.entrySet()
}

When the expression 'map.entrySet()' is highlighted and Ctrl+Space is pressed twice, the 'foreach' template should be offered.

When invoked, the 'foreach' template would alter the code thusly:

void printMappings(Map<?, ?> map) {
    for ([Entry<?, ?>] [entry] : map.entrySet()) {
        |
    }
}

The square brackets denote editable template fields, and the pipe character denotes the final cursor position when the template mode is exited cleanly.

It would be nice if the element type field would still have the drop-down list giving a choice among the possible assignable types.  If this enhancement request is implemented correctly, I think it would already do this "for free."