Skip to content

Commit 5c22fae

Browse files
ruspl-afedlaeubi
authored andcommitted
[#1575] EmptyStackException with javadoc on record method
* support `record` types
1 parent 2413246 commit 5c22fae

File tree

28 files changed

+921
-13
lines changed

28 files changed

+921
-13
lines changed
Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 ArSysOp.
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* Alexander Fedorov (ArSysOp) - initial API and implementation
13+
*******************************************************************************/
14+
package org.eclipse.pde.api.tools.builder.tests.tags;
15+
16+
import org.eclipse.core.runtime.IPath;
17+
import org.eclipse.jdt.core.JavaCore;
18+
import org.eclipse.pde.api.tools.internal.builder.BuilderMessages;
19+
import org.eclipse.pde.api.tools.internal.problems.ApiProblemFactory;
20+
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor;
21+
import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem;
22+
23+
import junit.framework.Test;
24+
25+
/**
26+
* Tests that the builder finds and properly reports invalid tags on records
27+
*
28+
* @since 1.4
29+
*/
30+
public class InvalidRecordTagTests extends TagTest {
31+
32+
public InvalidRecordTagTests(String name) {
33+
super(name);
34+
}
35+
36+
/**
37+
* @return the tests for this class
38+
*/
39+
public static Test suite() {
40+
return buildTestSuite(InvalidRecordTagTests.class);
41+
}
42+
43+
@Override
44+
protected String getTestingProjectName() {
45+
return "java17tags"; //$NON-NLS-1$
46+
}
47+
48+
@Override
49+
protected IPath getTestSourcePath() {
50+
return super.getTestSourcePath().append("record"); //$NON-NLS-1$
51+
}
52+
53+
@Override
54+
protected int getDefaultProblemId() {
55+
return ApiProblemFactory.createProblemId(IApiProblem.CATEGORY_USAGE, IElementDescriptor.TYPE, IApiProblem.UNSUPPORTED_TAG_USE, IApiProblem.NO_FLAGS);
56+
}
57+
58+
@Override
59+
protected String getTestCompliance() {
60+
return JavaCore.VERSION_14;
61+
}
62+
63+
public void testInvalidRecordTag1I() {
64+
x1(true);
65+
}
66+
67+
public void testInvalidRecordTag1F() {
68+
x1(false);
69+
}
70+
71+
/**
72+
* Tests having an @noreference tag on a variety of inner / outer /
73+
* top-level record in package a.b.c
74+
*/
75+
private void x1(boolean inc) {
76+
setExpectedProblemIds(getDefaultProblemSet(3));
77+
setExpectedMessageArgs(new String[][] {
78+
{ "@noreference", BuilderMessages.TagValidator_record_not_visible }, //$NON-NLS-1$
79+
{ "@noreference", BuilderMessages.TagValidator_record_not_visible }, //$NON-NLS-1$
80+
{ "@noreference", BuilderMessages.TagValidator_record_not_visible }, //$NON-NLS-1$
81+
});
82+
deployTagTest("test1.java", inc, false); //$NON-NLS-1$
83+
}
84+
85+
public void testInvalidRecordTag3I() {
86+
x3(true);
87+
}
88+
89+
public void testInvalidRecordTag3F() {
90+
x3(false);
91+
}
92+
93+
/**
94+
* Tests having an @noextend tag on a variety of inner / outer / top-level
95+
* records in package a.b.c
96+
*/
97+
private void x3(boolean inc) {
98+
setExpectedProblemIds(getDefaultProblemSet(4));
99+
setExpectedMessageArgs(new String[][] {
100+
{ "@noextend", BuilderMessages.TagValidator_a_record }, //$NON-NLS-1$
101+
{ "@noextend", BuilderMessages.TagValidator_a_record }, //$NON-NLS-1$
102+
{ "@noextend", BuilderMessages.TagValidator_a_record }, //$NON-NLS-1$
103+
{ "@noextend", BuilderMessages.TagValidator_a_record } //$NON-NLS-1$
104+
});
105+
deployTagTest("test3.java", inc, false); //$NON-NLS-1$
106+
}
107+
108+
public void testInvalidRecordTag4I() {
109+
x4(true);
110+
}
111+
112+
public void testInvalidRecordTag4F() {
113+
x4(false);
114+
}
115+
116+
/**
117+
* Tests having an @noextend tag on an record in the default package
118+
*/
119+
private void x4(boolean inc) {
120+
setExpectedProblemIds(getDefaultProblemSet(1));
121+
setExpectedMessageArgs(new String[][] { {
122+
"@noextend", BuilderMessages.TagValidator_a_record } //$NON-NLS-1$
123+
});
124+
deployTagTest("test4.java", inc, true); //$NON-NLS-1$
125+
}
126+
127+
public void testInvalidRecordTag5I() {
128+
x5(true);
129+
}
130+
131+
public void testInvalidRecordTag5F() {
132+
x5(false);
133+
}
134+
135+
/**
136+
* Tests having an @nooverride tag on a variety of inner / outer / top-level
137+
* records in package a.b.c
138+
*/
139+
private void x5(boolean inc) {
140+
setExpectedProblemIds(getDefaultProblemSet(4));
141+
setExpectedMessageArgs(new String[][] {
142+
{ "@nooverride", BuilderMessages.TagValidator_a_record }, //$NON-NLS-1$
143+
{ "@nooverride", BuilderMessages.TagValidator_a_record }, //$NON-NLS-1$
144+
{ "@nooverride", BuilderMessages.TagValidator_a_record }, //$NON-NLS-1$
145+
{ "@nooverride", BuilderMessages.TagValidator_a_record } //$NON-NLS-1$
146+
});
147+
deployTagTest("test5.java", inc, false); //$NON-NLS-1$
148+
}
149+
150+
public void testInvalidRecordTag6I() {
151+
x6(true);
152+
}
153+
154+
public void testInvalidRecordTag6F() {
155+
x6(false);
156+
}
157+
158+
/**
159+
* Tests having an @nooverride tag on a record in the default package
160+
*/
161+
private void x6(boolean inc) {
162+
setExpectedProblemIds(getDefaultProblemSet(1));
163+
setExpectedMessageArgs(new String[][] { {
164+
"@nooverride", BuilderMessages.TagValidator_a_record } //$NON-NLS-1$
165+
});
166+
deployTagTest("test6.java", inc, true); //$NON-NLS-1$
167+
}
168+
169+
public void testInvalidRecordTag7I() {
170+
x7(true);
171+
}
172+
173+
public void testInvalidRecordTag7F() {
174+
x7(false);
175+
}
176+
177+
/**
178+
* Tests having an @noinstantiate on a variety of inner / outer / top-level
179+
* records in package a.b.c
180+
*/
181+
private void x7(boolean inc) {
182+
setExpectedProblemIds(getDefaultProblemSet(4));
183+
setExpectedMessageArgs(new String[][] {
184+
{ "@noinstantiate", BuilderMessages.TagValidator_a_record }, //$NON-NLS-1$
185+
{ "@noinstantiate", BuilderMessages.TagValidator_a_record }, //$NON-NLS-1$
186+
{ "@noinstantiate", BuilderMessages.TagValidator_a_record }, //$NON-NLS-1$
187+
{ "@noinstantiate", BuilderMessages.TagValidator_a_record } //$NON-NLS-1$
188+
});
189+
deployTagTest("test7.java", inc, false); //$NON-NLS-1$
190+
}
191+
192+
public void testInvalidRecordTag8I() {
193+
x8(true);
194+
}
195+
196+
public void testInvalidRecordTag8F() {
197+
x8(false);
198+
}
199+
200+
/**
201+
* Tests having an @noinstantiate on a record in the default package
202+
*/
203+
private void x8(boolean inc) {
204+
setExpectedProblemIds(getDefaultProblemSet(1));
205+
setExpectedMessageArgs(new String[][] { {
206+
"@noinstantiate", BuilderMessages.TagValidator_a_record } //$NON-NLS-1$
207+
});
208+
deployTagTest("test8.java", inc, true); //$NON-NLS-1$
209+
}
210+
211+
public void testInvalidRecordTag9I() {
212+
x9(true);
213+
}
214+
215+
public void testInvalidRecordTag9F() {
216+
x9(false);
217+
}
218+
219+
/**
220+
* Tests having an @noimplement tag on a variety of inner / outer /
221+
* top-level records in package a.b.c
222+
*/
223+
private void x9(boolean inc) {
224+
setExpectedProblemIds(getDefaultProblemSet(4));
225+
setExpectedMessageArgs(new String[][] {
226+
{ "@noimplement", BuilderMessages.TagValidator_a_record }, //$NON-NLS-1$
227+
{ "@noimplement", BuilderMessages.TagValidator_a_record }, //$NON-NLS-1$
228+
{ "@noimplement", BuilderMessages.TagValidator_a_record }, //$NON-NLS-1$
229+
{ "@noimplement", BuilderMessages.TagValidator_a_record } //$NON-NLS-1$
230+
});
231+
deployTagTest("test9.java", inc, false); //$NON-NLS-1$
232+
}
233+
234+
public void testInvalidRecordTag10I() {
235+
x10(true);
236+
}
237+
238+
public void testInvalidRecordTag10F() {
239+
x10(false);
240+
}
241+
242+
/**
243+
* Tests having an @noimplement tag on a record in the default package
244+
*/
245+
private void x10(boolean inc) {
246+
setExpectedProblemIds(getDefaultProblemSet(1));
247+
setExpectedMessageArgs(new String[][] { {
248+
"@noimplement", BuilderMessages.TagValidator_a_record } //$NON-NLS-1$
249+
});
250+
deployTagTest("test10.java", inc, true); //$NON-NLS-1$
251+
}
252+
253+
public void testInvalidRecordTag11I() {
254+
x11(true);
255+
}
256+
257+
public void testInvalidRecordTag11F() {
258+
x11(false);
259+
}
260+
261+
/**
262+
* Tests all tags are invalid when parent record is package default
263+
*/
264+
private void x11(boolean inc) {
265+
setExpectedProblemIds(getDefaultProblemSet(1));
266+
setExpectedMessageArgs(new String[][] {
267+
{ "@noreference", BuilderMessages.TagValidator_record_not_visible } //$NON-NLS-1$
268+
});
269+
deployTagTest("test11.java", inc, true); //$NON-NLS-1$
270+
}
271+
}

apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/tags/TagTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2008, 2024 IBM Corporation and others.
2+
* Copyright (c) 2008, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
1010
*
1111
* Contributors:
1212
* IBM Corporation - initial API and implementation
13+
* Alexander Fedorov (ArSysOp) - support records
1314
*******************************************************************************/
1415
package org.eclipse.pde.api.tools.builder.tests.tags;
1516

@@ -70,6 +71,8 @@ private static Class<?>[] getAllTestClasses() {
7071
classes.add(ValidMethodTagTests.class);
7172
classes.add(ValidEnumTagTests.class);
7273
classes.add(InvalidEnumTagTests.class);
74+
classes.add(InvalidRecordTagTests.class);
75+
classes.add(ValidRecordTagTests.class);
7376
classes.add(ValidAnnotationTagTests.class);
7477
classes.add(InvalidAnnotationTagTests.class);
7578
classes.add(InvalidDuplicateTagsTests.class);
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 ArSysOp and others.
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* IBM Corporation - initial API and implementation
13+
*******************************************************************************/
14+
package org.eclipse.pde.api.tools.builder.tests.tags;
15+
16+
import org.eclipse.core.runtime.IPath;
17+
18+
import junit.framework.Test;
19+
20+
/**
21+
* Tests that the builder accepts valid tags on records
22+
*/
23+
public class ValidRecordTagTests extends InvalidRecordTagTests {
24+
25+
public ValidRecordTagTests(String name) {
26+
super(name);
27+
}
28+
29+
/**
30+
* @return the tests for this class
31+
*/
32+
public static Test suite() {
33+
return buildTestSuite(ValidRecordTagTests.class);
34+
}
35+
36+
@Override
37+
protected IPath getTestSourcePath() {
38+
return super.getTestSourcePath().append("valid"); //$NON-NLS-1$
39+
}
40+
41+
public void testValidRecordTag1I() {
42+
x1(true);
43+
}
44+
45+
@Override
46+
public void testInvalidRecordTag1F() {
47+
x1(false);
48+
}
49+
50+
/**
51+
* Tests having an @noreference tag on a record in the default package
52+
*/
53+
private void x1(boolean inc) {
54+
deployTagTest("test1.java", inc, true); //$NON-NLS-1$
55+
}
56+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
4+
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5+
<classpathentry kind="src" path="src"/>
6+
<classpathentry kind="output" path="bin"/>
7+
</classpath>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>java17tags</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.pde.ManifestBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.pde.SchemaBuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
</buildSpec>
29+
<natures>
30+
<nature>org.eclipse.pde.PluginNature</nature>
31+
<nature>org.eclipse.jdt.core.javanature</nature>
32+
<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
33+
</natures>
34+
</projectDescription>

0 commit comments

Comments
 (0)