docs: try first map

上级 2014d528
......@@ -514,8 +514,9 @@ results
- [ ] GitHub search code
- [ ] Pluggable
- [ ] plugin support
- [ ] 3rd-party Dependence Analysis
- [ ] analysis XML or Groovy Scripts
- [ ] Dependence Analysis
- [ ] Deps Related Counts
- [ ] 3rd-party analysis XML or Groovy Scripts
- [ ] Groovy Support
- [ ] migrate to Golang Styles
......
package deps
import (
"fmt"
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/phodal/coca/core/domain"
"github.com/phodal/coca/core/infrastructure/ast/groovy"
......@@ -15,8 +14,19 @@ func NewDepApp() DepApp {
return *&DepApp{}
}
func (d *DepApp) CountDeps(deps []domain.JClassNode) {
fmt.Println(deps)
func (d *DepApp) BuildImportMap(deps []domain.JClassNode) map[string]domain.JImport {
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) {
......
......@@ -26,7 +26,7 @@ func Test_ShouldCountDeps_WhenHadClassNodes(t *testing.T) {
classNodes, _, _ := cocatest.BuildAnalysisDeps(codePath)
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.
先完成此消息的编辑!
想要评论请 注册