View | Details | Raw Unified | Return to bug 80904 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java (+24 lines)
Lines 5413-5418 Link Here
5413
		}
5413
		}
5414
	}
5414
	}
5415
5415
5416
	/*
5417
	 * Ensures that the start position of an argument that has a previous sibbling with a comment is correct
5418
	 * (regression test for bug 80904 Quick Fix "Assign parameter to new field" doesn't appear with commented type)
5419
	 */
5420
	public void test0579() throws CoreException {
5421
		ICompilationUnit workingCopy = null;
5422
		try {
5423
			workingCopy = getWorkingCopy(
5424
				"/Converter/src/X.java", 
5425
				"public class X {\n" +
5426
				"  /*start*/void foo(Object/*first arg*/ arg1, Object arg2) {\n" +
5427
				"  }/*end*/\n" +
5428
				"}",
5429
				true/*resolve*/);
5430
			MethodDeclaration method = (MethodDeclaration) buildAST(workingCopy);
5431
			SingleVariableDeclaration arg2 = (SingleVariableDeclaration) method.parameters().get(1);
5432
			int start = arg2.getStartPosition();
5433
			assertEquals("Unexpected range for arg2", "Object arg2", workingCopy.getSource().substring(start, start+arg2.getLength()));
5434
		} finally {
5435
			if (workingCopy != null)
5436
				workingCopy.discardWorkingCopy();
5437
		}
5438
	}
5439
	
5416
	public void test0606() throws JavaModelException {
5440
	public void test0606() throws JavaModelException {
5417
		ICompilationUnit sourceUnit = getCompilationUnit("Converter", "src", "test0606", "X.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
5441
		ICompilationUnit sourceUnit = getCompilationUnit("Converter", "src", "test0606", "X.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
5418
		ASTNode result = runConversion(sourceUnit, true);
5442
		ASTNode result = runConversion(sourceUnit, true);
(-)model/org/eclipse/jdt/internal/compiler/SourceElementParser.java (-28 / +1 lines)
Lines 160-193 Link Here
160
	}
160
	}
161
}
161
}
162
public void checkComment() {
162
public void checkComment() {
163
	// discard obsolete comments while inside methods or fields initializer (see bug 74369)
163
	super.checkComment();
164
	if (!(this.diet && this.dietInt==0) && this.scanner.commentPtr >= 0) {
165
		flushCommentsDefinedPriorTo(this.endStatementPosition);
166
	}
167
	
168
	int lastComment = this.scanner.commentPtr;
169
	
170
	if (this.modifiersSourceStart >= 0) {
171
		// eliminate comments located after modifierSourceStart if positionned
172
		while (lastComment >= 0 && Math.abs(this.scanner.commentStarts[lastComment]) > this.modifiersSourceStart) lastComment--;
173
	}
174
	if (lastComment >= 0) {
175
		// consider all remaining leading comments to be part of current declaration
176
		this.modifiersSourceStart = Math.abs(this.scanner.commentStarts[0]); 
177
	
178
		// check deprecation in last comment if javadoc (can be followed by non-javadoc comments which are simply ignored)	
179
		while (lastComment >= 0 && this.scanner.commentStops[lastComment] < 0) lastComment--; // non javadoc comment have negative end positions
180
		if (lastComment >= 0 && this.javadocParser != null) {
181
			int commentEnd = this.scanner.commentStops[lastComment] - 1; //stop is one over,
182
			// do not report problem before last parsed comment while recovering code...
183
			this.javadocParser.reportProblems = this.currentElement == null || commentEnd > this.lastJavadocEnd;
184
			if (this.javadocParser.checkDeprecation(lastComment)) {
185
				checkAndSetModifiers(ClassFileConstants.AccDeprecated);
186
			}
187
			this.javadoc = this.javadocParser.docComment;	// null if check javadoc is not activated
188
			if (currentElement == null) this.lastJavadocEnd = commentEnd;
189
		}
190
	}
191
164
192
	if (this.reportReferenceInfo && this.javadocParser.checkDocComment && this.javadoc != null) {
165
	if (this.reportReferenceInfo && this.javadocParser.checkDocComment && this.javadoc != null) {
193
		// Report reference info in javadoc comment @throws/@exception tags
166
		// Report reference info in javadoc comment @throws/@exception tags

Return to bug 80904