Skip to content

Formatting SL_COMMENT nodes #1838

Answered by shutterfreak
shutterfreak asked this question in Q&A

You must be logged in to vote

Here's my implementation which takes care of placing a SL_COMMENT that is right after a '{' node on a new line, properly indented (note: the code should also be applicable to multi-line ML_COMMENT nodes (untested)):

  /**
   * Creates hidden text edits for single-line comments after an opening brace.
   * Adjusts indentation and adds newlines as needed.
   *
   * @param previous The previous CST node.
   * @param hidden The hidden CST node (single-line comment).
   * @param formatting The formatting action.
   * @param context The formatting context.
   * @returns An array of TextEdit objects.
   */
  protected override createHiddenTextEdits(
    previous: CstNode | undefined,
    hidden: C…

Replies: 2 comments 5 replies

You must be logged in to vote
5 replies
@shutterfreak

@msujew

@shutterfreak

@msujew

@shutterfreak

You must be logged in to vote
0 replies
Answer selected by shutterfreak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants