Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
909426dd
C
Coca
项目概览
Phodal
/
Coca
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Coca
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
909426dd
编写于
12月 20, 2019
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: add first api call test
上级
f8389a05
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
606 addition
and
2 deletion
+606
-2
core/domain/call_graph/call_graph.go
core/domain/call_graph/call_graph.go
+1
-2
test/call_api_test.go
test/call_api_test.go
+39
-0
test/test_data/call_api_test.json
test/test_data/call_api_test.json
+566
-0
未找到文件。
core/domain/call_graph/call_graph.go
浏览文件 @
909426dd
...
@@ -16,7 +16,6 @@ func NewCallGraph() CallGraph {
...
@@ -16,7 +16,6 @@ func NewCallGraph() CallGraph {
func
(
c
CallGraph
)
Analysis
(
funcName
string
,
clzs
[]
models
.
JClassNode
)
string
{
func
(
c
CallGraph
)
Analysis
(
funcName
string
,
clzs
[]
models
.
JClassNode
)
string
{
methodMap
:=
BuildMethodMap
(
clzs
)
methodMap
:=
BuildMethodMap
(
clzs
)
chain
:=
BuildCallChain
(
funcName
,
methodMap
,
nil
)
chain
:=
BuildCallChain
(
funcName
,
methodMap
,
nil
)
dotContent
:=
ToGraphviz
(
chain
)
dotContent
:=
ToGraphviz
(
chain
)
return
dotContent
return
dotContent
...
@@ -25,7 +24,7 @@ func (c CallGraph) Analysis(funcName string, clzs []models.JClassNode) string {
...
@@ -25,7 +24,7 @@ func (c CallGraph) Analysis(funcName string, clzs []models.JClassNode) string {
// TODO: be a utils
// TODO: be a utils
func
ToGraphviz
(
chain
string
)
string
{
func
ToGraphviz
(
chain
string
)
string
{
//rankdir = LR;
//rankdir = LR;
var
result
=
"digraph G {
\n
"
var
result
=
"digraph G {
\n
"
result
=
result
+
chain
result
=
result
+
chain
result
=
result
+
"}
\n
"
result
=
result
+
"}
\n
"
return
result
return
result
...
...
test/call_api_test.go
0 → 100644
浏览文件 @
909426dd
package
test_test
import
(
"coca/core/domain/call_graph"
"coca/core/models"
"coca/core/support"
"encoding/json"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
"log"
)
var
_
=
Describe
(
"Git Parser"
,
func
()
{
Context
(
"Test for Range"
,
func
()
{
It
(
"should be a novel"
,
func
()
{
var
parsedDeps
[]
models
.
JClassNode
analyser
:=
call_graph
.
NewCallGraph
()
file
:=
support
.
ReadFile
(
"test_data/call_api_test.json"
)
if
file
==
nil
{
log
.
Fatal
(
"lost file:"
)
}
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
dotContent
:=
analyser
.
Analysis
(
"com.phodal.pholedge.book.BookController.createBook"
,
*&
parsedDeps
)
Expect
(
dotContent
)
.
To
(
Equal
(
`digraph G {
"com.phodal.pholedge.book.BookService.createBook" -> "com.phodal.pholedge.book.BookFactory.create";
"com.phodal.pholedge.book.BookService.createBook" -> "com.phodal.pholedge.book.model.command.CreateBookCommand.getIsbn";
"com.phodal.pholedge.book.BookService.createBook" -> "com.phodal.pholedge.book.model.command.CreateBookCommand.getName";
"com.phodal.pholedge.book.BookService.createBook" -> "com.phodal.pholedge.book.BookRepository.save";
"com.phodal.pholedge.book.BookService.createBook" -> "com.phodal.pholedge.book.model.Book.getId";
"com.phodal.pholedge.book.BookController.createBook" -> "com.phodal.pholedge.book.BookService.createBook";
}
`
))
})
})
})
\ No newline at end of file
test/test_data/call_api_test.json
0 → 100644
浏览文件 @
909426dd
[
{
"Package"
:
"com.phodal.pholedge.book"
,
"Class"
:
"BookController"
,
"Type"
:
"Class"
,
"Path"
:
"examples/api/BookController.java"
,
"Fields"
:
[
{
"Type"
:
"BookService"
,
"Value"
:
"applicationService"
}
],
"Methods"
:
[
{
"Name"
:
"createBook"
,
"Type"
:
"Map
\u
003cString,String
\u
003e"
,
"StartLine"
:
26
,
"StartLinePosition"
:
31
,
"StopLine"
:
28
,
"StopLinePosition"
:
41
,
"Parameters"
:
[
{
"Name"
:
"CreateBookCommand"
,
"Type"
:
"command"
}
],
"MethodCalls"
:
[
{
"Package"
:
"com.google.common.collect.ImmutableSortedMap.of"
,
"Type"
:
""
,
"Class"
:
""
,
"MethodName"
:
"of"
,
"StartLine"
:
27
,
"StartLinePosition"
:
15
,
"StopLine"
:
27
,
"StopLinePosition"
:
17
},
{
"Package"
:
"com.phodal.pholedge.book"
,
"Type"
:
"same package"
,
"Class"
:
"BookService"
,
"MethodName"
:
"createBook"
,
"StartLine"
:
27
,
"StartLinePosition"
:
43
,
"StopLine"
:
27
,
"StopLinePosition"
:
53
}
],
"Override"
:
false
,
"Annotations"
:
null
},
{
"Name"
:
"updateBook"
,
"Type"
:
"BookRepresentaion"
,
"StartLine"
:
32
,
"StartLinePosition"
:
29
,
"StopLine"
:
34
,
"StopLinePosition"
:
39
,
"Parameters"
:
[
{
"Name"
:
"String"
,
"Type"
:
"id"
},
{
"Name"
:
"UpdateBookCommand"
,
"Type"
:
"command"
}
],
"MethodCalls"
:
[
{
"Package"
:
"com.phodal.pholedge.book"
,
"Type"
:
"same package"
,
"Class"
:
"BookService"
,
"MethodName"
:
"updateBook"
,
"StartLine"
:
33
,
"StartLinePosition"
:
34
,
"StopLine"
:
33
,
"StopLinePosition"
:
44
}
],
"Override"
:
false
,
"Annotations"
:
null
},
{
"Name"
:
"getBookList"
,
"Type"
:
"List
\u
003cBookRepresentaion
\u
003e"
,
"StartLine"
:
37
,
"StartLinePosition"
:
35
,
"StopLine"
:
39
,
"StopLinePosition"
:
46
,
"Parameters"
:
null
,
"MethodCalls"
:
[
{
"Package"
:
"com.phodal.pholedge.book"
,
"Type"
:
"same package"
,
"Class"
:
"BookService"
,
"MethodName"
:
"getBooksLists"
,
"StartLine"
:
38
,
"StartLinePosition"
:
34
,
"StopLine"
:
38
,
"StopLinePosition"
:
47
}
],
"Override"
:
false
,
"Annotations"
:
null
},
{
"Name"
:
"getBookById"
,
"Type"
:
"BookRepresentaion"
,
"StartLine"
:
42
,
"StartLinePosition"
:
29
,
"StopLine"
:
44
,
"StopLinePosition"
:
40
,
"Parameters"
:
[
{
"Name"
:
"String"
,
"Type"
:
"id"
}
],
"MethodCalls"
:
[
{
"Package"
:
"com.phodal.pholedge.book"
,
"Type"
:
"same package"
,
"Class"
:
"BookService"
,
"MethodName"
:
"getBookById"
,
"StartLine"
:
43
,
"StartLinePosition"
:
34
,
"StopLine"
:
43
,
"StopLinePosition"
:
45
}
],
"Override"
:
false
,
"Annotations"
:
null
}
],
"MethodCalls"
:
[
{
"Package"
:
"com.google.common.collect.ImmutableSortedMap.of"
,
"Type"
:
""
,
"Class"
:
""
,
"MethodName"
:
"of"
,
"StartLine"
:
27
,
"StartLinePosition"
:
15
,
"StopLine"
:
27
,
"StopLinePosition"
:
17
},
{
"Package"
:
"com.phodal.pholedge.book"
,
"Type"
:
"same package"
,
"Class"
:
"BookService"
,
"MethodName"
:
"createBook"
,
"StartLine"
:
27
,
"StartLinePosition"
:
43
,
"StopLine"
:
27
,
"StopLinePosition"
:
53
},
{
"Package"
:
"com.phodal.pholedge.book"
,
"Type"
:
"same package"
,
"Class"
:
"BookService"
,
"MethodName"
:
"updateBook"
,
"StartLine"
:
33
,
"StartLinePosition"
:
34
,
"StopLine"
:
33
,
"StopLinePosition"
:
44
},
{
"Package"
:
"com.phodal.pholedge.book"
,
"Type"
:
"same package"
,
"Class"
:
"BookService"
,
"MethodName"
:
"getBooksLists"
,
"StartLine"
:
38
,
"StartLinePosition"
:
34
,
"StopLine"
:
38
,
"StopLinePosition"
:
47
},
{
"Package"
:
"com.phodal.pholedge.book"
,
"Type"
:
"same package"
,
"Class"
:
"BookService"
,
"MethodName"
:
"getBookById"
,
"StartLine"
:
43
,
"StartLinePosition"
:
34
,
"StopLine"
:
43
,
"StopLinePosition"
:
45
}
],
"Extend"
:
""
,
"Implements"
:
null
},
{
"Package"
:
"com.phodal.pholedge.book"
,
"Class"
:
"BookService"
,
"Type"
:
"Class"
,
"Path"
:
"examples/api/BookService.java"
,
"Fields"
:
[
{
"Type"
:
"BookFactory"
,
"Value"
:
"bookFactory"
},
{
"Type"
:
"BookRepository"
,
"Value"
:
"bookRepository"
}
],
"Methods"
:
[
{
"Name"
:
"getBookById"
,
"Type"
:
"BookRepresentaion"
,
"StartLine"
:
35
,
"StartLinePosition"
:
29
,
"StopLine"
:
38
,
"StopLinePosition"
:
40
,
"Parameters"
:
[
{
"Name"
:
"String"
,
"Type"
:
"id"
}
],
"MethodCalls"
:
[
{
"Package"
:
"com.phodal.pholedge.book"
,
"Type"
:
"same package"
,
"Class"
:
"BookRepository"
,
"MethodName"
:
"byId"
,
"StartLine"
:
36
,
"StartLinePosition"
:
35
,
"StopLine"
:
36
,
"StopLinePosition"
:
39
},
{
"Package"
:
"com.phodal.pholedge.book.model"
,
"Type"
:
"chain"
,
"Class"
:
"Book"
,
"MethodName"
:
"toRepresentation"
,
"StartLine"
:
37
,
"StartLinePosition"
:
20
,
"StopLine"
:
37
,
"StopLinePosition"
:
36
}
],
"Override"
:
false
,
"Annotations"
:
null
},
{
"Name"
:
"updateBook"
,
"Type"
:
"BookRepresentaion"
,
"StartLine"
:
40
,
"StartLinePosition"
:
29
,
"StopLine"
:
45
,
"StopLinePosition"
:
39
,
"Parameters"
:
[
{
"Name"
:
"String"
,
"Type"
:
"id"
},
{
"Name"
:
"UpdateBookCommand"
,
"Type"
:
"command"
}
],
"MethodCalls"
:
[
{
"Package"
:
"com.phodal.pholedge.book"
,
"Type"
:
"same package"
,
"Class"
:
"BookRepository"
,
"MethodName"
:
"byId"
,
"StartLine"
:
41
,
"StartLinePosition"
:
35
,
"StopLine"
:
41
,
"StopLinePosition"
:
39
},
{
"Package"
:
"com.phodal.pholedge.book.model"
,
"Type"
:
"chain"
,
"Class"
:
"Book"
,
"MethodName"
:
"save"
,
"StartLine"
:
42
,
"StartLinePosition"
:
13
,
"StopLine"
:
42
,
"StopLinePosition"
:
17
},
{
"Package"
:
"com.phodal.pholedge.book.model.command"
,
"Type"
:
"chain"
,
"Class"
:
"UpdateBookCommand"
,
"MethodName"
:
"getIsbn"
,
"StartLine"
:
42
,
"StartLinePosition"
:
26
,
"StopLine"
:
42
,
"StopLinePosition"
:
33
},
{
"Package"
:
"com.phodal.pholedge.book.model.command"
,
"Type"
:
"chain"
,
"Class"
:
"UpdateBookCommand"
,
"MethodName"
:
"getName"
,
"StartLine"
:
42
,
"StartLinePosition"
:
45
,
"StopLine"
:
42
,
"StopLinePosition"
:
52
},
{
"Package"
:
"com.phodal.pholedge.book"
,
"Type"
:
"same package"
,
"Class"
:
"BookRepository"
,
"MethodName"
:
"save"
,
"StartLine"
:
43
,
"StartLinePosition"
:
23
,
"StopLine"
:
43
,
"StopLinePosition"
:
27
},
{
"Package"
:
"com.phodal.pholedge.book.model"
,
"Type"
:
"chain"
,
"Class"
:
"Book"
,
"MethodName"
:
"toRepresentation"
,
"StartLine"
:
44
,
"StartLinePosition"
:
20
,
"StopLine"
:
44
,
"StopLinePosition"
:
36
}
],
"Override"
:
false
,
"Annotations"
:
null
},
{
"Name"
:
"createBook"
,
"Type"
:
"String"
,
"StartLine"
:
25
,
"StartLinePosition"
:
18
,
"StopLine"
:
29
,
"StopLinePosition"
:
28
,
"Parameters"
:
[
{
"Name"
:
"CreateBookCommand"
,
"Type"
:
"command"
}
],
"MethodCalls"
:
[
{
"Package"
:
"com.phodal.pholedge.book"
,
"Type"
:
"same package"
,
"Class"
:
"BookFactory"
,
"MethodName"
:
"create"
,
"StartLine"
:
26
,
"StartLinePosition"
:
32
,
"StopLine"
:
26
,
"StopLinePosition"
:
38
},
{
"Package"
:
"com.phodal.pholedge.book.model.command"
,
"Type"
:
"chain"
,
"Class"
:
"CreateBookCommand"
,
"MethodName"
:
"getIsbn"
,
"StartLine"
:
26
,
"StartLinePosition"
:
47
,
"StopLine"
:
26
,
"StopLinePosition"
:
54
},
{
"Package"
:
"com.phodal.pholedge.book.model.command"
,
"Type"
:
"chain"
,
"Class"
:
"CreateBookCommand"
,
"MethodName"
:
"getName"
,
"StartLine"
:
26
,
"StartLinePosition"
:
66
,
"StopLine"
:
26
,
"StopLinePosition"
:
73
},
{
"Package"
:
"com.phodal.pholedge.book"
,
"Type"
:
"same package"
,
"Class"
:
"BookRepository"
,
"MethodName"
:
"save"
,
"StartLine"
:
27
,
"StartLinePosition"
:
23
,
"StopLine"
:
27
,
"StopLinePosition"
:
27
},
{
"Package"
:
"com.phodal.pholedge.book.model"
,
"Type"
:
"chain"
,
"Class"
:
"Book"
,
"MethodName"
:
"getId"
,
"StartLine"
:
28
,
"StartLinePosition"
:
20
,
"StopLine"
:
28
,
"StopLinePosition"
:
25
}
],
"Override"
:
false
,
"Annotations"
:
null
},
{
"Name"
:
"getBooksLists"
,
"Type"
:
"List
\u
003cBookRepresentaion
\u
003e"
,
"StartLine"
:
31
,
"StartLinePosition"
:
35
,
"StopLine"
:
33
,
"StopLinePosition"
:
48
,
"Parameters"
:
null
,
"MethodCalls"
:
[
{
"Package"
:
"com.phodal.pholedge.book"
,
"Type"
:
"same package"
,
"Class"
:
"BookRepository"
,
"MethodName"
:
"list"
,
"StartLine"
:
32
,
"StartLinePosition"
:
30
,
"StopLine"
:
32
,
"StopLinePosition"
:
34
}
],
"Override"
:
false
,
"Annotations"
:
null
}
],
"MethodCalls"
:
[
{
"Package"
:
"com.phodal.pholedge.book"
,
"Type"
:
"same package"
,
"Class"
:
"BookFactory"
,
"MethodName"
:
"create"
,
"StartLine"
:
26
,
"StartLinePosition"
:
32
,
"StopLine"
:
26
,
"StopLinePosition"
:
38
},
{
"Package"
:
"com.phodal.pholedge.book.model.command"
,
"Type"
:
"chain"
,
"Class"
:
"CreateBookCommand"
,
"MethodName"
:
"getIsbn"
,
"StartLine"
:
26
,
"StartLinePosition"
:
47
,
"StopLine"
:
26
,
"StopLinePosition"
:
54
},
{
"Package"
:
"com.phodal.pholedge.book.model.command"
,
"Type"
:
"chain"
,
"Class"
:
"CreateBookCommand"
,
"MethodName"
:
"getName"
,
"StartLine"
:
26
,
"StartLinePosition"
:
66
,
"StopLine"
:
26
,
"StopLinePosition"
:
73
},
{
"Package"
:
"com.phodal.pholedge.book"
,
"Type"
:
"same package"
,
"Class"
:
"BookRepository"
,
"MethodName"
:
"save"
,
"StartLine"
:
27
,
"StartLinePosition"
:
23
,
"StopLine"
:
27
,
"StopLinePosition"
:
27
},
{
"Package"
:
"com.phodal.pholedge.book.model"
,
"Type"
:
"chain"
,
"Class"
:
"Book"
,
"MethodName"
:
"getId"
,
"StartLine"
:
28
,
"StartLinePosition"
:
20
,
"StopLine"
:
28
,
"StopLinePosition"
:
25
},
{
"Package"
:
"com.phodal.pholedge.book"
,
"Type"
:
"same package"
,
"Class"
:
"BookRepository"
,
"MethodName"
:
"list"
,
"StartLine"
:
32
,
"StartLinePosition"
:
30
,
"StopLine"
:
32
,
"StopLinePosition"
:
34
},
{
"Package"
:
"com.phodal.pholedge.book"
,
"Type"
:
"same package"
,
"Class"
:
"BookRepository"
,
"MethodName"
:
"byId"
,
"StartLine"
:
36
,
"StartLinePosition"
:
35
,
"StopLine"
:
36
,
"StopLinePosition"
:
39
},
{
"Package"
:
"com.phodal.pholedge.book.model"
,
"Type"
:
"chain"
,
"Class"
:
"Book"
,
"MethodName"
:
"toRepresentation"
,
"StartLine"
:
37
,
"StartLinePosition"
:
20
,
"StopLine"
:
37
,
"StopLinePosition"
:
36
},
{
"Package"
:
"com.phodal.pholedge.book"
,
"Type"
:
"same package"
,
"Class"
:
"BookRepository"
,
"MethodName"
:
"byId"
,
"StartLine"
:
41
,
"StartLinePosition"
:
35
,
"StopLine"
:
41
,
"StopLinePosition"
:
39
},
{
"Package"
:
"com.phodal.pholedge.book.model"
,
"Type"
:
"chain"
,
"Class"
:
"Book"
,
"MethodName"
:
"save"
,
"StartLine"
:
42
,
"StartLinePosition"
:
13
,
"StopLine"
:
42
,
"StopLinePosition"
:
17
},
{
"Package"
:
"com.phodal.pholedge.book.model.command"
,
"Type"
:
"chain"
,
"Class"
:
"UpdateBookCommand"
,
"MethodName"
:
"getIsbn"
,
"StartLine"
:
42
,
"StartLinePosition"
:
26
,
"StopLine"
:
42
,
"StopLinePosition"
:
33
},
{
"Package"
:
"com.phodal.pholedge.book.model.command"
,
"Type"
:
"chain"
,
"Class"
:
"UpdateBookCommand"
,
"MethodName"
:
"getName"
,
"StartLine"
:
42
,
"StartLinePosition"
:
45
,
"StopLine"
:
42
,
"StopLinePosition"
:
52
},
{
"Package"
:
"com.phodal.pholedge.book"
,
"Type"
:
"same package"
,
"Class"
:
"BookRepository"
,
"MethodName"
:
"save"
,
"StartLine"
:
43
,
"StartLinePosition"
:
23
,
"StopLine"
:
43
,
"StopLinePosition"
:
27
},
{
"Package"
:
"com.phodal.pholedge.book.model"
,
"Type"
:
"chain"
,
"Class"
:
"Book"
,
"MethodName"
:
"toRepresentation"
,
"StartLine"
:
44
,
"StartLinePosition"
:
20
,
"StopLine"
:
44
,
"StopLinePosition"
:
36
}
],
"Extend"
:
""
,
"Implements"
:
[
"com.phodal.pholedge.core.domain.Service"
]
}
]
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录