-
-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: bug in comment association and pretty-printing #2482
Comments
It is a bug in JDTCommentBuilder which assigns comments and AST nodes together. it looks like it assigns correctly only first single line comment. Next are assigned wrong. |
@tempuser1909 could you make a pull request with failing test? It is then much easier/faster to fix the problem. |
@pvojtechovsky, sorry, I do not understand what do you mean by a pull request with failing test. Do you mean to include a unit test for this with a pull request? Is it under src/test/java/spoon/test/comment/CommentTest.java |
yes
yes 👍 |
Sorry for the late pull request. This is my first time writing a unit test. Please let me know if writing a more specific unit test is required. I just compared the original file with the prettyprint-ed file. |
closed by #2636 Thanks a lot @tempuser1909 for the bug report and the failing test case! |
The comments in the lambda expression are reported to have errors. An example code: import java.util.Arrays; public class CommentInLambdaExpressionTest {
} |
I just got this error messing about ;) 01:45:53.266 [main] ERROR spoon.support.compiler.jdt.JDTCommentBuilder - "/* &0xff /" cannot be added into the AST, with parent class spoon.support.reflect.code.CtVariableReadImpl at (/mnt/data/src/com/jcraft/jzlib/Deflate.java:569), please report the bug by posting on #2482 |
Thanks for posting there! Would you be able to isolate the bug in a failing test case in a pull
request?
|
On 8.0.0
|
ERROR spoon.support.compiler.jdt.JDTCommentBuilder - "// " cannot be added into the AST, with parent class spoon.support.reflect.declaration.CtAnnotationImpl Le code @Interceptor(I_M_HU_PI_Item_Product.class)
34 public class M_HU_PI_Item_Product
35 {
36 public static final transient M_HU_PI_Item_Product instance = new M_HU_PI_Item_Product();
37
38 private M_HU_PI_Item_Product()
39 {
40 }
41
42 @ModelChange(timings = ModelValidator.TYPE_AFTER_CHANGE
43 //
44 , ifColumnsChanged = { I_M_HU_PI_Item_Product.COLUMNNAME_M_Product_ID, I_M_HU_PI_Item_Product.COLUMNNAME_Description, I_M_HU_PI_Item_Product.COLUMNNAME_IsActive, I_M_HU_PI_Item_Product.COLUMNNAME_C_BPartner_ID }
45 //
46 )
47 public void updatePMM_Product(final I_M_HU_PI_Item_Product piip)
48 {
49 Services.get(IPMMProductBL.class).updateByHUPIItemProduct(piip);
50 }
51 } ` |
On 8.3.0 [ERROR] "/* inner */" cannot be added into the AST, with parent class spoon.support.reflect.declaration.CtTypeParameterImpl at (/home/ezio/testSpoon/testExample/src/cstar/testExample/CellClient2bak.java:2), please report the bug by posting on #2482 Analyzed code
|
On Spoon 10.2.0-beta-20 analyzing the following code gives the error messages:
Example code:
|
Spoon 10.3.0-beta-1
class Test {
Test() {
byte b =
// comment
// comment
(byte)
// comment
// comment
(10
// comment
// comment
| 20
// comment
// comment
);
}
} |
Hi, I am not sure if this is a bug for printing the source code with the comments.
Original:
Pretty-printed by Spoon Launcher:
So the problem is:
The text was updated successfully, but these errors were encountered: