diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-02-20 13:20:14 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-02-20 13:20:14 +0800 |
| commit | ccb574673067152c12408be4e7329e088576fdea (patch) | |
| tree | eeda1759029bbda299aeb94b80b2fe324b666c85 /src | |
| parent | 3d1d5aad072034a7fe7dd8833835f52e7ef3e404 (diff) | |
| download | yuescript-ccb574673067152c12408be4e7329e088576fdea.tar.gz yuescript-ccb574673067152c12408be4e7329e088576fdea.tar.bz2 yuescript-ccb574673067152c12408be4e7329e088576fdea.zip | |
Emit class body comments in reserve-comment mode
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuescript/yue_compiler.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
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: | |||
| 9937 | std::tie(clsName, newDefined, clsTextName) = defineClassVariable(clsDecl->name); | 9937 | std::tie(clsName, newDefined, clsTextName) = defineClassVariable(clsDecl->name); |
| 9938 | if (newDefined) varDefs.push_back(clsName); | 9938 | if (newDefined) varDefs.push_back(clsName); |
| 9939 | } | 9939 | } |
| 9940 | } else if (ast_is<YueComment_t, EmptyLine_t>(item)) { | ||
| 9941 | block->statementOrComments.push_back(item); | ||
| 9940 | } | 9942 | } |
| 9941 | } | 9943 | } |
| 9942 | if (!varDefs.empty()) { | 9944 | if (!varDefs.empty()) { |
| @@ -9990,6 +9992,14 @@ private: | |||
| 9990 | for (auto stmt_ : block->statementOrComments.objects()) { | 9992 | for (auto stmt_ : block->statementOrComments.objects()) { |
| 9991 | if (auto stmt = ast_cast<Statement_t>(stmt_)) { | 9993 | if (auto stmt = ast_cast<Statement_t>(stmt_)) { |
| 9992 | transformStatement(stmt, statements); | 9994 | transformStatement(stmt, statements); |
| 9995 | } else if (auto comment = ast_cast<YueComment_t>(stmt_)) { | ||
| 9996 | if (_config.reserveComment) { | ||
| 9997 | statements.push_back(indent() + comment->to_string(&_config) + nl(comment)); | ||
| 9998 | } | ||
| 9999 | } else if (auto emptyLine = ast_cast<EmptyLine_t>(stmt_)) { | ||
| 10000 | if (_config.reserveComment) { | ||
| 10001 | statements.push_back(nl(emptyLine)); | ||
| 10002 | } | ||
| 9993 | } | 10003 | } |
| 9994 | } | 10004 | } |
| 9995 | for (auto& member : members) { | 10005 | for (auto& member : members) { |
