Summary: | [javadoc] Wrong warning of unused import for reference in Javadoc | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Koen van Dijken <koen.van.dijken> |
Component: | Core | Assignee: | Frederic Fusier <frederic_fusier> |
Status: | VERIFIED WORKSFORME | QA Contact: | |
Severity: | normal | ||
Priority: | P5 | CC: | b.michael, benno.baumgartner, daniel_megert, dev, gnu_andrew, joerg, kent_johnson, martinae, mauromol, Olivier_Thomann |
Version: | 3.3 | Keywords: | helpwanted |
Target Milestone: | 3.7 M5 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Koen van Dijken
2007-08-01 07:15:54 EDT
Think this bug is mis-classified. It is not an ALF bug The problem is in the compiler warning. The import 'import test.A.A2;' is required, otherwise the Javadoc tool can not find the reference to 'A2' (A2 is only visible inside the classbody of B, not outside) package test; import test.A.A2; // import marked as unused, but is required /** * {@link A2} * @author koen * */ public class B implements A { public void doIt(A2 a2) { } } package test; public interface A { interface A2 { } void doIt(A2 a2); } Problem comes from JavadocSingleTypeReference.internalResolveType(Scope). The given scope is a class scope on type 'B' which implements A => while resolving the reference, the need of import is not stored hence the final incorrect 'unused import' warning... I pretty sure that A2 is found thru inheritance so the import is not needed. To test this, remove the import and run the Javadoc command. You will get an error that 'A2' can not be resolved. Martin, please try this example with A & B defined in the default package. I'm seeing an error on the generated import As for the visibility of A2 to the Javadoc tool - isn't it resolved in the context of B? Its attached to B so it should see the hierarchy of B. Does it use the classScope for B or not? When I remove the import, I do not get any errors/warnings AND can still hover over the link to A2 to see the correct type. So without the import, what isn't supposed to work? Kent, file a new bug with the default package, if this is of importance (default package is always a corner case). The Javadoc tool has it's own special rules with resolving. What we want is that the Eclipse compiler emits the same warnings as the Javadoc tool. I'm also seeing a similar problem when using ecj (Eclipse Java Compiler 0.671, 3.2.0 release in this case but sounds like it still exists in 3.3) separately to compile GNU Classpath. The compiler generates a lot of unused import warnings for imports that are actually used solely by the Javadoc in a particular class (and thus should not be removed). I see a similar issue as well. Imports that are there just for the benefit of the Javadoc tool do not show up in the Problems view of Eclipse 3.3 during development, but they are generated when using PDE to do a headless build of an RCP application. Ownership has changed for the javadoc comments bugs, but I surely will not have enough time to fix your bug during the 3.5 development process, hence set its priority to P5. Please provide a patch if you definitely need the bug to be fixed in this version and I'll have a look at it... TIA This looks like a duplicate of bug #128661. Using 3.6 this works as expected: if Javadoc processing is enabled an import inserted since it is needed to correctly generate the Javadoc. If Javadoc processing is disabled, then no import is added. Verified. |