| Summary: | [templates] generic type proposals | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | thomas menzel <dev.tom.menzel> |
| Component: | Text | Assignee: | JDT-Text-Inbox <jdt-text-inbox> |
| Status: | RESOLVED DUPLICATE | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | ||
| Version: | 3.1 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
i often use templates and have created quite a bunch myself to speed up coding for stuff i often use. i'd find a generic way to ask for a proposal of a certain type to be very helpful. case 1: i have the following template for "ifn" if( ${var} == null) { } now i'd like To have a proper proposal for $(var) that could be any object and hence i'd like to spec smth. like this: if( ${proposal:java.lang.Object} == null) { } the alg. to find the proposal could just be the same for filling in proposals for methods when expanding them with ctrl-shift, which i think takes the most recent variable of the requested type/class. the format of the variable is then ${proposal:<type>}. for the primitives we just could do long, int, char, ... i dont know if that format is possible or if its possible at all to have parameters for a template variable. it'd be nice though another example: iteration over a map for (Iterator ${iterator} = ${proposal:java.util.Map}.entrySet().iterator(); ${iterator}.hasNext(); ) { Map.Entry me = (Map.Entry) iter.next(); ${keyType} key = (${keyType}) me.getKey(); ${valType} val = (${valType}) me.getValue(); ${cursor} } no this case is still ok and not much or difficult for java 1.4 but it will get difficult as it touches the ground of generics and i have no clue how to handly in such situations the proposals as you have 3 other types that will depend on the generics of the Map being chosen. but we all like challanges! right?