From 3260726c6aa73c99803687b22ddd24d896501d9b Mon Sep 17 00:00:00 2001 From: peefy Date: Tue, 20 Aug 2024 15:40:48 +0800 Subject: [PATCH] fix: schema index signature comment format location Signed-off-by: peefy --- kclvm/ast_pretty/src/node.rs | 1 + kclvm/ast_pretty/src/test_data/comment.input | 6 ++++++ kclvm/ast_pretty/src/test_data/comment.output | 6 ++++++ 3 files changed, 13 insertions(+) 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..15d59812d 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 +