Skip to content

[Question] SniperJavaPrettyPrinter, add comment to method #6665

@uvilop

Description

@uvilop

how can i add some inline-comments before a method and keep everything else unchanged, printing with SniperJavaPrettyPrinter?

i am am trying:

      CtComment cc1 = factory.createInlineComment("TEST 1");
      CtComment cc2 = factory.createInlineComment("TEST 2");
      CtComment cc3 = factory.createInlineComment("");
      method.setComments(List.of(cc1,cc2,cc3));

but this comments the method out:

 // TEST 1
 // TEST 2
 // public static void main(String[] args)

i am using 11.3.1-beta-8 and java 25.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions