docs: try first map

上级 2014d528
...@@ -514,8 +514,9 @@ results ...@@ -514,8 +514,9 @@ results
- [ ] GitHub search code - [ ] GitHub search code
- [ ] Pluggable - [ ] Pluggable
- [ ] plugin support - [ ] plugin support
- [ ] 3rd-party Dependence Analysis - [ ] Dependence Analysis
- [ ] analysis XML or Groovy Scripts - [ ] Deps Related Counts
- [ ] 3rd-party analysis XML or Groovy Scripts
- [ ] Groovy Support - [ ] Groovy Support
- [ ] migrate to Golang Styles - [ ] migrate to Golang Styles
......
package deps package deps
import ( import (
"fmt"
"github.com/antlr/antlr4/runtime/Go/antlr" "github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/phodal/coca/core/domain" "github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/ast/groovy" "github.com/phodal/coca/core/infrastructure/ast/groovy"
...@@ -15,8 +14,19 @@ func NewDepApp() DepApp { ...@@ -15,8 +14,19 @@ func NewDepApp() DepApp {
return *&DepApp{} return *&DepApp{}
} }
func (d *DepApp) CountDeps(deps []domain.JClassNode) { func (d *DepApp) BuildImportMap(deps []domain.JClassNode) map[string]domain.JImport {
fmt.Println(deps) var impMap = make(map[string]domain.JImport)
for _, clz := range deps {
for _, method := range clz.Methods {
for _, call := range method.MethodCalls {
if call.Package != clz.Package {
impMap[call.Package] = domain.NewJImport(call.Package)
}
}
}
}
return impMap
} }
func Analysis(str string) { func Analysis(str string) {
......
...@@ -26,7 +26,7 @@ func Test_ShouldCountDeps_WhenHadClassNodes(t *testing.T) { ...@@ -26,7 +26,7 @@ func Test_ShouldCountDeps_WhenHadClassNodes(t *testing.T) {
classNodes, _, _ := cocatest.BuildAnalysisDeps(codePath) classNodes, _, _ := cocatest.BuildAnalysisDeps(codePath)
depApp := NewDepApp() depApp := NewDepApp()
depApp.CountDeps(classNodes) importMap := depApp.BuildImportMap(classNodes)
g.Expect(true).To(Equal(true)) g.Expect(len(importMap)).To(Equal(6))
} }
package domain
type JImport struct {
source string
}
func NewJImport(str string) JImport {
return *&JImport{
source: str,
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册