Чистка: Spec обработчики вынесены в отдельный файл
Этот коммит содержится в:
родитель
55085ceb4f
коммит
b09e560a4d
2 изменённых файлов: 37 добавлений и 32 удалений
|
@ -472,23 +472,6 @@ func handleIfStmt(stmt *ast.IfStmt) string {
|
|||
return code
|
||||
}
|
||||
|
||||
func handleImportSpec(spec ast.Spec) string {
|
||||
s := spec.(*ast.ImportSpec)
|
||||
code := ""
|
||||
if s.Name != nil {
|
||||
name := handleIdent(s.Name)
|
||||
if val, ok := mapping[name]; ok {
|
||||
name = val
|
||||
}
|
||||
if name != "" {
|
||||
if name != "controller" {
|
||||
code = "#include <" + name + ".h>\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
return code
|
||||
}
|
||||
|
||||
func handleSelectorExpr(expr ast.Expr) string {
|
||||
s := expr.(*ast.SelectorExpr)
|
||||
code := ""
|
||||
|
@ -504,21 +487,6 @@ func handleSelectorExpr(expr ast.Expr) string {
|
|||
return code
|
||||
}
|
||||
|
||||
func handleSpecs(specs []ast.Spec) string {
|
||||
code := ""
|
||||
for _, spec := range specs {
|
||||
switch spec.(type) {
|
||||
case *ast.ImportSpec:
|
||||
code += handleImportSpec(spec)
|
||||
case *ast.ValueSpec:
|
||||
code += handleValueSpec(spec) + ";"
|
||||
case *ast.TypeSpec:
|
||||
code += handleTypeSpec(spec)
|
||||
}
|
||||
}
|
||||
return code
|
||||
}
|
||||
|
||||
func handleStmt(stmt ast.Stmt, standaloneAssignment bool) string {
|
||||
code := ""
|
||||
switch s := stmt.(type) {
|
||||
|
|
37
pkg/service/spec.go
Обычный файл
37
pkg/service/spec.go
Обычный файл
|
@ -0,0 +1,37 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"go/ast"
|
||||
)
|
||||
|
||||
func handleSpecs(specs []ast.Spec) string {
|
||||
code := ""
|
||||
for _, spec := range specs {
|
||||
switch spec.(type) {
|
||||
case *ast.ImportSpec:
|
||||
code += handleImportSpec(spec)
|
||||
case *ast.ValueSpec:
|
||||
code += handleValueSpec(spec) + ";"
|
||||
case *ast.TypeSpec:
|
||||
code += handleTypeSpec(spec)
|
||||
}
|
||||
}
|
||||
return code
|
||||
}
|
||||
|
||||
func handleImportSpec(spec ast.Spec) string {
|
||||
s := spec.(*ast.ImportSpec)
|
||||
code := ""
|
||||
if s.Name != nil {
|
||||
name := handleIdent(s.Name)
|
||||
if val, ok := mapping[name]; ok {
|
||||
name = val
|
||||
}
|
||||
if name != "" {
|
||||
if name != "controller" {
|
||||
code = "#include <" + name + ".h>\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
return code
|
||||
}
|
Загрузка…
Создание таблицы
Сослаться в новой задаче