Bug 23054

Summary: DOM - TypeDeclaration.getJavadoc() can find incorrect javadoc
Product: [Eclipse Project] JDT Reporter: mark_dixon
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: akiezun, daschneider
Version: 2.0   
Target Milestone: 2.1 M1   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description mark_dixon CLA 2002-08-30 16:37:17 EDT
Running 200208270833

This code
IWorkspace ws = testcasesPlugin.getWorkspace();
IWorkspaceRoot root = ws.getRoot();
IProject project = root.getProjects()[0];
IJavaProject jp = JavaCore.create(project);
		
CompilationUnit cu = AST.parseCompilationUnit(
   "public class Class {/** Method theMethod.*/ void theMethod()  
{} }".toCharArray(),
   "Class", jp);
cu.accept(new ASTVisitor() {
   public boolean visit(TypeDeclaration node) {
      Javadoc doc = node.getJavadoc();
      // Javadoc must start before the type name!
      if (node.getName().getStartPosition() < doc.getStartPosition()) {
         System.out.println("Incorrect javadoc associated with type");
      }
      return true;
   }
});

produces
Incorrect javadoc associated with type

The problem is that ASTConverter.setJavaDocComment finds the *first* javadoc in 
the type - if the type doesn't have javadoc but a member does then that'll be 
returned as the type's doc.  I think ASTConverter.setJavaDocComment should stop 
searching for javadoc once it finds a token other than a comment or whitespace.

Thanks
Mark
Comment 1 Olivier Thomann CLA 2002-09-04 13:41:07 EDT
Thank you for all your nice reports.
Fixed and released in 2.1 stream.
Comment 2 Olivier Thomann CLA 2002-09-06 10:06:51 EDT
*** Bug 23264 has been marked as a duplicate of this bug. ***
Comment 3 David Audel CLA 2002-09-19 04:46:46 EDT
Verified.
Comment 4 Olivier Thomann CLA 2002-09-19 11:04:54 EDT
Regression test added (test0381)
Comment 5 Olivier Thomann CLA 2003-02-28 12:45:51 EST
Backported to 2.0.x stream.
Regression test added in 2.0.x stream.
Comment 6 Olivier Thomann CLA 2003-02-28 12:47:08 EST
*** Bug 31626 has been marked as a duplicate of this bug. ***