Skip to content

Commit

Permalink
process it if no errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevatkm committed May 9, 2018
1 parent edd5b35 commit 4e5fd12
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
4 changes: 4 additions & 0 deletions ainsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ func Inspect(path string, excludes ess.Excludes, registeredActions map[string]ma
errs = append(errs, err)
}

if len(errs) == 0 {
prg.process()
}

return prg, errs
}

Expand Down
50 changes: 25 additions & 25 deletions program.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,6 @@ type Program struct {
RegisteredActions map[string]map[string]uint8
}

// Process method processes all packages in the program for `Type`,
// `Embedded Type`, `Method`, etc.
func (prg *Program) Process() {
for _, pkgInfo := range prg.Packages {
pkgInfo.Types = map[string]*typeInfo{}

// Each source file
for name, file := range pkgInfo.Pkg.Files {
pkgInfo.Files = append(pkgInfo.Files, filepath.Base(name))
fileImports := make(map[string]string)

for _, decl := range file.Decls {
// Processing imports
pkgInfo.processImports(decl, fileImports)

// Processing types
pkgInfo.processTypes(decl, fileImports)

// Processing methods
processMethods(pkgInfo, prg.RegisteredActions, decl, fileImports)
}
}
}
}

// FindTypeByEmbeddedType method returns all the typeInfo that has directly or
// indirectly embedded by given type name. Type name must be fully qualified
// type name. E.g.: aahframework.org/aah.Controller
Expand Down Expand Up @@ -105,6 +80,31 @@ func (prg *Program) CreateImportPaths(types []*typeInfo, importPaths map[string]
return importPaths
}

// Process method processes all packages in the program for `Type`,
// `Embedded Type`, `Method`, etc.
func (prg *Program) process() {
for _, pkgInfo := range prg.Packages {
pkgInfo.Types = map[string]*typeInfo{}

// Each source file
for name, file := range pkgInfo.Pkg.Files {
pkgInfo.Files = append(pkgInfo.Files, filepath.Base(name))
fileImports := make(map[string]string)

for _, decl := range file.Decls {
// Processing imports
pkgInfo.processImports(decl, fileImports)

// Processing types
pkgInfo.processTypes(decl, fileImports)

// Processing methods
processMethods(pkgInfo, prg.RegisteredActions, decl, fileImports)
}
}
}
}

//‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
// TypeInfo struct and its methods
//______________________________________________________________________________
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
package ainsp

// Version no. of Go AST library for aah framework
const Version = "0.1.0"
const Version = "0.1.1"

0 comments on commit 4e5fd12

Please sign in to comment.