INRIA / spoon

Spoon is a metaprogramming library to analyze and transform Java source code. :spoon: is made with :heart:, :beers: and :sparkles:. It parses source files to build a well-designed AST with powerful analysis and transformation API.
http://spoon.gforge.inria.fr/
Other
1.76k stars 352 forks source link

[Bug]: JDTCommentBuilder IndexOutOfBoundsException exception #6069

Closed josple closed 6 days ago

josple commented 1 week ago

Describe the bug

I am seeing errors like:

15:34:29.240 [main] ERROR spoon.Launcher - error: JDTCommentBuilder crashed with the error, some comments may be missing in the model: java.lang.IndexOutOfBoundsException: Index: -1

The error is originating from: spoon.support.compiler.jdt.JDTCommentBuilder.insertCommentInAST(...).new CtInheritanceScanner() {...}.visitCtLambda(CtLambda)

I have fixed it by replacing:

if (e.getExpression() != null)

With:

 if (e.getExpression() != null && !e.getParameters().isEmpty()) {

Source code you are trying to analyze/transform

No response

Source code for your Spoon processing

No response

Actual output

No response

Expected output

No response

Spoon Version

11.1.0

JVM Version

17

What operating system are you using?

Windows