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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java (+117 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
	 * @bug 233187: [javadoc] partially qualified inner types  should be warned
7253
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=233187"
7254
	 */
7255
	public void testBug233187a() {
7256
		String[] units = new String[] {
7257
			"X.java",
7258
			"package test.bug;\n" + 
7259
			"\n" + 
7260
			"public class X {\n" + 
7261
			"   public static class Y {\n" + 
7262
			"        public static class Z { \n" + 
7263
			"            /**\n" + 
7264
			"             * The position in the new method signature depends on\n" + 
7265
			"             * the position in the array passed to\n" + 
7266
			"             * {@link X.Y#foo(test.bug.X.Y.Z[])} OK for javadoc tool\n" + 
7267
			"             * {@link X.Y#foo(test.bug.X.Y.Z)} KO for javadoc tool\n" + 
7268
			"             * {@link X.Y#foo(no_test.bug.X.Y.Z[])} KO for javadoc tool\n" + 
7269
			"             * {@link X.Y#foo(Y.Z[])} KO for javadoc tool\n" + 
7270
			"             * {@link test.bug.X.Y#foo(Y.Z[])} KO for javadoc tool\n" + 
7271
			"             */\n" + 
7272
			"            public int bar() {\n" + 
7273
			"                return 0;\n" + 
7274
			"            }\n" + 
7275
			"        }\n" + 
7276
			"\n" + 
7277
			"        public void foo(Z[] params) {\n" + 
7278
			"        }\n" + 
7279
			"    }\n" + 
7280
			"}\n"
7281
		};
7282
		this.reportInvalidJavadocVisibility = CompilerOptions.PUBLIC;
7283
		runNegativeTest(units,
7284
			// warning - Tag @link: can't find foo(test.bug.X.Y.Z) in test.bug.X.Y
7285
			// warning - Tag @link: can't find foo(no_test.bug.X.Y.Z[]) in test.bug.X.Y
7286
			// warning - Tag @link: can't find foo(Y.Z[]) in test.bug.X.Y
7287
			// warning - Tag @link: can't find foo(Y.Z[]) in test.bug.X.Y
7288
			"----------\n" + 
7289
			"1. ERROR in X.java (at line 10)\n" + 
7290
			"	* {@link X.Y#foo(test.bug.X.Y.Z)} KO for javadoc tool\n" + 
7291
			"	             ^^^\n" + 
7292
			"Javadoc: The method foo(X.Y.Z[]) in the type X.Y is not applicable for the arguments (X.Y.Z)\n" + 
7293
			"----------\n" + 
7294
			"2. ERROR in X.java (at line 11)\n" + 
7295
			"	* {@link X.Y#foo(no_test.bug.X.Y.Z[])} KO for javadoc tool\n" + 
7296
			"	                 ^^^^^^^^^^^^^^^^^\n" + 
7297
			"Javadoc: no_test[] cannot be resolved to a type\n" + 
7298
			"----------\n" + 
7299
			"3. ERROR in X.java (at line 12)\n" + 
7300
			"	* {@link X.Y#foo(Y.Z[])} KO for javadoc tool\n" + 
7301
			"	                 ^^^\n" + 
7302
			"Javadoc: Invalid member type qualification\n" + 
7303
			"----------\n" + 
7304
			"4. ERROR in X.java (at line 13)\n" + 
7305
			"	* {@link test.bug.X.Y#foo(Y.Z[])} KO for javadoc tool\n" + 
7306
			"	                          ^^^\n" + 
7307
			"Javadoc: Invalid member type qualification\n" + 
7308
			"----------\n"
7309
		);
7310
	}
7311
	public void testBug233187b() {
7312
		String[] units = new String[] {
7313
			"X.java",
7314
			"package test.bug;\n" + 
7315
			"\n" + 
7316
			"public class X {\n" + 
7317
			"   public static class Y {\n" + 
7318
			"        public static class Z { \n" + 
7319
			"            /**\n" + 
7320
			"             * The position in the new method signature depends on\n" + 
7321
			"             * the position in the array passed to\n" + 
7322
			"             * {@link X.Y#foo(test.bug.X.Y.Z)} OK for javadoc tool\n" +
7323
			"            * {@link X.Y#foo(test.bug.X.Y.Z[])} KO for javadoc tool\n" +
7324
			"             * {@link X.Y#foo(no_test.bug.X.Y.Z)} KO for javadoc tool\n" +
7325
			"             * {@link X.Y#foo(Y.Z)} KO for javadoc tool\n" +
7326
			"             * {@link test.bug.X.Y#foo(Y.Z)} KO for javadoc tool\n" +
7327
			"             */\n" + 
7328
			"            public int bar() {\n" + 
7329
			"                return 0;\n" + 
7330
			"            }\n" + 
7331
			"        }\n" + 
7332
			"\n" + 
7333
			"        public void foo(Z params) {\n" + 
7334
			"        }\n" + 
7335
			"    }\n" + 
7336
			"}\n"
7337
		};
7338
		this.reportInvalidJavadocVisibility = CompilerOptions.PUBLIC;
7339
		runNegativeTest(units,
7340
			// warning - Tag @link: can't find foo(test.bug.X.Y.Z[]) in test.bug.X.Y
7341
			// warning - Tag @link: can't find foo(no_test.bug.X.Y.Z) in test.bug.X.Y
7342
			// warning - Tag @link: can't find foo(Y.Z) in test.bug.X.Y
7343
			// warning - Tag @link: can't find foo(Y.Z) in test.bug.X.Y
7344
			"----------\n" + 
7345
			"1. ERROR in X.java (at line 10)\n" + 
7346
			"	* {@link X.Y#foo(test.bug.X.Y.Z[])} KO for javadoc tool\n" + 
7347
			"	             ^^^\n" + 
7348
			"Javadoc: The method foo(X.Y.Z) in the type X.Y is not applicable for the arguments (X.Y.Z[])\n" + 
7349
			"----------\n" + 
7350
			"2. ERROR in X.java (at line 11)\n" + 
7351
			"	* {@link X.Y#foo(no_test.bug.X.Y.Z)} KO for javadoc tool\n" + 
7352
			"	                 ^^^^^^^^^^^^^^^^^\n" + 
7353
			"Javadoc: no_test cannot be resolved to a type\n" + 
7354
			"----------\n" + 
7355
			"3. ERROR in X.java (at line 12)\n" + 
7356
			"	* {@link X.Y#foo(Y.Z)} KO for javadoc tool\n" + 
7357
			"	                 ^^^\n" + 
7358
			"Javadoc: Invalid member type qualification\n" + 
7359
			"----------\n" + 
7360
			"4. ERROR in X.java (at line 13)\n" + 
7361
			"	* {@link test.bug.X.Y#foo(Y.Z)} KO for javadoc tool\n" + 
7362
			"	                          ^^^\n" + 
7363
			"Javadoc: Invalid member type qualification\n" + 
7364
			"----------\n"
7365
		);
7366
	}
7250
}
7367
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/JavadocArgumentExpression.java (+16 lines)
Lines 49-54 Link Here
49
					scope.problemReporter().javadocInvalidMemberTypeQualification(this.sourceStart, this.sourceEnd, scope.getDeclarationModifiers());
49
					scope.problemReporter().javadocInvalidMemberTypeQualification(this.sourceStart, this.sourceEnd, scope.getDeclarationModifiers());
50
					// https://bugs.eclipse.org/bugs/show_bug.cgi?id=228648
50
					// https://bugs.eclipse.org/bugs/show_bug.cgi?id=228648
51
					// do not return now but report unresolved reference as expected depending on compliance settings
51
					// do not return now but report unresolved reference as expected depending on compliance settings
52
				} else if (typeRef instanceof QualifiedTypeReference && this.resolvedType != null && this.resolvedType.leafComponentType().enclosingType() != null) {
53
					// https://bugs.eclipse.org/bugs/show_bug.cgi?id=233187
54
					// inner type references should be fully qualified:
55
					// as invalid type warning will be warned later, we just need to
56
					// verify that the reference is fully qualified by comparing compare name lengths
57
					
58
					// calculate expected name length
59
					int expectedLength = 1;
60
					TypeBinding current = this.resolvedType.leafComponentType();
61
					while ((current = current.enclosingType()) != null) expectedLength++;
62
					// add package length
63
					expectedLength+=this.resolvedType.getPackage().compoundName.length;
64
					// compare lengths
65
					if (typeRef.getTypeName().length != expectedLength) {
66
						scope.problemReporter().javadocInvalidMemberTypeQualification(typeRef.sourceStart, typeRef.sourceEnd, scope.getDeclarationModifiers());
67
					}
52
				}
68
				}
53
				if (!this.resolvedType.isValidBinding()) {
69
				if (!this.resolvedType.isValidBinding()) {
54
					scope.problemReporter().javadocInvalidType(typeRef, this.resolvedType, scope.getDeclarationModifiers());
70
					scope.problemReporter().javadocInvalidType(typeRef, this.resolvedType, scope.getDeclarationModifiers());

Return to bug 233187