mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-18 13:25:06 +00:00
Merge pull request #116 from notzippy/log-update
Added check to ignore functions which have no body (external functions)
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
"time"
|
"time"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"github.com/revel/revel"
|
"github.com/revel/revel"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import (
|
|||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
"github.com/revel/revel"
|
"github.com/revel/revel"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SourceInfo is the top-level struct containing all extracted information
|
// SourceInfo is the top-level struct containing all extracted information
|
||||||
@@ -222,8 +223,8 @@ func processPackage(fset *token.FileSet, pkgImportPath, pkgPath string, pkg *ast
|
|||||||
)
|
)
|
||||||
|
|
||||||
// For each source file in the package...
|
// For each source file in the package...
|
||||||
|
log.Println("Exaiming files in path", pkgPath)
|
||||||
for _, file := range pkg.Files {
|
for _, file := range pkg.Files {
|
||||||
|
|
||||||
// Imports maps the package key to the full import path.
|
// Imports maps the package key to the full import path.
|
||||||
// e.g. import "sample/app/models" => "models": "sample/app/models"
|
// e.g. import "sample/app/models" => "models": "sample/app/models"
|
||||||
imports := map[string]string{}
|
imports := map[string]string{}
|
||||||
@@ -240,8 +241,8 @@ func processPackage(fset *token.FileSet, pkgImportPath, pkgPath string, pkg *ast
|
|||||||
structSpecs = appendStruct(structSpecs, pkgImportPath, pkg, decl, imports, fset)
|
structSpecs = appendStruct(structSpecs, pkgImportPath, pkg, decl, imports, fset)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is a func...
|
// If this is a func... (ignore nil for external (non-Go) function)
|
||||||
if funcDecl, ok := decl.(*ast.FuncDecl); ok {
|
if funcDecl, ok := decl.(*ast.FuncDecl); ok && funcDecl.Body != nil {
|
||||||
// Scan it for validation calls
|
// Scan it for validation calls
|
||||||
lineKeys := getValidationKeys(fset, funcDecl, imports)
|
lineKeys := getValidationKeys(fset, funcDecl, imports)
|
||||||
if len(lineKeys) > 0 {
|
if len(lineKeys) > 0 {
|
||||||
@@ -794,7 +795,7 @@ func NewTypeExpr(pkgName string, expr ast.Expr) TypeExpr {
|
|||||||
e := NewTypeExpr(pkgName, t.Elt)
|
e := NewTypeExpr(pkgName, t.Elt)
|
||||||
return TypeExpr{"[]" + e.Expr, e.PkgName, e.pkgIndex + 2, e.Valid}
|
return TypeExpr{"[]" + e.Expr, e.PkgName, e.pkgIndex + 2, e.Valid}
|
||||||
default:
|
default:
|
||||||
revel.RevelLog.Error("Failed to generate name for field. Make sure the field name is valid.")
|
revel.RevelLog.Error("Failed to generate name for field. Make sure the field name is valid.", "package", pkgName, "expresion",expr)
|
||||||
}
|
}
|
||||||
return TypeExpr{Valid: false}
|
return TypeExpr{Valid: false}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user