From ccb574673067152c12408be4e7329e088576fdea Mon Sep 17 00:00:00 2001 From: Li Jin Date: Fri, 20 Feb 2026 13:20:14 +0800 Subject: Emit class body comments in reserve-comment mode --- src/yuescript/yue_compiler.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index 1abd662..e42c75d 100644 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp @@ -9937,6 +9937,8 @@ private: std::tie(clsName, newDefined, clsTextName) = defineClassVariable(clsDecl->name); if (newDefined) varDefs.push_back(clsName); } + } else if (ast_is(item)) { + block->statementOrComments.push_back(item); } } if (!varDefs.empty()) { @@ -9990,6 +9992,14 @@ private: for (auto stmt_ : block->statementOrComments.objects()) { if (auto stmt = ast_cast(stmt_)) { transformStatement(stmt, statements); + } else if (auto comment = ast_cast(stmt_)) { + if (_config.reserveComment) { + statements.push_back(indent() + comment->to_string(&_config) + nl(comment)); + } + } else if (auto emptyLine = ast_cast(stmt_)) { + if (_config.reserveComment) { + statements.push_back(nl(emptyLine)); + } } } for (auto& member : members) { -- cgit v1.2.3-55-g6feb