eclipse-jdt / eclipse-jdt/eclipse.jdt.core

Javadoc parsing doesn't properly parse <pre>{@code .... }</pre> sequences

Open
#501 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
237
Forks
195
Avg merge
1d 12h
Merged PRs (30d)
47

Description

The following:

```
public class C {

/**
* Performs:
*

{@code

* for (String s : strings) {
* if (s.equals(value)) {
* return 0;
* }
* if (s.startsWith(value)) {
* return 1;
* }
* }
* return -1;
* }

*/
int check (String value, String[] strings) {
for (String s : strings) {
if (s.equals(value)) {
return 0;
}
if (s.startsWith(value)) {
return 1;
}
}
return -1;
}

}
```

is parsed incorrectly for the @code tag. It treats the first end curly brace (after return 0;) as the end of the @code tag and then passes TextElements for each line following. This caused the Javadoc hover to display the extraneous } before . I have made a workaround fix to JDT UI that will handle this, but it would be best if the parser could recognize such a sequence and ignore the end curly braces until it finds the one preceding .

The hover issue is currently tracked by https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/316

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.