BetaBug修复 (#1825)

* feature:调整package注入路由方法

* feature:调整package回滚路由方法

* feature:调整创建自动化代码enter重复import的问题
This commit is contained in:
PiexlMax(奇淼
2024-07-22 23:53:48 +08:00
committed by GitHub
parent 5492e0db50
commit 39be2d0351
4 changed files with 123 additions and 171 deletions

View File

@@ -69,3 +69,25 @@ func CreateStmt(statement string) *ast.ExprStmt {
}
return &ast.ExprStmt{X: expr}
}
func IsBlockStmt(node ast.Node) bool {
_, ok := node.(*ast.BlockStmt)
return ok
}
func VariableExistsInBlock(block *ast.BlockStmt, varName string) bool {
exists := false
ast.Inspect(block, func(n ast.Node) bool {
switch node := n.(type) {
case *ast.AssignStmt:
for _, expr := range node.Lhs {
if ident, ok := expr.(*ast.Ident); ok && ident.Name == varName {
exists = true
return false
}
}
}
return true
})
return exists
}