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 (-1 / +101 lines)
Lines 7526-7532 Link Here
7526
		"1. ERROR in pkg\\X.java (at line 5)\n" + 
7526
		"1. ERROR in pkg\\X.java (at line 5)\n" + 
7527
		"	* {@link \"http://www.eclipse.org/}\n" + 
7527
		"	* {@link \"http://www.eclipse.org/}\n" + 
7528
		"	         ^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
7528
		"	         ^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
7529
		"Javadoc: Invalid reference\n" + 
7529
		"Javadoc: Invalid URL reference. Double quote the reference or use the href syntax\n" + 
7530
		"----------\n" + 
7530
		"----------\n" + 
7531
		"2. ERROR in pkg\\X.java (at line 6)\n" + 
7531
		"2. ERROR in pkg\\X.java (at line 6)\n" + 
7532
		"	* @see \"http://www.eclipse.org/\n" + 
7532
		"	* @see \"http://www.eclipse.org/\n" + 
Lines 8487-8490 Link Here
8487
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError
8487
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError
8488
	);
8488
	);
8489
}
8489
}
8490
public void testBug200207() {
8491
	runNegativeTest(
8492
		new String[] {
8493
				"XYZ.java", 
8494
				"/** \n" +
8495
				"* " +
8496
				"* @see \"Unterminated\n" +
8497
				"* @see String\"\n" +
8498
				"*/ \n" + 
8499
				"public class XYZ { \n"+
8500
				"}\n"
8501
				},
8502
				"----------\n" + 
8503
				"1. ERROR in XYZ.java (at line 2)\n" + 
8504
				"	* * @see \"Unterminated\n" + 
8505
				"	         ^^^^^^^^^^^^^\n" + 
8506
				"Javadoc: Invalid reference\n" + 
8507
				"----------\n" + 
8508
				"2. ERROR in XYZ.java (at line 3)\n" + 
8509
				"	* @see String\"\n" + 
8510
				"	       ^^^^^^^\n" + 
8511
				"Javadoc: Malformed reference (missing end space separator)\n" + 
8512
				"----------\n");
8513
}
8514
public void testBug200207_2() {
8515
	runConformTest(
8516
		new String[] {
8517
				"XYZ.java", 
8518
				"/** \n" +
8519
				"* " +
8520
				"* @see \"Unterminated\n" +
8521
				"* String\"\n" +
8522
				"* @author jay\n" +
8523
				"* @see \"Alice in \n" +
8524
				"* still ** @@{} not closed @\n" +
8525
				"* wonder*land@\"\n" +
8526
				"*/ \n" + 
8527
				"public class XYZ { \n"+
8528
				"}\n"
8529
				});
8530
}
8531
8532
public void testBug200207_3() {
8533
	runConformTest(
8534
		new String[] {
8535
				"XYZ.java", 
8536
				"/** \n" +
8537
				"* " +
8538
				"* @see <a href=\"http://www.eclipse.org" +
8539
				"* \">Eclipse</a>" +
8540
				"*/ \n" + 
8541
				"public class XYZ { \n"+
8542
				"}\n"
8543
				},
8544
				"");
8545
}
8546
8547
public void testBug200207_4() {
8548
	runNegativeTest(
8549
		new String[] {
8550
				"XYZ.java", 
8551
				"/** \n" +
8552
				"* This test includes valid {@link \"http://www.eclipse.org\"}, {@author jay} \n" +
8553
				"* invalid {@link \"http://eclipse.org} inline tags \n" +
8554
				"* " +
8555
				"*/ \n" + 
8556
				"public class XYZ { \n"+
8557
				"}\n"
8558
				},
8559
				"----------\n" + 
8560
				"1. ERROR in XYZ.java (at line 3)\n" + 
8561
				"	* invalid {@link \"http://eclipse.org} inline tags \n" + 
8562
				"	                 ^^^^^^^^^^^^^^^^^^^^\n" + 
8563
				"Javadoc: Invalid URL reference. Double quote the reference or use the href syntax\n" + 
8564
				"----------\n");
8565
}
8566
8567
public void testBug200207_5() {
8568
	runNegativeTest(
8569
		new String[] {
8570
				"XYZ.java", 
8571
				"/** \n" +
8572
				"* This test checks for two invalid {@link \"http://www.eclipse.org} inline {@link http://eclipse.org\"} tags \n" +
8573
				"* " +
8574
				"*/ \n" + 
8575
				"public class XYZ { \n"+
8576
				"}\n"
8577
				},
8578
				"----------\n" + 
8579
				"1. ERROR in XYZ.java (at line 2)\n" + 
8580
				"	* This test checks for two invalid {@link \"http://www.eclipse.org} inline {@link http://eclipse.org\"} tags \n" + 
8581
				"	                                          ^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
8582
				"Javadoc: Invalid URL reference. Double quote the reference or use the href syntax\n" + 
8583
				"----------\n" + 
8584
				"2. ERROR in XYZ.java (at line 2)\n" + 
8585
				"	* This test checks for two invalid {@link \"http://www.eclipse.org} inline {@link http://eclipse.org\"} tags \n" + 
8586
				"	                                                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
8587
				"Javadoc: Invalid URL reference. Double quote the reference or use the href syntax\n" + 
8588
				"----------\n");
8589
}
8490
}
8590
}
(-)compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java (-1 / +95 lines)
Lines 1158-1164 Link Here
1158
						if (currentError.length>0 && currentError[0] == '"') {
1158
						if (currentError.length>0 && currentError[0] == '"') {
1159
							if (this.reportProblems) {
1159
							if (this.reportProblems) {
1160
								boolean isUrlRef = false;
1160
								boolean isUrlRef = false;
1161
								if (this.tagValue == TAG_SEE_VALUE) {
1161
								if (this.tagValue == TAG_SEE_VALUE || this.tagValue == TAG_LINK_VALUE) {
1162
									int length=currentError.length, i=1 /* first char is " */;
1162
									int length=currentError.length, i=1 /* first char is " */;
1163
									while (i<length && ScannerHelper.isLetter(currentError[i])) {
1163
									while (i<length && ScannerHelper.isLetter(currentError[i])) {
1164
										i++;
1164
										i++;
Lines 1433-1444 Link Here
1433
		return c;
1433
		return c;
1434
	}
1434
	}
1435
1435
1436
protected int scanJavadocString() throws InvalidInputException {
1437
	int startPosition = this.index;
1438
	boolean possibleNextTag = false;
1439
	boolean seekAhead = true;
1440
	int endOfToken = -1;
1441
	try {
1442
		while (seekAhead) {
1443
1444
			if (this.index >= this.javadocTextEnd) {
1445
				if (endOfToken != -1) {
1446
					this.index = endOfToken;
1447
				}
1448
				throw new InvalidInputException(Scanner.UNTERMINATED_STRING);
1449
			}
1450
			char currentChar = readChar();
1451
			
1452
			switch(currentChar) {
1453
				case '@':
1454
					if (possibleNextTag) {
1455
						this.index = endOfToken;
1456
						throw new InvalidInputException(Scanner.UNTERMINATED_STRING);
1457
					}
1458
					break;
1459
				case '}':
1460
				case '{':
1461
					if (this.inlineTagStarted) {
1462
						throw new InvalidInputException(Scanner.UNTERMINATED_STRING);
1463
					}
1464
					break;
1465
				case '*':
1466
					break;
1467
				case '\n':
1468
				case '\r':
1469
						if (!possibleNextTag) {
1470
							endOfToken = this.index -1;
1471
							possibleNextTag = true;
1472
						}
1473
						break;
1474
				case '"':
1475
					seekAhead = false;
1476
					break;
1477
				case '\\':
1478
					if (this.index >= this.javadocTextEnd) {
1479
						throw new InvalidInputException(Scanner.UNTERMINATED_STRING);
1480
					}
1481
					// We need to call scanner.getNextChar because the scanner.scanEscapeCharacter expects the character 
1482
					// after the '\\' as the currentCharacter.
1483
					this.scanner.currentPosition = this.index;
1484
					this.scanner.getNextChar();
1485
					this.scanner.scanEscapeCharacter();
1486
					this.index = this.scanner.currentPosition;
1487
					break;
1488
				default:
1489
					if (!ScannerHelper.isWhitespace(currentChar)) {
1490
						possibleNextTag = false;
1491
					}
1492
					break;
1493
			}
1494
		}
1495
	} catch (InvalidInputException invalidInput) {
1496
		if (invalidInput.getMessage().equals(Scanner.INVALID_ESCAPE)) {
1497
			// relocate if finding another quote fairly close: thus unicode '/u000D' will be fully consumed
1498
			for (int lookAhead = 0; lookAhead < 50; lookAhead++) {
1499
				if (this.index + lookAhead == this.javadocTextEnd)
1500
					break;
1501
				if (this.source[this.index + lookAhead] == '\n')
1502
					break;
1503
				if (this.source[this.index + lookAhead] == '\"') {
1504
					this.index += lookAhead + 1;
1505
					break;
1506
				}
1507
			}
1508
		}
1509
		this.scanner.currentPosition = this.index;
1510
		this.index = startPosition;
1511
		throw invalidInput;
1512
	}
1513
	this.scanner.resetTo(this.index, this.javadocEnd);
1514
	return TerminalTokens.TokenNameStringLiteral;
1515
}
1516
1436
	/*
1517
	/*
1437
	 * Read token only if previous was consumed
1518
	 * Read token only if previous was consumed
1438
	 */
1519
	 */
1439
	protected int readToken() throws InvalidInputException {
1520
	protected int readToken() throws InvalidInputException {
1440
		if (this.currentTokenType < 0) {
1521
		if (this.currentTokenType < 0) {
1441
			this.tokenPreviousPosition = this.scanner.currentPosition;
1522
			this.tokenPreviousPosition = this.scanner.currentPosition;
1523
			if (this.tagValue == TAG_LINK_VALUE || this.tagValue == TAG_SEE_VALUE) {
1524
				int oldIndex = this.index;
1525
				char charAhead;
1526
				do{
1527
					charAhead = readChar();
1528
					if (charAhead == '"') {
1529
						this.scanner.resetTo(this.index-1, this.javadocEnd);
1530
						return scanJavadocString();
1531
					}
1532
				}
1533
				while( charAhead == ' ' || charAhead == '\t'); // The other whitespace characters are now allowed?
1534
				this.index = oldIndex;
1535
			}
1442
			this.currentTokenType = this.scanner.getNextToken();
1536
			this.currentTokenType = this.scanner.getNextToken();
1443
			if (this.scanner.currentPosition > (this.lineEnd+1)) { // be sure to be on next line (lineEnd is still on the same line)
1537
			if (this.scanner.currentPosition > (this.lineEnd+1)) { // be sure to be on next line (lineEnd is still on the same line)
1444
				this.lineStarted = false;
1538
				this.lineStarted = false;

Return to bug 200207