Bug 98429 - [templates] update template for 'for' to Java 5.0
Summary: [templates] update template for 'for' to Java 5.0
Status: RESOLVED DUPLICATE of bug 102747
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.1   Edit
Hardware: PC All
: P3 trivial (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-04 21:17 EDT by Hendrik Maryns CLA
Modified: 2006-01-20 12:43 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hendrik Maryns CLA 2005-06-04 21:17:16 EDT
The template for "for" in 3.1 is now 

for (Iterator iter = collection.iterator(); iter.hasNext();) {
    type element = (type) iter.next();
};

This should be 

for (Iterator<type> iter = collection.iterator(); iter.hasNext();) {
    type element = iter.next();
};

at least when switched to 5.0 compatibility
Comment 1 Dani Megert CLA 2005-06-05 08:41:54 EDT

*** This bug has been marked as a duplicate of 95787 ***
Comment 2 Hendrik Maryns CLA 2005-06-05 09:16:51 EDT
I don't see why this would be a duplicate of bug 95787; it is exactly the
opposite suggestion!  
I could imagine there to be duplicate templates, with a mention as to to which
JDK level they apply, but merely as a temporary solution.
Comment 3 Dani Megert CLA 2005-06-05 15:45:37 EDT
The point is that we need to enhance the template infrastructure with the
additional info like the Java SDK level. Once this is in place both requests can
be resolved.
Comment 4 Tom Hofmann CLA 2005-06-06 05:11:27 EDT
We do know the source level once a template is being applied. Only the content
assistant / template engine collecting the proposals does not know about it.
When resolving a template (happens when it gets applied or the additional info
computed), we know the CU. 

However, the current for-template would have to be changed to be something like
this:

for (Iterator${typespec} ${iterator} = ${collection}.iterator();
${iterator}.hasNext(); ) {
	${type} ${element} = ${typecast}${iterator}.next();
	${cursor}
}

Note the new variable types 'typespec' and 'typecast'. ${typespec} would resolve
to the empty string when in a 1.4 project, while ${typecast} would resolve to
the empty string in a 1.5 project.

Additionally, the ${type} variable would have to be resolved in a 1.5 project.

No action for 3.1 as it is far more common to use the new for loop template
here. The old template would only make sense where one wants to call the
Iterator.remove() method.
Comment 5 Tom Hofmann CLA 2006-01-20 12:43:27 EST
bug 102747 is really a dup of this one but is targeted for 3.2 - marking this bug as a dup.

*** This bug has been marked as a duplicate of 102747 ***