You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
/** * This {@link RunCommand} executes a run on the target. * if (a) { * print(a); * } */publicclassRunCommand {
// some comment
}
Source code for your Spoon processing
importspoon.Launcher;
importspoon.reflect.CtModel;
importspoon.reflect.declaration.CtClass;
importspoon.reflect.visitor.filter.TypeFilter;
importspoon.support.compiler.VirtualFile;
publicfinalclassMain {
privatestaticCtModelbuildModel() {
Launcherlauncher = newLauncher();
launcher.addInputResource(newVirtualFile(
""" /** * This {@link RunCommand} executes a run on the target. * if (a) { * print(a); * } */ public class RunCommand { // some comment } """,
"RunCommand"
));
returnlauncher.buildModel();
}
publicstaticvoidmain(String[] args) {
CtModelctModel = buildModel();
System.out.println(ctModel.getElements(newTypeFilter<>(CtClass.class)));
}
}
Actual output
[// some commentpublicclassRunCommand {}]
Processfinishedwithexitcode0
Expected output
[/** * This {@link RunCommand} executes a run on the target. * if (a) { * print(a); * } */// some commentpublicclassRunCommand {}]
Processfinishedwithexitcode0
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
The text was updated successfully, but these errors were encountered:
This seems to be related to the specification of org.eclipse.jdt.internal.compiler.parser.Scanner.
If there is a whitespace at the beginning of the target file, it is consumed before proceeding to Javadoc comment, and Javadoc comment is interpreted as the start of the class definition, so to speak.
However, if there are no spaces at the beginning, Javadoc comment is processed alonely.
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
Source code for your Spoon processing
Actual output
Expected output
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
The text was updated successfully, but these errors were encountered: