eclipse-jdt / eclipse-jdt/eclipse.jdt.core
CommentRecorderParser sometimes generates ranges that miss Javadoc
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 47
Description
The given test shows that CommentRecorderParser sometimes return incorrect ranges for elements as it may fail at including the Javadoc.
```java
// Regression test for Javadoc not being included in the declaration by
// CommentRecorderParser with all those preconditions
// 1. CU has a package
// 2. Javadoc above primary type
// 3. An annotation with arrayInitializer value
// 4. Some content to recover in the CU body
public void testRecoverCommentRecorderParserIncludesJavadocInDeclaration() {
CommentRecorderParser parser = new CommentRecorderParser(new ProblemReporter(
DefaultErrorHandlingPolicies.proceedWithAllProblems(),
new CompilerOptions(getDefaultJavaCoreOptions()),
new DefaultProblemFactory(Locale.getDefault())), false);
parser.setStatementsRecovery(true);
CompilationUnitDeclaration res = parser.parse(new org.eclipse.jdt.internal.compiler.batch.CompilationUnit("""
package p;
/** some javadoc */
@SomeAnnotationWithArrayInitializer({})
public class A {
B run= new B(
}
""".toCharArray(), "A.java", Charset.defaultCharset().toString()), new CompilationResult(new char[0], 0, 0, 0));
assertEquals(11, res.types[0].declarationSourceStart);
}
```
Contributor guide
Assessment
This issue has not been assessed yet.