[Bug]: Javadoc of class missing
- Dominant language
- Java
- Stars
- 2k
- Forks
- 392
- Avg merge
- 11h 24m
- Merged PRs (30d)
- 36
Description
### Describe the bug
The javadoc of the class vanishes when it is the first thing in the file. Adding a single space in front of the `/**` solves the issue.
### Source code you are trying to analyze/transform
```Java
/**
* This {@link RunCommand} executes a run on the target.
* if (a) {
* print(a);
* }
*/
public class RunCommand {
// some comment
}
```
### Source code for your Spoon processing
```Java
import spoon.Launcher;
import spoon.reflect.CtModel;
import spoon.reflect.declaration.CtClass;
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.support.compiler.VirtualFile;
public final class Main {
private static CtModel buildModel() {
Launcher launcher = new Launcher();
launcher.addInputResource(new VirtualFile(
"""
/**
* This {@link RunCommand} executes a run on the target.
* if (a) {
* print(a);
* }
*/
public class RunCommand {
// some comment
}
""",
"RunCommand"
));
return launcher.buildModel();
}
public static void main(String[] args) {
CtModel ctModel = buildModel();
System.out.println(ctModel.getElements(new TypeFilter<>(CtClass.class)));
}
}
```
### Actual output
```Java
[// some comment
public class RunCommand {}]
Process finished with exit code 0
```
### Expected output
```Java
[/**
* This {@link RunCommand} executes a run on the target.
* if (a) {
* print(a);
* }
*/
// some comment
public class RunCommand {}]
Process finished with exit code 0
```
### Spoon Version
11.0.0
### JVM Version
openjdk version "21.0.2" 2024-01-16 LTS OpenJDK Runtime Environment Zulu21.32+17-CA (build 21.0.2+13-LTS) OpenJDK 64-Bit Server VM Zulu21.32+17-CA (build 21.0.2+13-LTS, mixed mode, sharing)
### What operating system are you using?
Windows
Contributor guide
Assessment
This issue has not been assessed yet.