Skip to content

Commit dfb7663

Browse files
authored
Distinguish elaboration messages on forbidden and discouraged references (eclipse-jdt#4908)
eclipse-jdt#4908
1 parent 955e7e3 commit dfb7663

9 files changed

Lines changed: 105 additions & 91 deletions

File tree

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2541,7 +2541,7 @@ public void forbiddenReference(FieldBinding field, ASTNode location,
25412541
this.handle(
25422542
problemId,
25432543
new String[] { new String(field.readableName()) }, // distinct from msg arg for quickfix purpose
2544-
getElaborationId(IProblem.ForbiddenReference, (byte) (FIELD_ACCESS | classpathEntryType)),
2544+
getElaborationId(problemId, (byte) (FIELD_ACCESS | classpathEntryType)),
25452545
new String[] {
25462546
classpathEntryName,
25472547
new String(field.shortReadableName()),
@@ -2560,7 +2560,7 @@ public void forbiddenReference(MethodBinding method, InvocationSite location,
25602560
this.handle(
25612561
problemId,
25622562
new String[] { new String(method.readableName()) }, // distinct from msg arg for quickfix purpose
2563-
getElaborationId(IProblem.ForbiddenReference, (byte) (CONSTRUCTOR_ACCESS | classpathEntryType)),
2563+
getElaborationId(problemId, (byte) (CONSTRUCTOR_ACCESS | classpathEntryType)),
25642564
new String[] {
25652565
classpathEntryName,
25662566
new String(method.shortReadableName())},
@@ -2571,7 +2571,7 @@ public void forbiddenReference(MethodBinding method, InvocationSite location,
25712571
this.handle(
25722572
problemId,
25732573
new String[] { new String(method.readableName()) }, // distinct from msg arg for quickfix purpose
2574-
getElaborationId(IProblem.ForbiddenReference, (byte) (METHOD_ACCESS | classpathEntryType)),
2574+
getElaborationId(problemId, (byte) (METHOD_ACCESS | classpathEntryType)),
25752575
new String[] {
25762576
classpathEntryName,
25772577
new String(method.shortReadableName()),
@@ -2590,7 +2590,7 @@ public void forbiddenReference(TypeBinding type, ASTNode location,
25902590
this.handle(
25912591
problemId,
25922592
new String[] { new String(type.readableName()) }, // distinct from msg arg for quickfix purpose
2593-
getElaborationId(IProblem.ForbiddenReference, /* TYPE_ACCESS | */ classpathEntryType), // TYPE_ACCESS values to 0
2593+
getElaborationId(problemId, /* TYPE_ACCESS | */ classpathEntryType), // TYPE_ACCESS values to 0
25942594
new String[] {
25952595
classpathEntryName,
25962596
new String(type.shortReadableName())},

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/messages.properties

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,15 +1225,29 @@
12251225

12261226
### ELABORATIONS
12271227
## Access restrictions
1228-
78592 = The type ''{1}'' is not API (restriction on classpath entry ''{0}'')
1229-
78593 = The type ''{1}'' is not API (restriction on required project ''{0}'')
1230-
78594 = The type ''{1}'' is not API (restriction on required library ''{0}'')
1231-
78596 = The field ''{2}.{1}'' is not API (restriction on classpath entry ''{0}'')
1232-
78597 = The field ''{2}.{1}'' is not API (restriction on required project ''{0}'')
1233-
78598 = The field ''{2}.{1}'' is not API (restriction on required library ''{0}'')
1234-
78600 = The constructor ''{1}'' is not API (restriction on classpath entry ''{0}'')
1235-
78601 = The constructor ''{1}'' is not API (restriction on required project ''{0}'')
1236-
78602 = The constructor ''{1}'' is not API (restriction on required library ''{0}'')
1237-
78604 = The method ''{2}.{1}'' is not API (restriction on classpath entry ''{0}'')
1238-
78606 = The method ''{2}.{1}'' is not API (restriction on required library ''{0}'')
1239-
78605 = The method ''{2}.{1}'' is not API (restriction on required project ''{0}'')
1228+
# Discouraged access
1229+
71680 = The type ''{1}'' is not API (restriction on classpath entry ''{0}'')
1230+
71681 = The type ''{1}'' is not API (restriction on required project ''{0}'')
1231+
71682 = The type ''{1}'' is not API (restriction on required library ''{0}'')
1232+
71684 = The field ''{2}.{1}'' is not API (restriction on classpath entry ''{0}'')
1233+
71685 = The field ''{2}.{1}'' is not API (restriction on required project ''{0}'')
1234+
71686 = The field ''{2}.{1}'' is not API (restriction on required library ''{0}'')
1235+
71688 = The constructor ''{1}'' is not API (restriction on classpath entry ''{0}'')
1236+
71689 = The constructor ''{1}'' is not API (restriction on required project ''{0}'')
1237+
71690 = The constructor ''{1}'' is not API (restriction on required library ''{0}'')
1238+
71692 = The method ''{2}.{1}'' is not API (restriction on classpath entry ''{0}'')
1239+
71693 = The method ''{2}.{1}'' is not API (restriction on required project ''{0}'')
1240+
71694 = The method ''{2}.{1}'' is not API (restriction on required library ''{0}'')
1241+
# Forbidden access
1242+
78592 = The type ''{1}'' is not accessible (restriction on classpath entry ''{0}'')
1243+
78593 = The type ''{1}'' is not accessible (restriction on required project ''{0}'')
1244+
78594 = The type ''{1}'' is not accessible (restriction on required library ''{0}'')
1245+
78596 = The field ''{2}.{1}'' is not accessible (restriction on classpath entry ''{0}'')
1246+
78597 = The field ''{2}.{1}'' is not accessible (restriction on required project ''{0}'')
1247+
78598 = The field ''{2}.{1}'' is not accessible (restriction on required library ''{0}'')
1248+
78600 = The constructor ''{1}'' is not accessible (restriction on classpath entry ''{0}'')
1249+
78601 = The constructor ''{1}'' is not accessible (restriction on required project ''{0}'')
1250+
78602 = The constructor ''{1}'' is not accessible (restriction on required library ''{0}'')
1251+
78604 = The method ''{2}.{1}'' is not accessible (restriction on classpath entry ''{0}'')
1252+
78605 = The method ''{2}.{1}'' is not accessible (restriction on required project ''{0}'')
1253+
78606 = The method ''{2}.{1}'' is not accessible (restriction on required library ''{0}'')

org.eclipse.jdt.core.tests.builder/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %pluginName
44
Bundle-SymbolicName: org.eclipse.jdt.core.tests.builder; singleton:=true
5-
Bundle-Version: 3.12.1100.qualifier
5+
Bundle-Version: 3.12.1200.qualifier
66
Bundle-Vendor: %providerName
77
Bundle-Localization: plugin
88
Export-Package: org.eclipse.jdt.core.tests.builder

org.eclipse.jdt.core.tests.builder/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<relativePath>../tests-pom/</relativePath>
1919
</parent>
2020
<artifactId>org.eclipse.jdt.core.tests.builder</artifactId>
21-
<version>3.12.1100-SNAPSHOT</version>
21+
<version>3.12.1200-SNAPSHOT</version>
2222
<packaging>eclipse-test-plugin</packaging>
2323

2424
<properties>

org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/MultiProjectTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ public void testExcludePartOfAnotherProject1() throws JavaModelException {
12831283
env.waitForManualRefresh();
12841284
fullBuild();
12851285
env.waitForAutoBuild();
1286-
expectingSpecificProblemFor(project2Path, new Problem("", "Access restriction: The type 'B' is not API (restriction on required project 'Project1')", d, 23, 35, CategorizedProblem.CAT_RESTRICTION, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$
1286+
expectingSpecificProblemFor(project2Path, new Problem("", "Access restriction: The type 'B' is not accessible (restriction on required project 'Project1')", d, 23, 35, CategorizedProblem.CAT_RESTRICTION, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$
12871287
env.removeProject(project1Path);
12881288
env.removeProject(project2Path);
12891289
}
@@ -1338,7 +1338,7 @@ public void testExcludePartOfAnotherProject2() throws JavaModelException {
13381338

13391339
incrementalBuild();
13401340
env.waitForAutoBuild();
1341-
expectingSpecificProblemFor(project2Path, new Problem("", "Access restriction: The type 'B' is not API (restriction on required project 'Project1')", d, 23, 35, CategorizedProblem.CAT_RESTRICTION, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$
1341+
expectingSpecificProblemFor(project2Path, new Problem("", "Access restriction: The type 'B' is not accessible (restriction on required project 'Project1')", d, 23, 35, CategorizedProblem.CAT_RESTRICTION, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$
13421342
env.removeProject(project1Path);
13431343
env.removeProject(project2Path);
13441344
}
@@ -1385,7 +1385,7 @@ public void testExcludePartOfAnotherProject3() throws JavaModelException {
13851385
env.waitForManualRefresh();
13861386
fullBuild();
13871387
env.waitForAutoBuild();
1388-
expectingSpecificProblemFor(project2Path, new Problem("", "Access restriction: The type 'B' is not API (restriction on required project 'Project1')", d, 23, 35, CategorizedProblem.CAT_RESTRICTION, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$
1388+
expectingSpecificProblemFor(project2Path, new Problem("", "Access restriction: The type 'B' is not accessible (restriction on required project 'Project1')", d, 23, 35, CategorizedProblem.CAT_RESTRICTION, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$
13891389

13901390
//----------------------------
13911391
// Step 2
@@ -1439,7 +1439,7 @@ public void testIncludePartOfAnotherProject1() throws JavaModelException {
14391439

14401440
fullBuild();
14411441
env.waitForAutoBuild();
1442-
expectingSpecificProblemFor(project2Path, new Problem("", "Access restriction: The type 'B' is not API (restriction on required project 'Project1')", d, 23, 35, CategorizedProblem.CAT_RESTRICTION, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$
1442+
expectingSpecificProblemFor(project2Path, new Problem("", "Access restriction: The type 'B' is not accessible (restriction on required project 'Project1')", d, 23, 35, CategorizedProblem.CAT_RESTRICTION, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$
14431443
env.removeProject(project1Path);
14441444
env.removeProject(project2Path);
14451445
}
@@ -1494,7 +1494,7 @@ public void testIncludePartOfAnotherProject2() throws JavaModelException {
14941494

14951495
incrementalBuild();
14961496
env.waitForAutoBuild();
1497-
expectingSpecificProblemFor(project2Path, new Problem("", "Access restriction: The type 'B' is not API (restriction on required project 'Project1')", d, 23, 35, CategorizedProblem.CAT_RESTRICTION, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$
1497+
expectingSpecificProblemFor(project2Path, new Problem("", "Access restriction: The type 'B' is not accessible (restriction on required project 'Project1')", d, 23, 35, CategorizedProblem.CAT_RESTRICTION, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$
14981498
env.removeProject(project1Path);
14991499
env.removeProject(project2Path);
15001500
}
@@ -1541,7 +1541,7 @@ public void testIncludePartOfAnotherProject3() throws JavaModelException {
15411541
env.waitForManualRefresh();
15421542
fullBuild();
15431543
env.waitForAutoBuild();
1544-
expectingSpecificProblemFor(project2Path, new Problem("", "Access restriction: The type 'B' is not API (restriction on required project 'Project1')", d, 23, 35, CategorizedProblem.CAT_RESTRICTION, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$
1544+
expectingSpecificProblemFor(project2Path, new Problem("", "Access restriction: The type 'B' is not accessible (restriction on required project 'Project1')", d, 23, 35, CategorizedProblem.CAT_RESTRICTION, IMarker.SEVERITY_ERROR)); //$NON-NLS-1$ //$NON-NLS-2$
15451545

15461546
//----------------------------
15471547
// Step 2

org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ public void test009(){
523523
"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 6)\n" +
524524
" KO ko;\n" +
525525
" ^^\n" +
526-
"Access restriction: The type \'KO\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" +
526+
"Access restriction: The type \'KO\' is not accessible (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" +
527527
"----------\n" +
528528
"3. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 7)\n" +
529529
" Zork z;\n" +
@@ -1584,7 +1584,7 @@ public void test019(){
15841584
"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 6)\n" +
15851585
" KO ko;\n" +
15861586
" ^^\n" +
1587-
"Access restriction: The type \'KO\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" +
1587+
"Access restriction: The type \'KO\' is not accessible (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" +
15881588
"----------\n" +
15891589
"3. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 7)\n" +
15901590
" Zork z;\n" +
@@ -1888,7 +1888,7 @@ public void test027(){
18881888
"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 6)\n" +
18891889
" KO ko;\n" +
18901890
" ^^\n" +
1891-
"Access restriction: The type \'KO\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" +
1891+
"Access restriction: The type \'KO\' is not accessible (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" +
18921892
"----------\n" +
18931893
"3. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 7)\n" +
18941894
" Zork z;\n" +
@@ -2616,7 +2616,7 @@ public void test040(){
26162616
"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/Y.java (at line 4)\n" +
26172617
" p.Z z;\n" +
26182618
" ^^^\n" +
2619-
"Access restriction: The type \'Z\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" +
2619+
"Access restriction: The type \'Z\' is not accessible (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" +
26202620
"----------\n" +
26212621
"1 problem (1 warning)\n",
26222622
false);
@@ -2665,7 +2665,7 @@ public void test041(){
26652665
"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/Y.java (at line 4)\n" +
26662666
" p.Z z;\n" +
26672667
" ^^^\n" +
2668-
"Access restriction: The type \'Z\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" +
2668+
"Access restriction: The type \'Z\' is not accessible (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" +
26692669
"----------\n" +
26702670
"1 problem (1 warning)\n",
26712671
false);
@@ -3682,7 +3682,7 @@ public void test073_per_source_output_directory(){
36823682
"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/Z.java (at line 2)\n" +
36833683
" X f;\n" +
36843684
" ^\n" +
3685-
"Access restriction: The type \'X\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---/src1\')\n" +
3685+
"Access restriction: The type \'X\' is not accessible (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---/src1\')\n" +
36863686
"----------\n" +
36873687
"1 problem (1 warning)\n",
36883688
true);
@@ -3871,7 +3871,7 @@ public void test079_per_source_output_directory(){
38713871
"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/Z.java (at line 2)\n" +
38723872
" X f;\n" +
38733873
" ^\n" +
3874-
"Access restriction: The type \'X\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---/src1\')\n" +
3874+
"Access restriction: The type \'X\' is not accessible (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---/src1\')\n" +
38753875
"----------\n" +
38763876
"1 problem (1 warning)\n",
38773877
true);
@@ -4065,7 +4065,7 @@ public void test085_per_source_output_directory(){
40654065
"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/Z.java (at line 2)\n" +
40664066
" X f;\n" +
40674067
" ^\n" +
4068-
"Access restriction: The type \'X\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---/src1\')\n" +
4068+
"Access restriction: The type \'X\' is not accessible (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---/src1\')\n" +
40694069
"----------\n" +
40704070
"1 problem (1 warning)\n",
40714071
true);
@@ -5096,27 +5096,27 @@ public void test148_access_restrictions(){
50965096
"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
50975097
" KO ko;\n" +
50985098
" ^^\n" +
5099-
"Access restriction: The type \'KO\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" +
5099+
"Access restriction: The type \'KO\' is not accessible (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" +
51005100
"----------\n" +
51015101
"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
51025102
" ko = new KO();\n" +
51035103
" ^^\n" +
5104-
"Access restriction: The type \'KO\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" +
5104+
"Access restriction: The type \'KO\' is not accessible (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" +
51055105
"----------\n" +
51065106
"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" +
51075107
" ko = new KO();\n" +
51085108
" ^^\n" +
5109-
"Access restriction: The constructor \'KO()\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" +
5109+
"Access restriction: The constructor \'KO()\' is not accessible (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" +
51105110
"----------\n" +
51115111
"4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 6)\n" +
51125112
" ko.bar();\n" +
51135113
" ^^^\n" +
5114-
"Access restriction: The method \'KO.bar()\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" +
5114+
"Access restriction: The method \'KO.bar()\' is not accessible (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" +
51155115
"----------\n" +
51165116
"5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 7)\n" +
51175117
" if (ko.m) {}\n" +
51185118
" ^\n" +
5119-
"Access restriction: The field \'KO.m\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" +
5119+
"Access restriction: The field \'KO.m\' is not accessible (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" +
51205120
"----------\n" +
51215121
"6. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 9)\n" +
51225122
" Zork z;\n" +

0 commit comments

Comments
 (0)