View | Details | Raw Unified | Return to bug 176027 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java (-43 / +556 lines)
Lines 4003-4011 Link Here
4003
	 * Bug 103304: [Javadoc] Wrong reference proposal for inner classes.
4003
	 * Bug 103304: [Javadoc] Wrong reference proposal for inner classes.
4004
	 * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=103304"
4004
	 * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=103304"
4005
	 */
4005
	 */
4006
	public void testBug103304a() {
4006
	public void testBug103304a_public() {
4007
		runNegativeTest(
4007
		String[] units = new String[] {
4008
			new String[] {
4009
				"boden/IAFAState.java",
4008
				"boden/IAFAState.java",
4010
				"package boden;\n" + 
4009
				"package boden;\n" + 
4011
				"public interface IAFAState {\n" + 
4010
				"public interface IAFAState {\n" + 
Lines 4043-4067 Link Here
4043
				"	 */\n" + 
4042
				"	 */\n" + 
4044
				"	IAFAState.ValidationException valid2;\n" + 
4043
				"	IAFAState.ValidationException valid2;\n" + 
4045
				"}\n"
4044
				"}\n"
4046
			},
4045
			};
4047
			//boden\TestValid.java:8: warning - Tag @see: reference not found: ValidationException
4046
		if (complianceLevel.equals(COMPLIANCE_1_3) || complianceLevel.equals(COMPLIANCE_1_4)) {
4048
			//boden\TestValid.java:12: warning - Tag @see: reference not found: ValidationException#IAFAState.ValidationException(String, IAFAState)
4047
			runNegativeTest(units,
4049
			"----------\n" + 
4048
				//boden\TestValid.java:8: warning - Tag @see: reference not found: ValidationException
4050
			"1. ERROR in boden\\TestValid.java (at line 4)\n" + 
4049
				"----------\n" + 
4051
			"	* @see ValidationException\n" + 
4050
				"1. ERROR in boden\\TestValid.java (at line 4)\n" + 
4052
			"	       ^^^^^^^^^^^^^^^^^^^\n" + 
4051
				"	* @see ValidationException\n" + 
4053
			"Javadoc: Invalid member type qualification\n" + 
4052
				"	       ^^^^^^^^^^^^^^^^^^^\n" + 
4054
			"----------\n" + 
4053
				"Javadoc: Invalid member type qualification\n" + 
4055
			"2. ERROR in boden\\TestValid.java (at line 9)\n" + 
4054
				"----------\n" + 
4056
			"	* @see ValidationException#IAFAState.ValidationException(String, IAFAState)\n" + 
4055
				"2. ERROR in boden\\TestValid.java (at line 9)\n" + 
4057
			"	       ^^^^^^^^^^^^^^^^^^^\n" + 
4056
				"	* @see ValidationException#IAFAState.ValidationException(String, IAFAState)\n" + 
4058
			"Javadoc: Invalid member type qualification\n" + 
4057
				"	       ^^^^^^^^^^^^^^^^^^^\n" + 
4059
			"----------\n"
4058
				"Javadoc: Invalid member type qualification\n" + 
4060
		);
4059
				"----------\n"
4060
			);
4061
		} else {
4062
			runConformTest(units);
4063
		}
4061
	}
4064
	}
4065
	
4066
	public void testBug103304a_private() {
4067
		String[] units = new String[] {
4068
				"boden/IAFAState.java",
4069
				"package boden;\n" + 
4070
				"public interface IAFAState {\n" + 
4071
				"    public class ValidationException extends Exception {\n" + 
4072
				"        public ValidationException(String variableName, IAFAState subformula) {\n" + 
4073
				"            super(\"Variable \'\"+variableName+\"\' may be unbound in \'\"+subformula+\"\'\");\n" + 
4074
				"        }\n" + 
4075
				"        public void method() {}\n" + 
4076
				"    }\n" + 
4077
				"    /**\n" + 
4078
				"     * Validates a formula for consistent bindings. Bindings are consistent, when at each point in time,\n" + 
4079
				"     * the set of povided variables can be guaranteed to be a superset of the set of required variables.\n" + 
4080
				"     * @throws ValidationException Thrown if a variable is unbound. \n" + 
4081
				"     * @see ValidationException#IAFAState.ValidationException(String, IAFAState)\n" + 
4082
				"     * @see IAFAState.ValidationException#method()\n" + 
4083
				"     * @see ValidationException\n" + 
4084
				"     * {@link ValidationException}\n" + 
4085
				"     */\n" + 
4086
				"    public void validate() throws ValidationException;\n" + 
4087
				"}\n",
4088
				"boden/TestValid.java",
4089
				"package boden;\n" + 
4090
				"import boden.IAFAState.ValidationException;\n" + 
4091
				"/**\n" + 
4092
				" * @see ValidationException\n" + 
4093
				" * @see IAFAState.ValidationException\n" + 
4094
				" */\n" + 
4095
				"public class TestValid {\n" + 
4096
				"	/**  \n" + 
4097
				"	 * @see ValidationException#IAFAState.ValidationException(String, IAFAState)\n" + 
4098
				"	 */\n" + 
4099
				"	IAFAState.ValidationException valid1;\n" + 
4100
				"	/**\n" + 
4101
				"	 * @see IAFAState.ValidationException#IAFAState.ValidationException(String, IAFAState)\n" + 
4102
				"	 */\n" + 
4103
				"	IAFAState.ValidationException valid2;\n" + 
4104
				"}\n"
4105
			};
4106
		if (complianceLevel.equals(COMPLIANCE_1_3) || complianceLevel.equals(COMPLIANCE_1_4)) {
4107
			runNegativeTest(units,
4108
				//boden\TestValid.java:8: warning - Tag @see: reference not found: ValidationException
4109
				//boden\TestValid.java:12: warning - Tag @see: reference not found: ValidationException#IAFAState.ValidationException(String, IAFAState)
4110
				"----------\n" + 
4111
				"1. ERROR in boden\\TestValid.java (at line 4)\n" + 
4112
				"	* @see ValidationException\n" + 
4113
				"	       ^^^^^^^^^^^^^^^^^^^\n" + 
4114
				"Javadoc: Invalid member type qualification\n" + 
4115
				"----------\n" + 
4116
				"2. ERROR in boden\\TestValid.java (at line 9)\n" + 
4117
				"	* @see ValidationException#IAFAState.ValidationException(String, IAFAState)\n" + 
4118
				"	       ^^^^^^^^^^^^^^^^^^^\n" + 
4119
				"Javadoc: Invalid member type qualification\n" + 
4120
				"----------\n"
4121
			);
4122
		} else {
4123
			runConformTest(units);
4124
		}
4125
	}
4126
4062
	public void testBug103304b() {
4127
	public void testBug103304b() {
4063
		runNegativeTest(
4128
		this.reportInvalidJavadocVisibility = CompilerOptions.PRIVATE;
4064
			new String[] {
4129
		String[] units = new String[] {
4065
				"boden/IAFAState.java",
4130
				"boden/IAFAState.java",
4066
				"package boden;\n" + 
4131
				"package boden;\n" + 
4067
				"public interface IAFAState {\n" + 
4132
				"public interface IAFAState {\n" + 
Lines 4078-4083 Link Here
4078
				"public class TestInvalid1 {\n" + 
4143
				"public class TestInvalid1 {\n" + 
4079
				"	/** \n" + 
4144
				"	/** \n" + 
4080
				"	 * @see ValidationException#ValidationException(String, IAFAState)\n" + 
4145
				"	 * @see ValidationException#ValidationException(String, IAFAState)\n" + 
4146
				"	 * @see ValidationException#IAFAState.ValidationException(String, IAFAState)\n" +
4081
				"	 */ \n" + 
4147
				"	 */ \n" + 
4082
				"	IAFAState.ValidationException invalid;\n" + 
4148
				"	IAFAState.ValidationException invalid;\n" + 
4083
				"}\n",
4149
				"}\n",
Lines 4107-4136 Link Here
4107
				"	 */\n" + 
4173
				"	 */\n" + 
4108
				"	IAFAState.ValidationException invalid;\n" + 
4174
				"	IAFAState.ValidationException invalid;\n" + 
4109
				"}\n"
4175
				"}\n"
4110
			},
4176
			};
4111
			//boden\TestInvalid1.java:7: warning - Tag @see: reference not found: ValidationException#ValidationException(String, IAFAState)
4177
		String errors_14 = new String (
4112
			//boden\TestInvalid2.java:6: warning - Tag @see: can't find ValidationException(String, IAFAState) in boden.IAFAState.ValidationException => bug ID: 4288720
4178
				//boden\TestInvalid1.java:7: warning - Tag @see: reference not found: ValidationException#ValidationException(String, IAFAState)
4113
			//boden\TestInvalid3.java:6: warning - Tag @see: can't find IAFA.State.ValidationException(String, IAFAState) in boden.IAFAState.ValidationException
4179
				//boden\TestInvalid1.java:8: warning - Tag @see: reference not found: ValidationException#IAFAState.ValidationException(String, IAFAState)
4114
			//boden\TestInvalid4.java:6: warning - Tag @see: can't find IAFAState in boden.IAFAState.ValidationException
4180
				//boden\TestInvalid2.java:6: warning - Tag @see: can't find ValidationException(String, IAFAState) in boden.IAFAState.ValidationException => bug ID: 4288720
4115
			"----------\n" + 
4181
				//boden\TestInvalid3.java:6: warning - Tag @see: can't find IAFA.State.ValidationException(String, IAFAState) in boden.IAFAState.ValidationException
4116
			"1. ERROR in boden\\TestInvalid1.java (at line 5)\n" + 
4182
				//boden\TestInvalid4.java:6: warning - Tag @see: can't find IAFAState in boden.IAFAState.ValidationException
4117
			"	* @see ValidationException#ValidationException(String, IAFAState)\n" + 
4183
				"----------\n" + 
4118
			"	       ^^^^^^^^^^^^^^^^^^^\n" + 
4184
				"1. ERROR in boden\\TestInvalid1.java (at line 5)\n" + 
4119
			"Javadoc: Invalid member type qualification\n" + 
4185
				"	* @see ValidationException#ValidationException(String, IAFAState)\n" + 
4120
			"----------\n" + 
4186
				"	       ^^^^^^^^^^^^^^^^^^^\n" + 
4121
			"----------\n" + 
4187
				"Javadoc: Invalid member type qualification\n" + 
4122
			"1. ERROR in boden\\TestInvalid3.java (at line 5)\n" + 
4188
				"----------\n" + 
4123
			"	* @see IAFAState.ValidationException#IAFA.State.ValidationException(String, IAFAState)\n" + 
4189
				"2. ERROR in boden\\TestInvalid1.java (at line 6)\n" + 
4124
		"	                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
4190
				"	* @see ValidationException#IAFAState.ValidationException(String, IAFAState)\n" + 
4125
			"Javadoc: Invalid member type qualification\n" + 
4191
				"	       ^^^^^^^^^^^^^^^^^^^\n" + 
4126
			"----------\n" + 
4192
				"Javadoc: Invalid member type qualification\n" + 
4127
			"----------\n" + 
4193
				"----------\n" + 
4128
			"1. ERROR in boden\\TestInvalid4.java (at line 5)\n" + 
4194
				"----------\n" + 
4129
			"	* @see IAFAState.ValidationException#IAFAState .ValidationException(String, IAFAState)\n" + 
4195
				"1. ERROR in boden\\TestInvalid3.java (at line 5)\n" + 
4130
			"	                                     ^^^^^^^^^\n" + 
4196
				"	* @see IAFAState.ValidationException#IAFA.State.ValidationException(String, IAFAState)\n" + 
4131
			"Javadoc: IAFAState cannot be resolved or is not a field\n" + 
4197
				"	                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
4132
			"----------\n"
4198
				"Javadoc: Invalid member type qualification\n" + 
4199
				"----------\n" + 
4200
				"----------\n" + 
4201
				"1. ERROR in boden\\TestInvalid4.java (at line 5)\n" + 
4202
				"	* @see IAFAState.ValidationException#IAFAState .ValidationException(String, IAFAState)\n" + 
4203
				"	                                     ^^^^^^^^^\n" + 
4204
				"Javadoc: IAFAState cannot be resolved or is not a field\n" + 
4205
				"----------\n"
4206
		);
4207
		String errors_50 = new String (
4208
				//boden\TestInvalid1.java:7: warning - Tag @see: reference not found: ValidationException#ValidationException(String, IAFAState)
4209
				//boden\TestInvalid2.java:6: warning - Tag @see: can't find ValidationException(String, IAFAState) in boden.IAFAState.ValidationException => bug ID: 4288720
4210
				//boden\TestInvalid3.java:6: warning - Tag @see: can't find IAFA.State.ValidationException(String, IAFAState) in boden.IAFAState.ValidationException
4211
				//boden\TestInvalid4.java:6: warning - Tag @see: can't find IAFAState in boden.IAFAState.ValidationException
4212
				"----------\n" + 
4213
				"1. ERROR in boden\\TestInvalid3.java (at line 5)\n" + 
4214
				"	* @see IAFAState.ValidationException#IAFA.State.ValidationException(String, IAFAState)\n" + 
4215
				"	                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
4216
				"Javadoc: Invalid member type qualification\n" + 
4217
				"----------\n" + 
4218
				"----------\n" + 
4219
				"1. ERROR in boden\\TestInvalid4.java (at line 5)\n" + 
4220
				"	* @see IAFAState.ValidationException#IAFAState .ValidationException(String, IAFAState)\n" + 
4221
				"	                                     ^^^^^^^^^\n" + 
4222
				"Javadoc: IAFAState cannot be resolved or is not a field\n" + 
4223
				"----------\n"
4133
		);
4224
		);
4225
		if (complianceLevel.equals(COMPLIANCE_1_3) || complianceLevel.equals(COMPLIANCE_1_4)) {
4226
			runNegativeTest(units, errors_14);
4227
		} else {
4228
			runNegativeTest(units, errors_50);
4229
		}
4230
		
4134
	}
4231
	}
4135
	public void testBug103304c() {
4232
	public void testBug103304c() {
4136
		runConformTest(
4233
		runConformTest(
Lines 5191-5194 Link Here
5191
			);
5288
			);
5192
		}
5289
		}
5193
	}
5290
	}
5291
	
5292
	/**
5293
	 * Bug 176027: [javadoc] @link to member type handled incorrectly
5294
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=176027"
5295
	 */
5296
	public void testBug176027a() {
5297
		// case1 class X static class Inner
5298
		String[] units = new String[] {
5299
			"otherpkg/C.java",
5300
			"package otherpkg;\n" +
5301
			"public class C {\n" +
5302
			"        public static class Inner { }\n" +
5303
			"}\n"
5304
			,
5305
			"somepkg/MemberTypeDocTest.java",
5306
			"package somepkg;\n" +
5307
			"import otherpkg.C.Inner;\n" +
5308
			"/**\n" +
5309
			" * {@link Inner} -- error/warning \n" +
5310
			" */\n" +
5311
			"public class MemberTypeDocTest {\n" +
5312
			"      void m() { }\n" +
5313
			"}\n"
5314
		};
5315
		if (complianceLevel.equals(COMPLIANCE_1_3) || complianceLevel.equals(COMPLIANCE_1_4)) {
5316
			runNegativeTest(units,
5317
				//somepkg/MemberTypeDocTest.java:6: warning - Tag @link: reference not found: Inner
5318
				"----------\n" + 
5319
				"1. ERROR in somepkg\\MemberTypeDocTest.java (at line 4)\n" + 
5320
				"	* {@link Inner} -- error/warning \n" + 
5321
				"	         ^^^^^\n" + 
5322
				"Javadoc: Invalid member type qualification\n" + 
5323
				"----------\n"
5324
			);
5325
		}
5326
		else {
5327
			runConformTest(units);
5328
		}
5329
	}
5330
	
5331
	public void testBug176027b() {
5332
		// case3 class X class Inner
5333
		String[] units = new String[] {
5334
			"otherpkg/C.java",
5335
			"package otherpkg;\n" +
5336
			"public class C {\n" +
5337
			"        public class Inner { }\n" +
5338
			"}\n"
5339
			,
5340
			"somepkg/MemberTypeDocTest.java",
5341
			"package somepkg;\n" +
5342
			"import otherpkg.C.Inner;\n" +
5343
			"/**\n" +
5344
			" * {@link Inner} -- error/warning \n" +
5345
			" */\n" +
5346
			"public class MemberTypeDocTest {\n" +
5347
			"      void m() { }\n" +
5348
			"}\n"
5349
		};
5350
		if (complianceLevel.equals(COMPLIANCE_1_3) || complianceLevel.equals(COMPLIANCE_1_4)) {
5351
			runNegativeTest(units,
5352
				//somepkg/MemberTypeDocTest.java:6: warning - Tag @link: reference not found: Inner
5353
				"----------\n" + 
5354
				"1. ERROR in somepkg\\MemberTypeDocTest.java (at line 4)\n" + 
5355
				"	* {@link Inner} -- error/warning \n" + 
5356
				"	         ^^^^^\n" + 
5357
				"Javadoc: Invalid member type qualification\n" + 
5358
				"----------\n"
5359
			);
5360
		}
5361
		else {
5362
			runConformTest(units);
5363
		}
5364
	}
5365
	
5366
	public void testBug176027c() {
5367
		// case3 class X interface Inner
5368
		String[] units = new String[] {
5369
			"otherpkg/C.java",
5370
			"package otherpkg;\n" +
5371
			"public class C {\n" +
5372
			"        public interface Inner { }\n" +
5373
			"}\n"
5374
			,
5375
			"somepkg/MemberTypeDocTest.java",
5376
			"package somepkg;\n" +
5377
			"import otherpkg.C.Inner;\n" +
5378
			"/**\n" +
5379
			" * {@link Inner} -- error/warning \n" +
5380
			" */\n" +
5381
			"public class MemberTypeDocTest {\n" +
5382
			"      void m() { }\n" +
5383
			"}\n"
5384
		};
5385
		if (complianceLevel.equals(COMPLIANCE_1_3) || complianceLevel.equals(COMPLIANCE_1_4)) {
5386
			runNegativeTest(units,
5387
				//somepkg/MemberTypeDocTest.java:6: warning - Tag @link: reference not found: Inner
5388
				"----------\n" + 
5389
				"1. ERROR in somepkg\\MemberTypeDocTest.java (at line 4)\n" + 
5390
				"	* {@link Inner} -- error/warning \n" + 
5391
				"	         ^^^^^\n" + 
5392
				"Javadoc: Invalid member type qualification\n" + 
5393
				"----------\n"
5394
			);
5395
		}
5396
		else {
5397
			runConformTest(units);
5398
		}
5399
	}
5400
	
5401
	public void testBug176027d() {
5402
		// case4 interface X static class Inner
5403
		String[] units = new String[] {
5404
			"otherpkg/C.java",
5405
			"package otherpkg;\n" +
5406
			"public interface C {\n" +
5407
			"        public static class Inner { }\n" +
5408
			"}\n"
5409
			,
5410
			"somepkg/MemberTypeDocTest.java",
5411
			"package somepkg;\n" +
5412
			"import otherpkg.C.Inner;\n" +
5413
			"/**\n" +
5414
			" * {@link Inner} -- error/warning \n" +
5415
			" */\n" +
5416
			"public class MemberTypeDocTest {\n" +
5417
			"      void m() { }\n" +
5418
			"}\n"
5419
		};
5420
		if (complianceLevel.equals(COMPLIANCE_1_3) || complianceLevel.equals(COMPLIANCE_1_4)) {
5421
			runNegativeTest(units,
5422
				//somepkg/MemberTypeDocTest.java:6: warning - Tag @link: reference not found: Inner
5423
				"----------\n" + 
5424
				"1. ERROR in somepkg\\MemberTypeDocTest.java (at line 4)\n" + 
5425
				"	* {@link Inner} -- error/warning \n" + 
5426
				"	         ^^^^^\n" + 
5427
				"Javadoc: Invalid member type qualification\n" + 
5428
				"----------\n"
5429
			);
5430
		}
5431
		else {
5432
			runConformTest(units);
5433
		}
5434
	}
5435
	
5436
	public void testBug176027f() {
5437
		// case5 interface X class Inner
5438
		String[] units = new String[] {
5439
			"otherpkg/C.java",
5440
			"package otherpkg;\n" +
5441
			"public interface C {\n" +
5442
			"        public class Inner { }\n" +
5443
			"}\n"
5444
			,
5445
			"somepkg/MemberTypeDocTest.java",
5446
			"package somepkg;\n" +
5447
			"import otherpkg.C.Inner;\n" +
5448
			"/**\n" +
5449
			" * {@link Inner} -- error/warning \n" +
5450
			" */\n" +
5451
			"public class MemberTypeDocTest {\n" +
5452
			"      void m() { }\n" +
5453
			"}\n"
5454
		};
5455
		if (complianceLevel.equals(COMPLIANCE_1_3) || complianceLevel.equals(COMPLIANCE_1_4)) {
5456
			runNegativeTest(units,
5457
				//somepkg/MemberTypeDocTest.java:6: warning - Tag @link: reference not found: Inner
5458
				"----------\n" + 
5459
				"1. ERROR in somepkg\\MemberTypeDocTest.java (at line 4)\n" + 
5460
				"	* {@link Inner} -- error/warning \n" + 
5461
				"	         ^^^^^\n" + 
5462
				"Javadoc: Invalid member type qualification\n" + 
5463
				"----------\n"
5464
			);
5465
		}
5466
		else {
5467
			runConformTest(units);
5468
		}
5469
	}
5470
	
5471
	public void testBug176027g() {
5472
		// case6 interface X interface Inner
5473
		String[] units = new String[] {
5474
			"otherpkg/C.java",
5475
			"package otherpkg;\n" +
5476
			"public interface C {\n" +
5477
			"        public interface Inner { }\n" +
5478
			"}\n"
5479
			,
5480
			"somepkg/MemberTypeDocTest.java",
5481
			"package somepkg;\n" +
5482
			"import otherpkg.C.Inner;\n" +
5483
			"/**\n" +
5484
			" * {@link Inner} -- error/warning \n" +
5485
			" */\n" +
5486
			"public class MemberTypeDocTest {\n" +
5487
			"      void m() { }\n" +
5488
			"}\n"
5489
		};
5490
		if (complianceLevel.equals(COMPLIANCE_1_3) || complianceLevel.equals(COMPLIANCE_1_4)) {
5491
			runNegativeTest(units,
5492
				//somepkg/MemberTypeDocTest.java:6: warning - Tag @link: reference not found: Inner
5493
				"----------\n" + 
5494
				"1. ERROR in somepkg\\MemberTypeDocTest.java (at line 4)\n" + 
5495
				"	* {@link Inner} -- error/warning \n" + 
5496
				"	         ^^^^^\n" + 
5497
				"Javadoc: Invalid member type qualification\n" + 
5498
				"----------\n"
5499
			);
5500
		}
5501
		else {
5502
			runConformTest(units);
5503
		}
5504
	}
5505
	
5506
	public void testBug176027h_public() {
5507
		// test embedded inner classes
5508
		String[] units = new String[] {
5509
				"mainpkg/Outer.java",
5510
				"package mainpkg;\n" +
5511
				"public class Outer {\n" +
5512
				"        public class Inner {\n" +
5513
				"        	public class MostInner{\n" +
5514
				"    \n" +    		
5515
				"        	}\n" +
5516
				"        } \n" +
5517
				"}\n"
5518
				,
5519
				"pkg1/Valid1.java",
5520
				"package pkg1; \n" +
5521
				"import mainpkg.Outer.Inner.MostInner;\n" +
5522
				"// valid import - no error in 5.0\n" +
5523
				"\n" +
5524
				"/** \n" +
5525
				" * {@link MostInner}\n" +
5526
				" * \n" +
5527
				" */ \n" +
5528
				"public class Valid1 { \n" +
5529
				"	/** \n" +
5530
				"	 * {@link MostInner} \n" +
5531
				"	 * \n" +
5532
				"	 */ \n" +
5533
				"      void m() { } \n" +
5534
				"}\n"
5535
				,
5536
				"pkg2/Valid2.java",
5537
				"package pkg2; \n" +
5538
				"import mainpkg.Outer.Inner.*;\n" +
5539
				"//valid import - no error in 5.0\n" +
5540
				"\n" +
5541
				"/** \n" +
5542
				" * {@link MostInner}\n" +
5543
				" * \n" +
5544
				" */ \n" +
5545
				"public class Valid2 { \n" +
5546
				"      void m() { } \n" +
5547
				"}\n"
5548
				,
5549
				"pkg3/Invalid3.java",
5550
				"package pkg3; \n" +
5551
				"import mainpkg.Outer.*;\n" +
5552
				"//invalid import: expecting warning / error\n" +
5553
				"\n" +
5554
				"/** \n" +
5555
				" * {@link MostInner} -- error/warning  \n" +
5556
				" * \n" +
5557
				" */ \n" +
5558
				"public class Invalid3 { \n" +
5559
				"      void m() { } \n" +
5560
				"}\n"
5561
		};
5562
		
5563
		String error14 = new String (
5564
			//pkg1\Valid1.java:12: warning - Tag @link: reference not found: MostInner
5565
			//pkg2\Valid2.java:12: warning - Tag @link: reference not found: MostInner
5566
			//pkg3\Invalid3.java:12: warning - Tag @link: reference not found: MostInner
5567
			"----------\n" + 
5568
			"1. ERROR in pkg1\\Valid1.java (at line 6)\n" + 
5569
			"	* {@link MostInner}\n" + 
5570
			"	         ^^^^^^^^^\n" + 
5571
			"Javadoc: Invalid member type qualification\n" + 
5572
			"----------\n" + 
5573
			"----------\n" + 
5574
			"1. ERROR in pkg2\\Valid2.java (at line 6)\n" + 
5575
			"	* {@link MostInner}\n" + 
5576
			"	         ^^^^^^^^^\n" + 
5577
			"Javadoc: Invalid member type qualification\n" + 
5578
			"----------\n" + 
5579
			"----------\n" + 
5580
			"1. ERROR in pkg3\\Invalid3.java (at line 6)\n" + 
5581
			"	* {@link MostInner} -- error/warning  \n" + 
5582
			"	         ^^^^^^^^^\n" + 
5583
			"Javadoc: MostInner cannot be resolved to a type\n" + 
5584
			"----------\n");
5585
		
5586
		String error50 = new String (
5587
				//pkg3\Invalid3.java:12: warning - Tag @link: reference not found: MostInner
5588
				"----------\n" + 
5589
				"1. ERROR in pkg3\\Invalid3.java (at line 6)\n" + 
5590
				"	* {@link MostInner} -- error/warning  \n" + 
5591
				"	         ^^^^^^^^^\n" + 
5592
				"Javadoc: MostInner cannot be resolved to a type\n" + 
5593
				"----------\n");
5594
		
5595
		this.reportInvalidJavadocVisibility = CompilerOptions.PUBLIC;
5596
		if (complianceLevel.equals(COMPLIANCE_1_3) || complianceLevel.equals(COMPLIANCE_1_4)) {
5597
			runNegativeTest(units,error14);
5598
		}
5599
		else {
5600
			runNegativeTest(units,error50);
5601
		}
5602
	}
5603
	
5604
	public void testBug176027h_private() {
5605
		// test embedded inner classes
5606
		String[] units = new String[] {
5607
				"mainpkg/Outer.java",
5608
				"package mainpkg;\n" +
5609
				"public class Outer {\n" +
5610
				"        public class Inner {\n" +
5611
				"        	public class MostInner{\n" +
5612
				"    \n" +    		
5613
				"        	}\n" +
5614
				"        } \n" +
5615
				"}\n"
5616
				,
5617
				"pkg1/Valid1.java",
5618
				"package pkg1; \n" +
5619
				"import mainpkg.Outer.Inner.MostInner;\n" +
5620
				"// valid import - no error in 5.0\n" +
5621
				"\n" +
5622
				"/** \n" +
5623
				" * {@link MostInner}\n" +
5624
				" * \n" +
5625
				" */ \n" +
5626
				"public class Valid1 { \n" +
5627
				"	/** \n" +
5628
				"	 * {@link MostInner} \n" +
5629
				"	 * \n" +
5630
				"	 */ \n" +
5631
				"      void m() { } \n" +
5632
				"}\n"
5633
				,
5634
				"pkg2/Valid2.java",
5635
				"package pkg2; \n" +
5636
				"import mainpkg.Outer.Inner.*;\n" +
5637
				"//valid import - no error in 5.0\n" +
5638
				"\n" +
5639
				"/** \n" +
5640
				" * {@link MostInner}\n" +
5641
				" * \n" +
5642
				" */ \n" +
5643
				"public class Valid2 { \n" +
5644
				"      void m() { } \n" +
5645
				"}\n"
5646
				,
5647
				"pkg3/Invalid3.java",
5648
				"package pkg3; \n" +
5649
				"import mainpkg.Outer.*;\n" +
5650
				"//invalid import: expecting warning / error\n" +
5651
				"\n" +
5652
				"/** \n" +
5653
				" * {@link MostInner} -- error/warning  \n" +
5654
				" * \n" +
5655
				" */ \n" +
5656
				"public class Invalid3 { \n" +
5657
				"      void m() { } \n" +
5658
				"}\n"
5659
		};
5660
		
5661
		String error14 = new String(
5662
				//pkg1\Valid1.java:12: warning - Tag @link: reference not found: MostInner
5663
				//pkg1\Valid1.java:17: warning - Tag @link: reference not found: MostInner
5664
				//pkg2\Valid2.java:12: warning - Tag @link: reference not found: MostInner
5665
				//pkg3\Invalid3.java:12: warning - Tag @link: reference not found: MostInner
5666
				"----------\n" + 
5667
				"1. ERROR in pkg1\\Valid1.java (at line 6)\n" + 
5668
				"	* {@link MostInner}\n" + 
5669
				"	         ^^^^^^^^^\n" + 
5670
				"Javadoc: Invalid member type qualification\n" + 
5671
				"----------\n" + 
5672
				"2. ERROR in pkg1\\Valid1.java (at line 11)\n" + 
5673
				"	* {@link MostInner} \n" + 
5674
				"	         ^^^^^^^^^\n" + 
5675
				"Javadoc: Invalid member type qualification\n" + 
5676
				"----------\n" + 
5677
				"----------\n" + 
5678
				"1. ERROR in pkg2\\Valid2.java (at line 6)\n" + 
5679
				"	* {@link MostInner}\n" + 
5680
				"	         ^^^^^^^^^\n" + 
5681
				"Javadoc: Invalid member type qualification\n" + 
5682
				"----------\n" + 
5683
				"----------\n" + 
5684
				"1. ERROR in pkg3\\Invalid3.java (at line 6)\n" + 
5685
				"	* {@link MostInner} -- error/warning  \n" + 
5686
				"	         ^^^^^^^^^\n" + 
5687
				"Javadoc: MostInner cannot be resolved to a type\n" + 
5688
		"----------\n");
5689
		
5690
		String error50 = new String(
5691
				//pkg3\Invalid3.java:12: warning - Tag @link: reference not found: MostInner
5692
				"----------\n" + 
5693
				"1. ERROR in pkg3\\Invalid3.java (at line 6)\n" + 
5694
				"	* {@link MostInner} -- error/warning  \n" + 
5695
				"	         ^^^^^^^^^\n" + 
5696
				"Javadoc: MostInner cannot be resolved to a type\n" + 
5697
				"----------\n");
5698
		
5699
		this.reportInvalidJavadocVisibility = CompilerOptions.PRIVATE;
5700
		if (complianceLevel.equals(COMPLIANCE_1_3) || complianceLevel.equals(COMPLIANCE_1_4)) {
5701
			runNegativeTest(units,error14);
5702
		}
5703
		else {
5704
			runNegativeTest(units,error50);
5705
		}
5706
	}
5194
}
5707
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/Javadoc.java (-38 / +101 lines)
Lines 723-771 Link Here
723
		}
723
		}
724
	}
724
	}
725
725
726
	private void verifyTypeReference(Expression reference, Expression typeReference, Scope scope, boolean source15, ReferenceBinding resolvedType, int modifiers) {
726
			private void verifyTypeReference(Expression reference, Expression typeReference, Scope scope, boolean source15, ReferenceBinding resolvedType, int modifiers) {
727
		if (resolvedType.isValidBinding()) {
727
				if (resolvedType.isValidBinding()) {
728
			int scopeModifiers = -1;
728
					int scopeModifiers = -1;
729
729
		
730
			// reference must have enough visibility to be used
730
					// reference must have enough visibility to be used
731
			if (!canBeSeen(scope.problemReporter().options.reportInvalidJavadocTagsVisibility, modifiers)) {
731
					if (!canBeSeen(scope.problemReporter().options.reportInvalidJavadocTagsVisibility, modifiers)) {
732
				scope.problemReporter().javadocHiddenReference(typeReference.sourceStart, reference.sourceEnd, scope, modifiers);
732
						scope.problemReporter().javadocHiddenReference(typeReference.sourceStart, reference.sourceEnd, scope, modifiers);
733
				return;
733
						return;
734
			}
734
					}
735
735
		
736
			// type reference must have enough visibility to be used
736
					// type reference must have enough visibility to be used
737
			if (reference != typeReference) {
737
					if (reference != typeReference) {
738
				if (!canBeSeen(scope.problemReporter().options.reportInvalidJavadocTagsVisibility, resolvedType.modifiers)) {
738
						if (!canBeSeen(scope.problemReporter().options.reportInvalidJavadocTagsVisibility, resolvedType.modifiers)) {
739
					scope.problemReporter().javadocHiddenReference(typeReference.sourceStart, typeReference.sourceEnd, scope, resolvedType.modifiers);
739
							scope.problemReporter().javadocHiddenReference(typeReference.sourceStart, typeReference.sourceEnd, scope, resolvedType.modifiers);
740
					return;
741
				}
742
			}
743
744
			// member types
745
			if (resolvedType.isMemberType()) {
746
				ReferenceBinding topLevelType = resolvedType;
747
				int depth = 0;
748
				while (topLevelType.enclosingType() != null) {
749
					topLevelType = topLevelType.enclosingType();
750
					depth++;
751
				}
752
				ClassScope topLevelScope = scope.classScope();
753
				// when scope is not on compilation unit type, then inner class may not be visible...
754
				if (topLevelScope.parent.kind != Scope.COMPILATION_UNIT_SCOPE ||
755
					!CharOperation.equals(topLevelType.sourceName, topLevelScope.referenceContext.name)) {
756
					topLevelScope = topLevelScope.outerMostClassScope();
757
					if (typeReference instanceof JavadocSingleTypeReference) {
758
						// inner class single reference can only be done in same unit
759
						if ((!source15 && depth == 1) || topLevelType != topLevelScope.referenceContext.binding) {
760
							if (scopeModifiers == -1) scopeModifiers = scope.getDeclarationModifiers();
761
							scope.problemReporter().javadocInvalidMemberTypeQualification(typeReference.sourceStart, typeReference.sourceEnd, scopeModifiers);
762
							return;
740
							return;
763
						}
741
						}
764
					}
742
					}
743
					
744
					// member types
745
					if (resolvedType.isMemberType()) {
746
						ReferenceBinding topLevelType = resolvedType;
747
						// rebuild and store (in reverse order) compound name to handle embedded inner class
748
						int idx = resolvedType.depth()+topLevelType.getPackage().compoundName.length;
749
						char[][] computedCompoundName = new char[idx+1][];
750
						computedCompoundName[idx] = topLevelType.sourceName;
751
						int depth = 0;
752
						while (topLevelType.enclosingType() != null) {
753
							topLevelType = topLevelType.enclosingType();
754
							depth++;
755
							idx--;
756
							computedCompoundName[idx] = topLevelType.sourceName;
757
						}
758
						
759
						// add package information
760
						idx--;
761
						for (int i = topLevelType.getPackage().compoundName.length; --i >= 0;) {
762
							computedCompoundName[idx] = topLevelType.getPackage().compoundName[i];
763
							idx--;
764
						}
765
												
766
						ClassScope topLevelScope = scope.classScope();
767
						// when scope is not on compilation unit type, then inner class may not be visible...
768
						if (topLevelScope.parent.kind != Scope.COMPILATION_UNIT_SCOPE ||
769
							!CharOperation.equals(topLevelType.sourceName, topLevelScope.referenceContext.name)) {
770
							topLevelScope = topLevelScope.outerMostClassScope();
771
							if (typeReference instanceof JavadocSingleTypeReference) {
772
								// inner class single reference can only be done in same unit
773
								if ((!source15 && depth == 1) || topLevelType != topLevelScope.referenceContext.binding) {
774
									// search for corresponding import
775
									boolean hasValidImport = false;
776
									boolean extendsEnclosingTypeOrInterface = false;
777
									if (source15) {
778
										CompilationUnitScope unitScope = topLevelScope.compilationUnitScope();
779
										ImportBinding[] imports = unitScope.imports;
780
										int length = imports == null ? 0 : imports.length;
781
										for (int i=0; i<length; i++) {
782
											if (hasValidImport) { // break the loop as soon as valid import found
783
												break;
784
											}
785
											boolean invalidImport = false;
786
											if (imports[i].onDemand) {
787
												if (! hasValidImport && (imports[i].compoundName.length == (computedCompoundName.length-1))) {
788
													for (int j = imports[i].compoundName.length; --j >= 0;) {
789
														if (!CharOperation.equals(imports[i].compoundName[j], computedCompoundName[j])) {
790
															invalidImport = true;
791
															break;	
792
														}
793
													}
794
													if (! invalidImport) {
795
														hasValidImport = true;
796
													}
797
												}
798
											} else {
799
												// compare import and enclosingtype compoundnames
800
												char[][] compoundName = imports[i].compoundName;
801
												if (compoundName.length > 1) {
802
													if (computedCompoundName == compoundName) {
803
														hasValidImport = true;
804
													}
805
													if (! hasValidImport && (computedCompoundName.length == compoundName.length)) {
806
														for (int j = computedCompoundName.length; --j >= 0;) {
807
															if (!CharOperation.equals(computedCompoundName[j], compoundName[j])) {
808
																invalidImport = true;
809
																break;	
810
															}
811
														}
812
														if (! invalidImport) {
813
															hasValidImport = true;
814
														}
815
													}																					
816
												}
817
											
818
											}
819
										}
820
									}
821
									if (! source15  || (source15 && (!hasValidImport || extendsEnclosingTypeOrInterface))) { // no valid import, no superclass or interface --> report error 
822
										if (scopeModifiers == -1) scopeModifiers = scope.getDeclarationModifiers();
823
										scope.problemReporter().javadocInvalidMemberTypeQualification(typeReference.sourceStart, typeReference.sourceEnd, scopeModifiers);
824
										return;
825
									}
826
								}
827
							}
828
						}
829
					}
765
				}
830
				}
766
			}
831
			}
767
		}
768
	}
769
832
770
	public void traverse(ASTVisitor visitor, BlockScope scope) {
833
	public void traverse(ASTVisitor visitor, BlockScope scope) {
771
		if (visitor.visit(this, scope)) {
834
		if (visitor.visit(this, scope)) {

Return to bug 176027