### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java,v retrieving revision 1.171 diff -u -r1.171 ASTConverterTest2.java --- src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java 29 Mar 2006 04:03:06 -0000 1.171 +++ src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java 19 Apr 2006 16:45:14 -0000 @@ -5413,6 +5413,30 @@ } } + /* + * Ensures that the start position of an argument that has a previous sibbling with a comment is correct + * (regression test for bug 80904 Quick Fix "Assign parameter to new field" doesn't appear with commented type) + */ + public void test0579() throws CoreException { + ICompilationUnit workingCopy = null; + try { + workingCopy = getWorkingCopy( + "/Converter/src/X.java", + "public class X {\n" + + " /*start*/void foo(Object/*first arg*/ arg1, Object arg2) {\n" + + " }/*end*/\n" + + "}", + true/*resolve*/); + MethodDeclaration method = (MethodDeclaration) buildAST(workingCopy); + SingleVariableDeclaration arg2 = (SingleVariableDeclaration) method.parameters().get(1); + int start = arg2.getStartPosition(); + assertEquals("Unexpected range for arg2", "Object arg2", workingCopy.getSource().substring(start, start+arg2.getLength())); + } finally { + if (workingCopy != null) + workingCopy.discardWorkingCopy(); + } + } + public void test0606() throws JavaModelException { ICompilationUnit sourceUnit = getCompilationUnit("Converter", "src", "test0606", "X.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ ASTNode result = runConversion(sourceUnit, true); #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/compiler/SourceElementParser.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementParser.java,v retrieving revision 1.65 diff -u -r1.65 SourceElementParser.java --- model/org/eclipse/jdt/internal/compiler/SourceElementParser.java 29 Mar 2006 03:08:49 -0000 1.65 +++ model/org/eclipse/jdt/internal/compiler/SourceElementParser.java 19 Apr 2006 16:45:16 -0000 @@ -160,34 +160,7 @@ } } public void checkComment() { - // discard obsolete comments while inside methods or fields initializer (see bug 74369) - if (!(this.diet && this.dietInt==0) && this.scanner.commentPtr >= 0) { - flushCommentsDefinedPriorTo(this.endStatementPosition); - } - - int lastComment = this.scanner.commentPtr; - - if (this.modifiersSourceStart >= 0) { - // eliminate comments located after modifierSourceStart if positionned - while (lastComment >= 0 && Math.abs(this.scanner.commentStarts[lastComment]) > this.modifiersSourceStart) lastComment--; - } - if (lastComment >= 0) { - // consider all remaining leading comments to be part of current declaration - this.modifiersSourceStart = Math.abs(this.scanner.commentStarts[0]); - - // check deprecation in last comment if javadoc (can be followed by non-javadoc comments which are simply ignored) - while (lastComment >= 0 && this.scanner.commentStops[lastComment] < 0) lastComment--; // non javadoc comment have negative end positions - if (lastComment >= 0 && this.javadocParser != null) { - int commentEnd = this.scanner.commentStops[lastComment] - 1; //stop is one over, - // do not report problem before last parsed comment while recovering code... - this.javadocParser.reportProblems = this.currentElement == null || commentEnd > this.lastJavadocEnd; - if (this.javadocParser.checkDeprecation(lastComment)) { - checkAndSetModifiers(ClassFileConstants.AccDeprecated); - } - this.javadoc = this.javadocParser.docComment; // null if check javadoc is not activated - if (currentElement == null) this.lastJavadocEnd = commentEnd; - } - } + super.checkComment(); if (this.reportReferenceInfo && this.javadocParser.checkDocComment && this.javadoc != null) { // Report reference info in javadoc comment @throws/@exception tags