diff --git a/kclvm/ast_pretty/src/node.rs b/kclvm/ast_pretty/src/node.rs index 93f77ba55..4c761aa0b 100644 --- a/kclvm/ast_pretty/src/node.rs +++ b/kclvm/ast_pretty/src/node.rs @@ -222,6 +222,7 @@ impl<'p, 'ctx> MutSelfTypedResultWalker<'ctx> for Printer<'p> { } if let Some(index_signature) = &schema_stmt.index_signature { self.fill(""); + self.write_ast_comments(index_signature); self.write_token(TokenKind::OpenDelim(DelimToken::Bracket)); if index_signature.node.any_other { self.write_token(TokenKind::DotDotDot); diff --git a/kclvm/ast_pretty/src/test_data/comment.input b/kclvm/ast_pretty/src/test_data/comment.input index 1b0de4c79..b2723ee4c 100644 --- a/kclvm/ast_pretty/src/test_data/comment.input +++ b/kclvm/ast_pretty/src/test_data/comment.input @@ -37,3 +37,9 @@ appConfiguration = AppConfiguration { overQuota: True } # Comment Nine + +schema Foo: + # Comment for index signature + [k: str]: int + # Comment for `x` field + x: int diff --git a/kclvm/ast_pretty/src/test_data/comment.output b/kclvm/ast_pretty/src/test_data/comment.output index 88172a804..b08b76655 100644 --- a/kclvm/ast_pretty/src/test_data/comment.output +++ b/kclvm/ast_pretty/src/test_data/comment.output @@ -38,3 +38,9 @@ appConfiguration = AppConfiguration { overQuota: True } # Comment Nine +schema Foo: + # comment for index signature + [k: str]: int + # comment for `x` field + x: int +