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 68719 - [code_template] CT does not add necessary imports
Summary: [code_template] CT does not add necessary imports
Status: VERIFIED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker with 1 vote (vote)
Assignee: Daniel Prusa
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-15 10:43 UTC by Jan Pokorsky
Modified: 2007-11-05 13:44 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Pokorsky 2005-11-15 10:43:39 UTC
The code template forc does not add import of Iterator to the source file. The
result is broken source file.
Comment 1 Daniel Prusa 2005-11-23 16:50:01 UTC
Fixed in trunk.

/cvs/java/editor/lib/src/org/netbeans/editor/ext/java/JavaSettingsDefaults.java
new revision: 1.12; previous revision: 1.11

/cvs/java/editor/src/org/netbeans/modules/java/editor/codetemplates/JavaCodeTemplateProcessor.java
new revision: 1.7; previous revision: 1.6
Comment 2 Jan Pokorsky 2005-11-24 16:29:40 UTC
In case the Iterator is not imported before typing forc the collection is
wrongly resolved. Have the following code

        List l;

and try forc template. You get

        for (Iterator it = collection.iterator(); it.hasNext();) {
                           ^^^^^^^^^^
            Object elem = (Object) it.next();
            
        }

In case the Iterotor IS imported everything works as expected

        for (Iterator it = l.iterator(); it.hasNext();) {
            Object elem = (Object) it.next();
            
        }
Comment 3 Daniel Prusa 2005-11-28 12:56:22 UTC
Order of actions taken during processing a code template was bad. Imports are
required to be add after all needed information is retrieved from jmi model
(including variable names).
Should be fixed now.

/cvs/java/editor/src/org/netbeans/modules/java/editor/codetemplates/JavaCodeTemplateProcessor.java

new revision: 1.8; previous revision: 1.7
Comment 4 Jan Pokorsky 2005-12-01 15:27:32 UTC
verified