Bug 50644 - Deprecation check doesn't check that the @deprecated is at the beginning of the line
Summary: Deprecation check doesn't check that the @deprecated is at the beginning of t...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 M7   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-01-26 17:05 EST by Olivier Thomann CLA
Modified: 2004-02-11 09:22 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2004-01-26 17:05:21 EST
Using 200401210900, the method fragments() from
org.eclipse.jdt.core.dom.TagElement is reported as deprecated inside
org.eclipse.jdt.core.dom.NaiveASTFlattener.visit(TagElement node).

It seems that the javadoc parser doesn't ensure that the @deprecated is located
at the beginning of a line.
The rule is:
@deprecated can only be preceeded by white spaces or one asterisk.
Comment 1 Frederic Fusier CLA 2004-01-27 04:30:20 EST
Olivier, I can't reproduce the problem with build I200401210900. I can't see 
any deprecation in NaiveASTFlattener.visit(TagElement)...
Do I missed something?
Comment 2 Frederic Fusier CLA 2004-01-27 07:17:33 EST
It happens when compiler Javadoc option is not set...
Comment 3 Philipe Mulet CLA 2004-01-27 07:43:14 EST
Bug is in Javadoc parser check for deprecation which no longer skip line if 
line is starting with anything else than whitespaces or '*'.

Fixed
Comment 4 Philipe Mulet CLA 2004-01-27 07:51:30 EST
Offending loop should read:

				// scan line per line, since tags must be at 
beginning of lines only
				nextLine : for (int line = firstLineNumber; 
line <= lastLineNumber; line++) {
					int lineStart = line == firstLineNumber
							? javadocStart + 3 // 
skip leading /**
							: 
this.sourceParser.scanner.getLineStart(line);
					this.index = lineStart;
					this.lineEnd = line == lastLineNumber
							? javadocEnd - 2 // 
remove trailing * /
							: 
this.sourceParser.scanner.getLineEnd(line);
					nextCharacter : while (this.index < 
this.lineEnd) {
						char c = readChar(); // 
consider unicodes
						switch (c) {
						    default : 
						        if 
(Character.isWhitespace(c)) {
						            continue 
nextCharacter;
						        }
						        break;
						    case '*' :
						        continue nextCharacter;
						    case '@' :
						        if ((readChar() == 'd') 
&& (readChar() == 'e') &&
									
	(readChar() == 'p') && (readChar() == 'r') &&
									
	(readChar() == 'e') && (readChar() == 'c') &&
									
	(readChar() == 'a') && (readChar() == 't') &&
									
	(readChar() == 'e') && (readChar() == 'd')) {
									// 
ensure the tag is properly ended: either followed by a space, a tab, line end 
or asterisk.
									c = 
readChar();
									if 
(Character.isWhitespace(c) || c == '*') {
									
	return true;
									}
						        }
						}
			        	continue nextLine;
					}
				}
Comment 5 Frederic Fusier CLA 2004-01-27 08:11:57 EST
Fixed.

This was a regression introduced while splitting Javadoc parsers between 
compiler and dom...

Test case added in jdt.core.tests.compiler.regression.JavadocTestMixed
Comment 6 David Audel CLA 2004-02-11 09:22:29 EST
Verified for 3.0M7