Bug 14386 Wrong Javadoc insertion in Editor
Testet with: Eclipse 2.0 (pre-release) Build 20020416 I played with the "Add Javadoc comment" feature and found the following bug. Using this source as the correct starting point: ----------------- test code: package test; /** * @author MH * * To change this generated comment edit the template variable "typecomment": * Window>Preferences>Java>Templates. */ public class HelloWorld { /** * Method main. * @param args */ public static void main(String[] args) { System.out.println("args = " + args); System.out.println("line 2 ..."); } } /** * @author MH * * To change this generated comment edit the template variable "typecomment": * Window>Preferences>Java>Templates. */ class SecondClass { public SecondClass { }//constructor private void doIt() { //bla } }//SecondClass ----------------------------- i double click the method "doIt()" in the tree browser on the right hand site. the result is: --------------------------- package test; /** * @author MH * * To change this generated comment edit the template variable "typecomment": * Window>Preferences>Java>Templates. */ public class HelloWorld { /** * Method main. * @param args */ public static void main(String[] args) { System.out.println("args = " + args); System.out.println("line 2 ..."); } } /** * @author MH * * To change this generated comment edit the template variable "typecomment": * Window>Preferences>Java>Templates. */ class SecondClass { public SecondClass { /** * Method doIt. */ }//constructor private void doIt() { //bla } }//SecondClass ------------------------------- => the javadoc comment is inserted within the body of the constructor of the class "SecondClass" - one line above.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/AddJavaDocStubAction.java
workingCopyCU.reconcile();
				}
			
			} else {
				
				workingCopyCU= EditorUtility.getWorkingCopy(cu);
				if (workingCopyCU == null) {
					showError(ActionMessages.getString("AddJavaDocStubsAction.error.noWorkingCopy")); 
					return;
				}
				workingCopyMembers= new IMember[members.length];
				for (int i= 0; i < members.length; i++) {
					IMember member= members[i];
					IMember workingCopyMember= (IMember) JavaModelUtil.findMemberInCompilationUnit(workingCopyCU, member);
					if (workingCopyMember == null) {
						showError(ActionMessages.getFormattedString("AddJavaDocStubsAction.error.memberNotExisting", member.getElementName())); 
						return;
					}
					workingCopyMembers[i]= workingCopyMember;
				}
			}
			
			run(workingCopyMembers);
			synchronized (workingCopyCU) {
				workingCopyCU.reconcile();
			}					
			EditorUtility.revealInEditor(editor, members[0]);
			
		} catch (CoreException e) {
			ExceptionHandler.handle(e, getShell(), getDialogTitle(), ActionMessages.getString("AddJavaDocStubsAction.error.actionFailed"));