Summary: | Javadoc of PackageDeclaration is null | ||||||
---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | julien <yang_ying_min> | ||||
Component: | Core | Assignee: | Frederic Fusier <frederic_fusier> | ||||
Status: | RESOLVED INVALID | QA Contact: | |||||
Severity: | critical | ||||||
Priority: | P3 | CC: | markus.kell.r | ||||
Version: | 3.1 | ||||||
Target Milestone: | 3.1 M7 | ||||||
Hardware: | PC | ||||||
OS: | Windows XP | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
julien
2005-05-04 19:16:33 EDT
Which build are you using? If this is 3.1 M6, could you make a try with a more recent integration build (I20050506-1600) or 3.1 M7 next week and confirm that your bug is a duplicate of bug 83804? Thanks I was 3.1M6. I just tested the build I20050506-1600. The javaDoc in PackageDeclaration of CompilationUnit is always null. I cannot reproduce your problem. PackageDeclaration javadoc of package-info.java CompilationUnit is always not null when there's a javadoc comment specified before package declaration: /** * Javadoc for all package * @see Object Root class */ package test.packageInfo; I'll add a snapshot to show this using ASTView... Can you provide a detailed test case to help to understand what happen there? Created attachment 20802 [details]
Snapshot of a sample
Using ASTView, you can see that PackageDeclaration Javadoc is not null and that
its hierachy match comment contents...
Here is my code: ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setSource("/**\n * test\n */package test;".toCharArray ()); CompilationUnit unit = (CompilationUnit) parser.createAST (null); PackageDeclaration packageDeclaration = unit.getPackage(); System.out.println(packageDeclaration.getJavadoc()); I get null in starndard output Javadoc is only set for package-info.java compilation unit and if you compile it with 1.5 source level. So, to make your example working, you need to modify your code as follow: ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setSource("/**\n * test\n */package test;".toCharArray()); // CU need to have package-info name parser.setUnitName("package-info"); // CU need to be parsed with 1.5 source level Hashtable options = JavaCore.getOptions(); options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); parser.setCompilerOptions(options); CompilationUnit unit = (CompilationUnit) parser.createAST(null); PackageDeclaration packageDeclaration = unit.getPackage(); System.out.println(packageDeclaration.getJavadoc()); > Javadoc is only set for package-info.java compilation unit and if you compile
> it with 1.5 source level.
That's not true. It it were so, it should have been documented in
PackageDeclaration#getJavadoc(). But the JLS3 AST for the example below contains
the Javadoc header in I20050509-2010.
/*******************************************************************************
* Header
******************************************************************************/
package xy;
public class Try { }
Yes, you're right. Only source level 1.5 is necessary to get javadoc in package declaration. The difference is that references in javadoc are resolved only for package-info.java compilation unit as javadoc.exe done. I posted a message on news group to julien's thread but didn't update this bug. Thanks to have done it :-) |