### 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.67 diff -u -r1.67 SourceElementParser.java --- model/org/eclipse/jdt/internal/compiler/SourceElementParser.java 20 Apr 2006 17:18:05 -0000 1.67 +++ model/org/eclipse/jdt/internal/compiler/SourceElementParser.java 20 Apr 2006 17:18:36 -0000 @@ -394,6 +394,10 @@ requestor.acceptFieldReference(fr.token, fr.sourceStart); } } +protected void consumeFormalParameter(boolean isVarArgs) { + super.consumeFormalParameter(isVarArgs); + flushCommentsDefinedPriorTo(this.scanner.currentPosition); +} protected void consumeInterfaceHeaderName1() { int currentAstPtr = this.astPtr; super.consumeInterfaceHeaderName1();