View | Details | Raw Unified | Return to bug 125903
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterJavadocTest.java (-2 / +37 lines)
Lines 113-119 Link Here
113
		// Run test cases subset
113
		// Run test cases subset
114
		COPY_DIR = false;
114
		COPY_DIR = false;
115
		System.err.println("WARNING: only subset of tests will be executed!!!");
115
		System.err.println("WARNING: only subset of tests will be executed!!!");
116
		suite.addTest(new ASTConverterJavadocTest("testBug125676"));
116
		suite.addTest(new ASTConverterJavadocTest("testBug125903"));
117
		return suite;
117
		return suite;
118
	}
118
	}
119
119
Lines 3188-3194 Link Here
3188
	}
3188
	}
3189
3189
3190
	/**
3190
	/**
3191
	 * Bug 125676: [javadoc][dom] ASTNode not including javadoc
3191
	 * @bug 125676: [javadoc] @category should not read beyond end of line
3192
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=125676"
3192
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=125676"
3193
	 */
3193
	 */
3194
	public void testBug125676() throws JavaModelException {
3194
	public void testBug125676() throws JavaModelException {
Lines 3249-3252 Link Here
3249
		);
3249
		);
3250
		verifyWorkingCopiesComments();
3250
		verifyWorkingCopiesComments();
3251
	}
3251
	}
3252
3253
	/**
3254
	 * @bug 125903: [javadoc] Treat whitespace in javadoc tags as invalid tags
3255
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=125903"
3256
	 */
3257
	public void testBug125903() throws JavaModelException {
3258
		workingCopies = new ICompilationUnit[1];
3259
		astLevel = AST.JLS3;
3260
		workingCopies[0] = getWorkingCopy("/Converter15/src/javadoc/b125903/Test.java",
3261
			"package javadoc.b125903;\n" + 
3262
			"/**\n" + 
3263
			" * {@ link java.lang.String}\n" + 
3264
			" * @ since 2.1\n" + 
3265
			" */\n" + 
3266
			"public class Test {\n" + 
3267
			"\n" + 
3268
			"}\n"
3269
		);
3270
		CompilationUnit compilUnit = (CompilationUnit) runConversion(workingCopies[0], true);
3271
		verifyWorkingCopiesComments();
3272
		if (docCommentSupport.equals(JavaCore.ENABLED)) {
3273
			// Verify  method javadoc
3274
			ASTNode node = getASTNode(compilUnit, 0);
3275
			assertEquals("Invalid type for node: "+node, ASTNode.TYPE_DECLARATION, node.getNodeType());
3276
			TypeDeclaration typeDeclaration = (TypeDeclaration) node;
3277
			Javadoc javadoc = typeDeclaration.getJavadoc();
3278
			assertNotNull("TypeDeclaration should have a javadoc comment", javadoc);
3279
			List tags = javadoc.tags();
3280
			TagElement tag = (TagElement) tags.get(0);
3281
			tag = (TagElement) tag.fragments().get(0);
3282
			assertEquals("Tag name should be empty", tag.getTagName(), "@");
3283
			tag = (TagElement) tags.get(1);
3284
			assertEquals("Tag name should be empty", tag.getTagName(), "@");
3285
		}
3286
	}
3252
}
3287
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java (-1 / +31 lines)
Lines 36-42 Link Here
36
	static {
36
	static {
37
//		TESTS_PREFIX = "testBug83127";
37
//		TESTS_PREFIX = "testBug83127";
38
//		TESTS_NAMES = new String[] { "testBug68017javadocWarning2" };
38
//		TESTS_NAMES = new String[] { "testBug68017javadocWarning2" };
39
//		TESTS_NUMBERS = new int[] { 83285 };
39
//		TESTS_NUMBERS = new int[] { 125903 };
40
//		TESTS_RANGE = new int[] { 21, 50 };
40
//		TESTS_RANGE = new int[] { 21, 50 };
41
	}
41
	}
42
	public static Test suite() {
42
	public static Test suite() {
Lines 3961-3964 Link Here
3961
			}
3961
			}
3962
		);
3962
		);
3963
	}
3963
	}
3964
3965
	/**
3966
	 * Bug 125903: [javadoc] Treat whitespace in javadoc tags as invalid tags
3967
	 * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=125903"
3968
	 */
3969
	public void testBug125903() {
3970
		this.reportMissingJavadocTags = CompilerOptions.ERROR;
3971
		runNegativeTest(
3972
			new String[] {
3973
				"X.java",
3974
				"/**\n" + 
3975
				" * {@ link java.lang.String}\n" + 
3976
				" * @ since 2.1\n" + 
3977
				" */\n" + 
3978
				"public class X {\n" + 
3979
				"}\n"
3980
			},
3981
			"----------\n" + 
3982
			"1. ERROR in X.java (at line 2)\n" + 
3983
			"	* {@ link java.lang.String}\n" + 
3984
			"	   ^^\n" + 
3985
			"Javadoc: Invalid tag\n" + 
3986
			"----------\n" + 
3987
			"2. ERROR in X.java (at line 3)\n" + 
3988
			"	* @ since 2.1\n" + 
3989
			"	  ^^\n" + 
3990
			"Javadoc: Invalid tag\n" + 
3991
			"----------\n"
3992
		);
3993
	}
3964
}
3994
}
(-)compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java (+7 lines)
Lines 355-361 Link Here
355
		boolean valid = false;
355
		boolean valid = false;
356
	
356
	
357
		// Read tag name
357
		// Read tag name
358
		int currentPosition = this.index;
358
		int token = readTokenAndConsume();
359
		int token = readTokenAndConsume();
360
		if (currentPosition != this.scanner.startPosition) {
361
			this.tagSourceStart = previousPosition;
362
			this.tagSourceEnd = currentPosition;
363
			if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidTag(this.tagSourceStart, this.tagSourceEnd);
364
			return false;
365
		}
359
		if (this.index >= this.scanner.eofPosition) {
366
		if (this.index >= this.scanner.eofPosition) {
360
			this.tagSourceStart = previousPosition;
367
			this.tagSourceStart = previousPosition;
361
			this.tagSourceEnd = this.tokenPreviousPosition;
368
			this.tagSourceEnd = this.tokenPreviousPosition;
(-)dom/org/eclipse/jdt/core/dom/DocCommentParser.java (-3 / +14 lines)
Lines 337-346 Link Here
337
	protected boolean parseTag(int previousPosition) throws InvalidInputException {
337
	protected boolean parseTag(int previousPosition) throws InvalidInputException {
338
		
338
		
339
		// Read tag name
339
		// Read tag name
340
		int currentPosition = this.index;
340
		int token = readTokenAndConsume();
341
		int token = readTokenAndConsume();
341
		this.tagSourceStart = this.scanner.getCurrentTokenStartPosition();
342
		char[] tagName = CharOperation.NO_CHAR;
342
		this.tagSourceEnd = this.scanner.getCurrentTokenEndPosition();
343
		if (currentPosition == this.scanner.startPosition) {
343
		char[] tagName = this.scanner.getCurrentIdentifierSource();
344
			this.tagSourceStart = this.scanner.getCurrentTokenStartPosition();
345
			this.tagSourceEnd = this.scanner.getCurrentTokenEndPosition();
346
			tagName = this.scanner.getCurrentIdentifierSource();
347
		} else {
348
			this.tagSourceEnd = currentPosition-1;
349
		}
344
350
345
		// Try to get tag name other than java identifier
351
		// Try to get tag name other than java identifier
346
		// (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=51660)
352
		// (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=51660)
Lines 385-390 Link Here
385
		this.scanner.currentPosition = this.tagSourceEnd+1;
391
		this.scanner.currentPosition = this.tagSourceEnd+1;
386
		this.tagSourceStart = previousPosition;
392
		this.tagSourceStart = previousPosition;
387
393
394
		// tage name may be empty (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=125903)
395
		if (tagName.length == 0) {
396
			return false;
397
		}
398
388
		// Decide which parse to perform depending on tag name
399
		// Decide which parse to perform depending on tag name
389
		this.tagValue = NO_TAG_VALUE;
400
		this.tagValue = NO_TAG_VALUE;
390
		boolean valid = true;
401
		boolean valid = true;

Return to bug 125903