📦 更新lsp对tree-sitter的依赖
🚀 优化部分无关代码 🐛 修复`ast`的测试代码
This commit is contained in:
@@ -1537,7 +1537,8 @@ namespace lsp::language::ast::detail
|
||||
TSNode body_node = ts_node_child_by_field_name(node, "body", 4);
|
||||
auto body_stmt = ParseStatement(body_node, ctx);
|
||||
if (body_stmt && body_stmt->kind == NodeKind::kBlockStatement)
|
||||
stmt->body = StatementCast<BlockStatement>(std::move(body_stmt));
|
||||
stmt->body = std::unique_ptr<BlockStatement>(
|
||||
static_cast<BlockStatement*>(body_stmt.release()));
|
||||
|
||||
return stmt;
|
||||
}
|
||||
@@ -1603,10 +1604,8 @@ namespace lsp::language::ast::detail
|
||||
TSNode body_node = ts_node_child_by_field_name(node, "body", 4);
|
||||
auto body = ParseStatement(body_node, ctx);
|
||||
if (body && body->kind == NodeKind::kBlockStatement)
|
||||
{
|
||||
stmt->body = std::unique_ptr<BlockStatement>(
|
||||
static_cast<BlockStatement*>(body.release()));
|
||||
}
|
||||
|
||||
return stmt;
|
||||
}
|
||||
|
||||
@@ -184,11 +184,4 @@ namespace lsp::language::ast::detail
|
||||
// 表达式语句
|
||||
StatementPtr ParseExpressionStatement(TSNode node, ParseContext& ctx);
|
||||
|
||||
template<typename To, typename From = Statement>
|
||||
std::unique_ptr<To> StatementCast(std::unique_ptr<From>&& ptr)
|
||||
{
|
||||
static_assert(std::is_base_of_v<Statement, To>);
|
||||
return std::unique_ptr<To>(static_cast<To*>(ptr.release()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user