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 138100 - Imports not added when QualIdents are resolved
Summary: Imports not added when QualIdents are resolved
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 6.x
Hardware: PC Windows Vista
: P2 blocker (vote)
Assignee: Jan Lahoda
URL:
Keywords: RANDOM
Depends on:
Blocks:
 
Reported: 2008-06-24 15:19 UTC by Jan Stola
Modified: 2008-07-30 09:08 UTC (History)
1 user (show)

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 Stola 2008-06-24 15:19:48 UTC
QualIdents are sometimes replaced by simple names, but the corresponding imports are not added. This makes the code 
uncompilable.

Steps to reproduce:
1. Create new JFrame.
2. Add JLabel into the frame.
3. Select the root node in the Inspector.
4. Un-check Generate Full Classnames in the Properties window.
5. Switch to Source view
   => GroupLayout, WindowConstants and JLabel were replaced by simple names, but only one import (for JLabel) was added

The corresponding code (in form/src/org/netbeans/modules/form/FQNImporter.java) uses several invocations of 
WorkingCopy.rewrite() in one task. It seems that only imports from the last rewrite are added e.g. it works well when 
just one rewrite is invoked.
Comment 1 Jan Stola 2008-06-24 15:54:49 UTC
I just realized that the provided steps do not lead to the problem every time. There seem to be some race conditions. 
The general advice is to reproduce this issue is:

1. Un-check Generate Full Classnames for some form (as described above).
2. Add some components that are not on the form already.
3. Switch to Source and check whether there are some errors.

I am not able to provide a 100% reliable test-case, but these instructions lead to the problem pretty quickly.
Comment 2 Jan Lahoda 2008-07-12 13:51:19 UTC
Should be OK now:
http://hg.netbeans.org/main?cmd=changeset;node=6c4e99f48e9f
Comment 3 Quality Engineering 2008-07-17 04:39:15 UTC
Integrated into 'main-golden', available in NB_Trunk_Production #324 build
Changeset: http://hg.netbeans.org/main/rev/6c4e99f48e9f
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #138100: imports clauses might not be added correctly for several independent QualIdents.
Comment 4 Jan Stola 2008-07-30 08:58:13 UTC
To jiriprox: Just curious, why do you think that this issue is important for NB 6.1 patch? The use-case described in 
the issue is not possible in NB 6.1 - there's no Generate Full Classnames in NB 6.1. While I understand that the fix 
provided by jlahoda can help in other cases as well it would be IHMO a good idea to provide such a use-case as a 
justification for inclusion in the patch.
Comment 5 Jiri Prox 2008-07-30 09:08:11 UTC
I see, thanks. I didn't noticed it's 6.5 specific. As far as I know there are no other similar problems reported ->
removing patch candidate status