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

(-)compiler/org/eclipse/jdt/internal/compiler/ast/Javadoc.java (-2 / +19 lines)
Lines 30-35 Link Here
30
	// bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=51600
30
	// bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=51600
31
	// Store param references for tag with invalid syntax
31
	// Store param references for tag with invalid syntax
32
	public JavadocSingleNameReference[] invalidParameters; // @param
32
	public JavadocSingleNameReference[] invalidParameters; // @param
33
	// bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=153399
34
	// Store value tag positions
35
	public long valuePositions = -1;
33
36
34
	public Javadoc(int sourceStart, int sourceEnd) {
37
	public Javadoc(int sourceStart, int sourceEnd) {
35
		this.sourceStart = sourceStart;
38
		this.sourceStart = sourceStart;
Lines 219-224 Link Here
219
		for (int i = 0; i < seeTagsLength; i++) {
222
		for (int i = 0; i < seeTagsLength; i++) {
220
			resolveReference(this.seeReferences[i], scope);
223
			resolveReference(this.seeReferences[i], scope);
221
		}
224
		}
225
226
		// @value tag
227
		boolean source15 = scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5;
228
		if (!source15 && this.valuePositions != -1) {
229
			scope.problemReporter().javadocUnexpectedTag((int)(this.valuePositions>>>32), (int) this.valuePositions);
230
		}
222
	}
231
	}
223
	
232
	
224
	/*
233
	/*
Lines 228-235 Link Here
228
		
237
		
229
		// get method declaration
238
		// get method declaration
230
		AbstractMethodDeclaration methDecl = methScope.referenceMethod();
239
		AbstractMethodDeclaration methDecl = methScope.referenceMethod();
231
		boolean overriding = methDecl == null || methDecl.binding == null ? false : !methDecl.binding.isStatic() && ((methDecl.binding.modifiers & (ExtraCompilerModifiers.AccImplementing | ExtraCompilerModifiers.AccOverriding)) != 0);
240
		boolean overriding = methDecl == null /* field declaration */ || methDecl.binding == null /* compiler error */
232
241
			? false :
242
			!methDecl.binding.isStatic() && ((methDecl.binding.modifiers & (ExtraCompilerModifiers.AccImplementing | ExtraCompilerModifiers.AccOverriding)) != 0);
243
		
233
		// @see tags
244
		// @see tags
234
		int seeTagsLength = this.seeReferences == null ? 0 : this.seeReferences.length;
245
		int seeTagsLength = this.seeReferences == null ? 0 : this.seeReferences.length;
235
		boolean superRef = false;
246
		boolean superRef = false;
Lines 317-322 Link Here
317
		// @throws/@exception tags
328
		// @throws/@exception tags
318
		resolveThrowsTags(methScope, reportMissing);
329
		resolveThrowsTags(methScope, reportMissing);
319
330
331
		// @value tag
332
		boolean source15 = methScope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5;
333
		if (!source15 && methDecl != null && this.valuePositions != -1) {
334
			methScope.problemReporter().javadocUnexpectedTag((int)(this.valuePositions>>>32), (int) this.valuePositions);
335
		}
336
320
		// Resolve param tags with invalid syntax
337
		// Resolve param tags with invalid syntax
321
		int length = this.invalidParameters == null ? 0 : this.invalidParameters.length;
338
		int length = this.invalidParameters == null ? 0 : this.invalidParameters.length;
322
		for (int i = 0; i < length; i++) {
339
		for (int i = 0; i < length; i++) {
(-)compiler/org/eclipse/jdt/core/compiler/IProblem.java (+5 lines)
Lines 780-785 Link Here
780
	 * Javadoc comments
780
	 * Javadoc comments
781
	 */
781
	 */
782
	/** 
782
	/** 
783
	 * Problem warned on duplicated tag.
784
	 * @since 3.3
785
	 */
786
	int JavadocDuplicateTag = Javadoc + Internal + 464;
787
	/** 
783
	 * Problem signaled on an hidden reference due to a too low visibility level.
788
	 * Problem signaled on an hidden reference due to a too low visibility level.
784
	 * @since 3.3
789
	 * @since 3.3
785
	 */
790
	 */
(-)compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties (+1 lines)
Lines 363-368 Link Here
363
460 = Empty block should be documented
363
460 = Empty block should be documented
364
364
365
### DOC 
365
### DOC 
366
464 = Unexpected duplicated tag @{0}
366
465 = ''{0}'' visibility for malformed doc comments hides this ''{1}'' reference
367
465 = ''{0}'' visibility for malformed doc comments hides this ''{1}'' reference
367
466 = Invalid member type qualification
368
466 = Invalid member type qualification
368
467 = Missing identifier
369
467 = Missing identifier
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (+10 lines)
Lines 198-203 Link Here
198
				return CompilerOptions.UnusedLabel;
198
				return CompilerOptions.UnusedLabel;
199
	
199
	
200
			case IProblem.JavadocUnexpectedTag:
200
			case IProblem.JavadocUnexpectedTag:
201
			case IProblem.JavadocDuplicateTag:
201
			case IProblem.JavadocDuplicateReturnTag:
202
			case IProblem.JavadocDuplicateReturnTag:
202
			case IProblem.JavadocInvalidThrowsClass:
203
			case IProblem.JavadocInvalidThrowsClass:
203
			case IProblem.JavadocInvalidSeeReference:
204
			case IProblem.JavadocInvalidSeeReference:
Lines 3589-3594 Link Here
3589
public void javadocDuplicatedReturnTag(int sourceStart, int sourceEnd){
3590
public void javadocDuplicatedReturnTag(int sourceStart, int sourceEnd){
3590
	this.handle(IProblem.JavadocDuplicateReturnTag, NoArgument, NoArgument, sourceStart, sourceEnd);
3591
	this.handle(IProblem.JavadocDuplicateReturnTag, NoArgument, NoArgument, sourceStart, sourceEnd);
3591
}
3592
}
3593
public void javadocDuplicatedTag(char[] tagName, int sourceStart, int sourceEnd){
3594
	String[] arguments = new String[] { new String(tagName) };
3595
	this.handle(
3596
		IProblem.JavadocDuplicateTag,
3597
		arguments,
3598
		arguments,
3599
		sourceStart,
3600
		sourceEnd);
3601
}
3592
public void javadocDuplicatedThrowsClassName(TypeReference typeReference, int modifiers) {
3602
public void javadocDuplicatedThrowsClassName(TypeReference typeReference, int modifiers) {
3593
	int severity = computeSeverity(IProblem.JavadocDuplicateThrowsClassName);
3603
	int severity = computeSeverity(IProblem.JavadocDuplicateThrowsClassName);
3594
	if (severity == ProblemSeverities.Ignore) return;
3604
	if (severity == ProblemSeverities.Ignore) return;
(-)compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java (-8 / +28 lines)
Lines 30-35 Link Here
30
	private int invalidParamReferencesPtr = -1;
30
	private int invalidParamReferencesPtr = -1;
31
	private ASTNode[] invalidParamReferencesStack;
31
	private ASTNode[] invalidParamReferencesStack;
32
32
33
	// bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=153399
34
	// Store value tag positions
35
	private long validValuePositions, invalidValuePositions;
36
33
	public JavadocParser(Parser sourceParser) {
37
	public JavadocParser(Parser sourceParser) {
34
		super(sourceParser);
38
		super(sourceParser);
35
		this.kind = COMPIL_PARSER | TEXT_VERIF;
39
		this.kind = COMPIL_PARSER | TEXT_VERIF;
Lines 47-52 Link Here
47
		this.javadocStart = this.sourceParser.scanner.commentStarts[commentPtr];
51
		this.javadocStart = this.sourceParser.scanner.commentStarts[commentPtr];
48
		this.javadocEnd = this.sourceParser.scanner.commentStops[commentPtr]-1;
52
		this.javadocEnd = this.sourceParser.scanner.commentStops[commentPtr]-1;
49
		this.firstTagPosition = this.sourceParser.scanner.commentTagStarts[commentPtr];
53
		this.firstTagPosition = this.sourceParser.scanner.commentTagStarts[commentPtr];
54
		this.validValuePositions = -1;
55
		this.invalidValuePositions = -1;
50
56
51
		// Init javadoc if necessary
57
		// Init javadoc if necessary
52
		if (this.checkDocComment) {
58
		if (this.checkDocComment) {
Lines 540-554 Link Here
540
						}
546
						}
541
						break;
547
						break;
542
					case 'v':
548
					case 'v':
543
						if (this.sourceLevel >= ClassFileConstants.JDK1_5 && length == TAG_VALUE_LENGTH && CharOperation.equals(TAG_VALUE, tagName)) {
549
						if (length == TAG_VALUE_LENGTH && CharOperation.equals(TAG_VALUE, tagName)) {
544
							this.tagValue = TAG_VALUE_VALUE;
550
							this.tagValue = TAG_VALUE_VALUE;
545
							if (this.inlineTagStarted) {
551
							if (this.sourceLevel >= ClassFileConstants.JDK1_5) {
546
								valid = parseReference();
552
								if (this.inlineTagStarted) {
547
							} else {
553
									valid = parseReference();
548
								valid = false;
554
								} else {
549
								if (this.reportProblems) {
555
									valid = false;
550
									this.sourceParser.problemReporter().javadocUnexpectedTag(this.tagSourceStart, this.tagSourceEnd);
556
									if (this.reportProblems) this.sourceParser.problemReporter().javadocUnexpectedTag(this.tagSourceStart, this.tagSourceEnd);
557
								}
558
							}
559
							if (this.validValuePositions == -1) {
560
								if (this.invalidValuePositions != -1) {
561
									if (this.reportProblems) this.sourceParser.problemReporter().javadocDuplicatedTag(tagName, (int) (this.invalidValuePositions>>>32), (int) this.invalidValuePositions);
551
								}
562
								}
563
								if (valid) {
564
									this.validValuePositions = (((long) this.tagSourceStart) << 32) + this.tagSourceEnd;
565
									this.invalidValuePositions = -1;
566
								} else {
567
									this.invalidValuePositions = (((long) this.tagSourceStart) << 32) + this.tagSourceEnd;
568
								}
569
							} else {
570
								if (this.reportProblems) this.sourceParser.problemReporter().javadocDuplicatedTag(tagName, this.tagSourceStart, this.tagSourceEnd);
552
							}
571
							}
553
						} else {
572
						} else {
554
							createTag();
573
							createTag();
Lines 720-727 Link Here
720
	 */
739
	 */
721
	protected void updateDocComment() {
740
	protected void updateDocComment() {
722
741
723
		// Set inherited positions
742
		// Set positions
724
		this.docComment.inheritedPositions = this.inheritedPositions;
743
		this.docComment.inheritedPositions = this.inheritedPositions;
744
		this.docComment.valuePositions = this.validValuePositions != -1 ? this.validValuePositions : this.invalidValuePositions;
725
745
726
		// Set return node if present
746
		// Set return node if present
727
		if (this.returnStatement != null) {
747
		if (this.returnStatement != null) {
(-)src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java (-22 / +253 lines)
Lines 2900-2935 Link Here
2900
	}
2900
	}
2901
2901
2902
	/**
2902
	/**
2903
	 * Bug 70892: [1.5][Javadoc] Compiler should parse reference for inline tag @value
2903
	 * @bug 70892: [1.5][Javadoc] Compiler should parse reference for inline tag @value
2904
	 * @see <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=70892">70892</a>
2904
	 * @test Ensure that reference in tag {@value} is only verified when source level >= 1.5
2905
	 * These two tests should pass whatever the source level...
2905
	 * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=70892"
2906
	 */
2906
	 */
2907
	public void testBug70892conform1() {
2907
	public void testBug70892a() {
2908
		runConformTest(
2909
			new String[] {
2910
				"X.java",
2911
				"/**\n" + 
2912
					" * {@value}\n" + 
2913
					" * {@value }\n" + 
2914
					" * {@value #field}\n" + 
2915
					" */\n" + 
2916
					"public class X {\n" + 
2917
					"	static int field;\n" + 
2918
					"}\n"
2919
			}
2920
		);
2921
	}
2922
	public void testBug70892conform2() {
2923
		runConformTest(
2908
		runConformTest(
2924
			new String[] {
2909
			new String[] {
2925
				"X.java",
2910
				"X.java",
2926
				"public class X {\n" + 
2911
				"public class X {\n" + 
2927
					"	/**{@value #field}*/\n" + 
2912
				"	/**\n" + 
2928
					"	static int field;\n" + 
2913
				"	 * {@value}\n" + 
2929
					"}\n"
2914
				"	 */\n" + 
2915
				"	static int field1;\n" + 
2916
				"	/**\n" + 
2917
				"	 * {@value }\n" + 
2918
				"	 */\n" + 
2919
				"	static int field2;\n" + 
2920
				"	/**\n" + 
2921
				"	 * {@value #field}\n" + 
2922
				"	 */\n" + 
2923
				"	static int field;\n" + 
2924
				"}\n"
2930
			}
2925
			}
2931
		);
2926
		);
2932
	}
2927
	}
2928
	public void testBug70892b() {
2929
		String[] testFiles = new String[] {
2930
			"X.java",
2931
			"public class X {\n" + 
2932
			"	/**\n" + 
2933
			"	 * {@value \"invalid\"}\n" + 
2934
			"	 */\n" + 
2935
			"	final static int field1 = 1;\n" + 
2936
			"	/**\n" + 
2937
			"	 * {@value <a href=\"invalid\">invalid</a>} invalid\n" + 
2938
			"	 */\n" + 
2939
			"	final static int field2 = 2;\n" + 
2940
			"	/**\n" + 
2941
			"	 * {@value #field}\n" + 
2942
			"	 */\n" + 
2943
			"	final static int field3 = 3;\n" + 
2944
			"	/**\n" + 
2945
			"	 * {@value #foo}\n" + 
2946
			"	 */\n" + 
2947
			"	final static int field4 = 4;\n" + 
2948
			"	/**\n" + 
2949
			"	 * {@value #foo()}\n" + 
2950
			"	 */\n" + 
2951
			"	final static int field5 = 5;\n" + 
2952
			"	void foo() {}\n" + 
2953
			"}\n"
2954
		};
2955
		if (this.complianceLevel.equals(COMPLIANCE_1_3) || this.complianceLevel.equals(COMPLIANCE_1_4)) {
2956
			runConformTest(testFiles);
2957
		} else {
2958
			runNegativeTest(testFiles,
2959
				"----------\n" + 
2960
				"1. ERROR in X.java (at line 3)\r\n" + 
2961
				"	* {@value \"invalid\"}\r\n" + 
2962
				"	          ^^^^^^^^^\n" + 
2963
				"Javadoc: Only static field reference is allowed for @value tag\n" + 
2964
				"----------\n" + 
2965
				"2. ERROR in X.java (at line 7)\r\n" + 
2966
				"	* {@value <a href=\"invalid\">invalid</a>} invalid\r\n" + 
2967
				"	          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
2968
				"Javadoc: Only static field reference is allowed for @value tag\n" + 
2969
				"----------\n" + 
2970
				"3. ERROR in X.java (at line 11)\r\n" + 
2971
				"	* {@value #field}\r\n" + 
2972
				"	           ^^^^^\n" + 
2973
				"Javadoc: field cannot be resolved or is not a field\n" + 
2974
				"----------\n" + 
2975
				"4. ERROR in X.java (at line 15)\r\n" + 
2976
				"	* {@value #foo}\r\n" + 
2977
				"	           ^^^\n" + 
2978
				"Javadoc: Only static field reference is allowed for @value tag\n" + 
2979
				"----------\n" + 
2980
				"5. ERROR in X.java (at line 19)\r\n" + 
2981
				"	* {@value #foo()}\r\n" + 
2982
				"	           ^^^^^\n" + 
2983
				"Javadoc: Only static field reference is allowed for @value tag\n" + 
2984
				"----------\n"
2985
			);
2986
		}
2987
	}
2933
2988
2934
	/**
2989
	/**
2935
	 * Bug 73348: [Javadoc] Missing description for return tag is not always warned
2990
	 * Bug 73348: [Javadoc] Missing description for return tag is not always warned
Lines 4815-4818 Link Here
4815
			"----------\n"
4870
			"----------\n"
4816
		);
4871
		);
4817
	}
4872
	}
4873
4874
	/**
4875
	 * @bug 153399: [javadoc] JDT Core should warn if the @value tag is not used correctly
4876
	 * @test Ensure that {@value} tag is well warned when not used correctly
4877
	 * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=153399"
4878
	 */
4879
	public void testBug153399a() {
4880
		String[] testFiles = new String[] {
4881
			"X.java",
4882
			"public class X { \n" + 
4883
			"	/**\n" + 
4884
			"	 * {@value #MY_VALUE}\n" + 
4885
			"	 */\n" + 
4886
			"	public final static int MY_VALUE = 0; \n" + 
4887
			"	/**\n" + 
4888
			"	 * {@value #MY_VALUE}\n" + 
4889
			"	 */\n" + 
4890
			"	public void foo() {}\n" + 
4891
			"	/**\n" + 
4892
			"	 * {@value #MY_VALUE}\n" + 
4893
			"	 */\n" + 
4894
			"	class Sub {} \n" + 
4895
			"}\n"
4896
		};
4897
		if (complianceLevel.equals(COMPLIANCE_1_3) || complianceLevel.equals(COMPLIANCE_1_4)) {
4898
			runNegativeTest(testFiles,
4899
				"----------\n" + 
4900
				"1. ERROR in X.java (at line 7)\n" + 
4901
				"	* {@value #MY_VALUE}\n" + 
4902
				"	    ^^^^^\n" + 
4903
				"Javadoc: Unexpected tag\n" + 
4904
				"----------\n" + 
4905
				"2. ERROR in X.java (at line 11)\n" + 
4906
				"	* {@value #MY_VALUE}\n" + 
4907
				"	    ^^^^^\n" + 
4908
				"Javadoc: Unexpected tag\n" + 
4909
				"----------\n"
4910
			);
4911
		} else {
4912
			runConformTest(testFiles);
4913
		}
4914
	}
4915
	public void testBug153399b() {
4916
		String[] testFiles = new String[] {
4917
			"X.java",
4918
			"public class X { \n" + 
4919
			"	/**\n" + 
4920
			"	 * {@value}\n" + 
4921
			"	 */\n" + 
4922
			"	public final static int MY_VALUE = 0; \n" + 
4923
			"	/**\n" + 
4924
			"	 * {@value}\n" + 
4925
			"	 */\n" + 
4926
			"	public void foo() {}\n" + 
4927
			"	/**\n" + 
4928
			"	 * {@value}\n" + 
4929
			"	 */\n" + 
4930
			"	class Sub {} \n" + 
4931
			"}\n"
4932
		};
4933
		if (complianceLevel.equals(COMPLIANCE_1_3) || complianceLevel.equals(COMPLIANCE_1_4)) {
4934
			runNegativeTest(testFiles,
4935
				"----------\n" + 
4936
				"1. ERROR in X.java (at line 7)\n" + 
4937
				"	* {@value}\n" + 
4938
				"	    ^^^^^\n" + 
4939
				"Javadoc: Unexpected tag\n" + 
4940
				"----------\n" + 
4941
				"2. ERROR in X.java (at line 11)\n" + 
4942
				"	* {@value}\n" + 
4943
				"	    ^^^^^\n" + 
4944
				"Javadoc: Unexpected tag\n" + 
4945
				"----------\n"
4946
			);
4947
		} else {
4948
			runConformTest(testFiles);
4949
		}
4950
	}
4951
	public void testBug153399c() {
4952
		String[] testFiles = new String[] {
4953
			"p1/X.java",
4954
			"package p1;\n" + 
4955
			"public class X {\n" + 
4956
			"	/**\n" + 
4957
			"	 * @return a\n" + 
4958
			"	 */\n" + 
4959
			"	boolean get() {\n" + 
4960
			"		return false;\n" + 
4961
			"	}\n" + 
4962
			"}\n"
4963
		};
4964
		runConformTest(testFiles);
4965
	}
4966
	public void testBug153399d() {
4967
		String[] testFiles = new String[] {
4968
			"X.java",
4969
			"public class X { \n" + 
4970
			"	/**\n" + 
4971
			"	 * {@value #MY_VALUE}\n" + 
4972
			"	 * {@value}\n" + 
4973
			"	 * {@value Invalid}\n" + 
4974
			"	 */\n" + 
4975
			"	public final static int MY_VALUE = 0; \n" + 
4976
			"}\n"
4977
		};
4978
		if (complianceLevel.equals(COMPLIANCE_1_3) || complianceLevel.equals(COMPLIANCE_1_4)) {
4979
			runNegativeTest(testFiles,
4980
				"----------\n" + 
4981
				"1. ERROR in X.java (at line 3)\n" + 
4982
				"	* {@value #MY_VALUE}\n" + 
4983
				"	    ^^^^^\n" + 
4984
				"Javadoc: Unexpected duplicated tag @value\n" + 
4985
				"----------\n" + 
4986
				"2. ERROR in X.java (at line 4)\n" + 
4987
				"	* {@value}\n" + 
4988
				"	    ^^^^^\n" + 
4989
				"Javadoc: Unexpected duplicated tag @value\n" + 
4990
				"----------\n"
4991
			);
4992
		} else {
4993
			runNegativeTest(testFiles,
4994
				"----------\n" + 
4995
				"1. ERROR in X.java (at line 4)\n" + 
4996
				"	* {@value}\n" + 
4997
				"	    ^^^^^\n" + 
4998
				"Javadoc: Unexpected duplicated tag @value\n" + 
4999
				"----------\n" + 
5000
				"2. ERROR in X.java (at line 5)\n" + 
5001
				"	* {@value Invalid}\n" + 
5002
				"	    ^^^^^\n" + 
5003
				"Javadoc: Unexpected duplicated tag @value\n" + 
5004
				"----------\n" + 
5005
				"3. ERROR in X.java (at line 5)\n" + 
5006
				"	* {@value Invalid}\n" + 
5007
				"	          ^^^^^^^^\n" + 
5008
				"Javadoc: Invalid reference\n" + 
5009
				"----------\n"
5010
			);
5011
		}
5012
	}
5013
	public void testBug153399e() {
5014
		String[] testFiles = new String[] {
5015
			"X.java",
5016
			"public class X { \n" + 
5017
			"	/**\n" + 
5018
			"	 * {@value Invalid}\n" + 
5019
			"	 * {@value #MY_VALUE}\n" + 
5020
			"	 */\n" + 
5021
			"	public final static int MY_VALUE = 0; \n" + 
5022
			"}\n"
5023
		};
5024
		if (complianceLevel.equals(COMPLIANCE_1_3) || complianceLevel.equals(COMPLIANCE_1_4)) {
5025
			runNegativeTest(testFiles,
5026
				"----------\n" + 
5027
				"1. ERROR in X.java (at line 3)\n" + 
5028
				"	* {@value Invalid}\n" + 
5029
				"	    ^^^^^\n" + 
5030
				"Javadoc: Unexpected duplicated tag @value\n" + 
5031
				"----------\n"
5032
			);
5033
		} else {
5034
			runNegativeTest(testFiles,
5035
				"----------\n" + 
5036
				"1. ERROR in X.java (at line 3)\n" + 
5037
				"	* {@value Invalid}\n" + 
5038
				"	    ^^^^^\n" + 
5039
				"Javadoc: Unexpected duplicated tag @value\n" + 
5040
				"----------\n" + 
5041
				"2. ERROR in X.java (at line 3)\n" + 
5042
				"	* {@value Invalid}\n" + 
5043
				"	          ^^^^^^^^\n" + 
5044
				"Javadoc: Invalid reference\n" + 
5045
				"----------\n"
5046
			);
5047
		}
5048
	}
4818
}
5049
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_4.java (-49 lines)
Lines 82-136 Link Here
82
		this.reportMissingJavadocComments = CompilerOptions.IGNORE;
82
		this.reportMissingJavadocComments = CompilerOptions.IGNORE;
83
	}
83
	}
84
84
85
	/**
86
	 * Test fix for bug 70892: [1.5][Javadoc] Compiler should parse reference for inline tag @value
87
	 * @see <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=70892">70892</a>
88
	 * These two tests pass for 1.3 or 1.4 source level but should fail for 1.5
89
	 * @see JavadocTest_1_5
90
	 */
91
	public void test001() {
92
		reportMissingJavadocTags = CompilerOptions.IGNORE;
93
		reportMissingJavadocComments = CompilerOptions.IGNORE;
94
		runNegativeTest(
95
			new String[] {
96
				"X.java",
97
				"/**\n" + 
98
					" * {@value \"invalid\"}\n" + 
99
					" * {@value <a href=\"invalid\">invalid</a>} invalid\n" + 
100
					" * {@value #field}\n" + 
101
					" * {@value #foo}\n" + 
102
					" * {@value #foo()}\n" + 
103
					" */\n" + 
104
					"public class X {\n" + 
105
					"	int field;\n" + 
106
					"	void foo() {}\n" + 
107
					"}\n"
108
			},
109
			""	// No failure in fact...
110
		);
111
	}
112
	public void test002() {
113
		reportMissingJavadocTags = CompilerOptions.IGNORE;
114
		reportMissingJavadocComments = CompilerOptions.IGNORE;
115
		runNegativeTest(
116
			new String[] {
117
				"X.java",
118
				"/**\n" + 
119
					" * {@value \"invalid}\n" + 
120
					" * {@value <a href}\n" + 
121
					" * {@value <a href=\"invalid\">invalid</a} invalid\n" + 
122
					" * {@value #fild}\n" + 
123
					" * {@value #fo}\n" + 
124
					" * {@value #f()}\n" + 
125
					" */\n" + 
126
					"public class X {\n" + 
127
					"	int field;\n" + 
128
					"	void foo() {}\n" + 
129
					"}\n"	
130
			},
131
			""	// No failure in fact...
132
		);
133
	}
134
85
135
	/**
86
	/**
136
	 * Test fix for bug 70891: [1.5][javadoc] Compiler should accept new 1.5 syntax for @param
87
	 * Test fix for bug 70891: [1.5][javadoc] Compiler should accept new 1.5 syntax for @param
(-)src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_3.java (-49 lines)
Lines 81-135 Link Here
81
		this.reportMissingJavadocComments = CompilerOptions.IGNORE;
81
		this.reportMissingJavadocComments = CompilerOptions.IGNORE;
82
	}
82
	}
83
83
84
	/**
85
	 * Test fix for bug 70892: [1.5][Javadoc] Compiler should parse reference for inline tag @value
86
	 * @see <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=70892">70892</a>
87
	 * These two tests pass for 1.3 or 1.4 source level but should fail for 1.5
88
	 * @see JavadocTest_1_5
89
	 */
90
	public void test001() {
91
		reportMissingJavadocTags = CompilerOptions.IGNORE;
92
		reportMissingJavadocComments = CompilerOptions.IGNORE;
93
		runNegativeTest(
94
			new String[] {
95
				"X.java",
96
				"/**\n" + 
97
					" * {@value \"invalid\"}\n" + 
98
					" * {@value <a href=\"invalid\">invalid</a>} invalid\n" + 
99
					" * {@value #field}\n" + 
100
					" * {@value #foo}\n" + 
101
					" * {@value #foo()}\n" + 
102
					" */\n" + 
103
					"public class X {\n" + 
104
					"	int field;\n" + 
105
					"	void foo() {}\n" + 
106
					"}\n"
107
			},
108
			""	// No failure in fact...
109
		);
110
	}
111
	public void test002() {
112
		reportMissingJavadocTags = CompilerOptions.IGNORE;
113
		reportMissingJavadocComments = CompilerOptions.IGNORE;
114
		runNegativeTest(
115
			new String[] {
116
				"X.java",
117
				"/**\n" + 
118
					" * {@value \"invalid}\n" + 
119
					" * {@value <a href}\n" + 
120
					" * {@value <a href=\"invalid\">invalid</a} invalid\n" + 
121
					" * {@value #fild}\n" + 
122
					" * {@value #fo}\n" + 
123
					" * {@value #f()}\n" + 
124
					" */\n" + 
125
					"public class X {\n" + 
126
					"	int field;\n" + 
127
					"	void foo() {}\n" + 
128
					"}\n"	
129
			},
130
			""	// No failure in fact...
131
		);
132
	}
133
84
134
	/**
85
	/**
135
	 * Test fix for bug 70891: [1.5][javadoc] Compiler should accept new 1.5 syntax for @param
86
	 * Test fix for bug 70891: [1.5][javadoc] Compiler should accept new 1.5 syntax for @param
(-)src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_5.java (-108 lines)
Lines 87-200 Link Here
87
	}
87
	}
88
88
89
	/**
89
	/**
90
	 * Test fix for bug 70892: [1.5][Javadoc] Compiler should parse reference for inline tag @value
91
	 * @see <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=70892">70892</a>
92
	 * These two tests fail for 1.5 source level but should pass for 1.3 or 1.4
93
	 * @see JavadocTest_1_4
94
	 */
95
	public void test001() {
96
		reportMissingJavadocTags = CompilerOptions.IGNORE;
97
		runNegativeTest(
98
			new String[] {
99
				"X.java",
100
				"/**\n" + 
101
					" * {@value \"invalid\"}\n" + 
102
					" * {@value <a href=\"invalid\">invalid</a>} invalid\n" + 
103
					" * {@value #field}\n" + 
104
					" * {@value #foo}\n" + 
105
					" * {@value #foo()}\n" + 
106
					" */\n" + 
107
					"public class X {\n" + 
108
					"	int field;\n" + 
109
					"	void foo() {}\n" + 
110
					"}\n"
111
			},
112
			"----------\n" + 
113
				"1. ERROR in X.java (at line 2)\n" + 
114
				"	* {@value \"invalid\"}\n" + 
115
				"	          ^^^^^^^^^\n" + 
116
				"Javadoc: Only static field reference is allowed for @value tag\n" + 
117
				"----------\n" + 
118
				"2. ERROR in X.java (at line 3)\n" + 
119
				"	* {@value <a href=\"invalid\">invalid</a>} invalid\n" + 
120
				"	          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
121
				"Javadoc: Only static field reference is allowed for @value tag\n" + 
122
				"----------\n" + 
123
				"3. ERROR in X.java (at line 4)\n" + 
124
				"	* {@value #field}\n" + 
125
				"	           ^^^^^\n" + 
126
				"Javadoc: Only static field reference is allowed for @value tag\n" + 
127
				"----------\n" + 
128
				"4. ERROR in X.java (at line 5)\n" + 
129
				"	* {@value #foo}\n" + 
130
				"	           ^^^\n" + 
131
				"Javadoc: Only static field reference is allowed for @value tag\n" + 
132
				"----------\n" + 
133
				"5. ERROR in X.java (at line 6)\n" + 
134
				"	* {@value #foo()}\n" + 
135
				"	           ^^^^^\n" + 
136
				"Javadoc: Only static field reference is allowed for @value tag\n" + 
137
				"----------\n"
138
		);
139
	}
140
	public void test002() {
141
		reportMissingJavadocTags = CompilerOptions.IGNORE;
142
		runNegativeTest(
143
			new String[] {
144
				"X.java",
145
				"/**\n" + 
146
					" * {@value \"invalid}\n" + 
147
					" * {@value <a href}\n" + 
148
					" * {@value <a href=\"invalid\">invalid</a} invalid\n" + 
149
					" * {@value #fild}\n" + 
150
					" * {@value #fo}\n" + 
151
					" * {@value #f()}\n" + 
152
					" */\n" + 
153
					"public class X {\n" + 
154
					"	int field;\n" + 
155
					"	void foo() {}\n" + 
156
					"}\n"	
157
			},
158
			"----------\n" + 
159
				"1. ERROR in X.java (at line 2)\n" + 
160
				"	* {@value \"invalid}\n" + 
161
				"	          ^^^^^^^^^\n" + 
162
				"Javadoc: Invalid reference\n" + 
163
				"----------\n" + 
164
				"2. ERROR in X.java (at line 3)\n" + 
165
				"	* {@value <a href}\n" + 
166
				"	          ^^^^^^^\n" + 
167
				"Javadoc: Only static field reference is allowed for @value tag\n" + 
168
				"----------\n" + 
169
				"3. ERROR in X.java (at line 4)\n" + 
170
				"	* {@value <a href=\"invalid\">invalid</a} invalid\n" + 
171
				"	          ^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
172
				"Javadoc: Only static field reference is allowed for @value tag\n" + 
173
				"----------\n" + 
174
				"4. ERROR in X.java (at line 5)\n" + 
175
				"	* {@value #fild}\n" + 
176
				"	           ^^^^\n" + 
177
				"Javadoc: fild cannot be resolved or is not a field\n" + 
178
				"----------\n" + 
179
				"5. ERROR in X.java (at line 6)\n" + 
180
				"	* {@value #fo}\n" + 
181
				"	           ^^\n" + 
182
				"Javadoc: fo cannot be resolved or is not a field\n" + 
183
				"----------\n" + 
184
				"6. ERROR in X.java (at line 7)\n" + 
185
				"	* {@value #f()}\n" + 
186
				"	           ^\n" + 
187
				"Javadoc: The method f() is undefined for the type X\n" + 
188
				"----------\n" + 
189
				"7. ERROR in X.java (at line 7)\n" + 
190
				"	* {@value #f()}\n" + 
191
				"	           ^^^\n" + 
192
				"Javadoc: Only static field reference is allowed for @value tag\n" + 
193
				"----------\n"
194
		);
195
	}
196
197
	/**
198
	 * Test fix for bug 70891: [1.5][javadoc] Compiler should accept new 1.5 syntax for @param
90
	 * Test fix for bug 70891: [1.5][javadoc] Compiler should accept new 1.5 syntax for @param
199
	 * @see <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=70891">70891</a>
91
	 * @see <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=70891">70891</a>
200
	 * These two tests fail for 1.5 source level but should pass for 1.3 or 1.4
92
	 * These two tests fail for 1.5 source level but should pass for 1.3 or 1.4

Return to bug 153399