Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 200207 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java (+51 lines)
Lines 7247-7250 Link Here
7247
		reportMissingJavadocDescription = CompilerOptions.ALL_STANDARD_TAGS;
7247
		reportMissingJavadocDescription = CompilerOptions.ALL_STANDARD_TAGS;
7248
		runConformTest(units);
7248
		runConformTest(units);
7249
	}
7249
	}
7250
	
7251
7252
	/**
7253
	 * @bug 200207: [javadoc] Incorrect flagging of @see as malformed javadoc
7254
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=200207"
7255
	 */
7256
	public void testBug200207a() {
7257
		String[] units = new String[] {
7258
			"pkg/X.java",
7259
			"package pkg;\n" +
7260
			"public class X\n" +
7261
			"{\n" +
7262
			"  /**\n" +
7263
			"   * @see this text\n" +
7264
			"   *      is expected\n" +
7265
			"   *    to be ok\"\n" +
7266
			"   */\n" +
7267
			"	public String toString() { \n" +
7268
			"		return \"foo\";\n" +
7269
			"	}\n" +
7270
			"}\n"
7271
		};
7272
		reportInvalidJavadoc = CompilerOptions.WARNING;
7273
		runConformTest(units);
7274
	}
7275
	public void testBug200207b() {
7276
		String[] units = new String[] {
7277
				"pkg/X.java",
7278
				"package pkg;\n" +
7279
				"public class X\n" +
7280
				"{\n" +
7281
				"  /**\n" +
7282
				"   * @see \"unterminated\n" +
7283
				"   *      string literal\n" +
7284
				"   *    should be warned\n" +
7285
				"   */\n" +
7286
				"	public String toString() { \n" +
7287
				"		return \"foo\";\n" +
7288
				"	}\n" +
7289
				"}\n"
7290
			};
7291
		reportInvalidJavadoc = CompilerOptions.WARNING;
7292
		runNegativeTest(units,
7293
				"----------\n" + 
7294
				"1. WARNING in pkg\\X.java (at line 5)\n" + 
7295
				"	* @see \"unterminated\n" + 
7296
				"	       ^^^^^^^^^^^^^\n" + 
7297
				"Javadoc: Invalid reference\n" + 
7298
				"----------\n"
7299
			);
7300
	}
7250
}
7301
}
(-)compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java (-4 / +35 lines)
Lines 1096-1101 Link Here
1096
			int previousPosition = -1;
1096
			int previousPosition = -1;
1097
			int typeRefStartPosition = -1;
1097
			int typeRefStartPosition = -1;
1098
			
1098
			
1099
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=200207
1100
			boolean considerAsStringLiteral = false;
1101
			int literalStartPosition = -1;
1102
			
1099
			// Get reference tokens
1103
			// Get reference tokens
1100
			nextToken : while (this.index < this.scanner.eofPosition) {
1104
			nextToken : while (this.index < this.scanner.eofPosition) {
1101
				previousPosition = this.index;
1105
				previousPosition = this.index;
Lines 1151-1161 Link Here
1151
						}
1155
						}
1152
						char[] currentError = this.scanner.getCurrentIdentifierSource();
1156
						char[] currentError = this.scanner.getCurrentIdentifierSource();
1153
						if (currentError.length>0 && currentError[0] == '"') {
1157
						if (currentError.length>0 && currentError[0] == '"') {
1154
							if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidReference(this.scanner.getCurrentTokenStartPosition(), getTokenEndPosition());
1158
							// https://bugs.eclipse.org/bugs/show_bug.cgi?id=200207
1155
							return false;
1159
							// handle double quoted strings than span on several lines
1156
						}
1160
							if (considerAsStringLiteral) {
1161
								// closing '"' found
1162
								considerAsStringLiteral = false;
1163
								literalStartPosition = -1;
1164
								break;
1165
							} else {
1166
								if (this.scanner.currentCharacter == '\r') {
1167
									// unterminated string literal: keep on parsing the reference until closing '"' found
1168
									considerAsStringLiteral = true;
1169
									// store position for error handling
1170
									literalStartPosition = this.scanner.getCurrentTokenStartPosition();
1171
									break;
1172
								} else {
1173
									if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidReference(this.scanner.getCurrentTokenStartPosition(), getTokenEndPosition());
1174
										return false;
1175
									}
1176
								}
1177
							}
1157
						break nextToken;
1178
						break nextToken;
1158
					case TerminalTokens.TokenNameIdentifier :
1179
					case TerminalTokens.TokenNameIdentifier :
1180
						// discard identifiers when inside an unterminated string literal
1181
						if (considerAsStringLiteral) {
1182
							consumeToken();
1183
							break;
1184
						}
1159
						if (typeRef == null) {
1185
						if (typeRef == null) {
1160
							typeRefStartPosition = this.scanner.getCurrentTokenStartPosition();
1186
							typeRefStartPosition = this.scanner.getCurrentTokenStartPosition();
1161
							typeRef = parseQualifiedName(true);
1187
							typeRef = parseQualifiedName(true);
Lines 1178-1184 Link Here
1178
					return true;
1204
					return true;
1179
				}
1205
				}
1180
				if (this.reportProblems) {
1206
				if (this.reportProblems) {
1181
					this.sourceParser.problemReporter().javadocMissingReference(this.tagSourceStart, this.tagSourceEnd, this.sourceParser.modifiers);
1207
					if (considerAsStringLiteral) {
1208
						// unterminated string literal
1209
						this.sourceParser.problemReporter().javadocInvalidReference(literalStartPosition, getTokenEndPosition());
1210
					} else {
1211
						this.sourceParser.problemReporter().javadocMissingReference(this.tagSourceStart, this.tagSourceEnd, this.sourceParser.modifiers);
1212
					}
1182
				}
1213
				}
1183
				return false;
1214
				return false;
1184
			}
1215
			}

Return to bug 200207