Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
e0d7f484
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 搜索 >>
未验证
提交
e0d7f484
编写于
12月 26, 2019
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: add test for sql
上级
7d1fbed8
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
46 addition
and
6 deletion
+46
-6
_fixtures/sql/hello.sql
_fixtures/sql/hello.sql
+2
-0
core/adapter/sql/sql_identifier_app.go
core/adapter/sql/sql_identifier_app.go
+11
-1
core/adapter/sql/sql_identifier_app_test.go
core/adapter/sql/sql_identifier_app_test.go
+15
-0
core/adapter/sql/sql_identifier_listener.go
core/adapter/sql/sql_identifier_listener.go
+13
-0
core/domain/count/count_app.go
core/domain/count/count_app.go
+3
-3
core/domain/refactor/unused_classes/unused_classes_app.go
core/domain/refactor/unused_classes/unused_classes_app.go
+2
-2
未找到文件。
_fixtures/sql/hello.sql
0 → 100644
浏览文件 @
e0d7f484
SELECT
name
,
country
FROM
Websites
;
SELECT
*
FROM
Persons
;
core/adapter/sql/sql_identifier_app.go
浏览文件 @
e0d7f484
...
...
@@ -14,7 +14,11 @@ type SqlIdentifierApp struct {
}
func
(
j
*
SqlIdentifierApp
)
AnalysisPath
(
codeDir
string
)
{
func
NewSqlIdentifierApp
()
SqlIdentifierApp
{
return
*&
SqlIdentifierApp
{}
}
func
(
j
*
SqlIdentifierApp
)
AnalysisPath
(
codeDir
string
)
[]
SqlNode
{
xmlFiles
:=
(
*
SqlIdentifierApp
)(
nil
)
.
xmlFiles
(
codeDir
)
for
_
,
xmlFile
:=
range
xmlFiles
{
xmlFile
,
err
:=
os
.
Open
(
xmlFile
)
...
...
@@ -30,6 +34,7 @@ func (j *SqlIdentifierApp) AnalysisPath(codeDir string) {
}
}
var
infos
[]
SqlNode
files
:=
(
*
SqlIdentifierApp
)(
nil
)
.
sqlFiles
(
codeDir
)
for
index
:=
range
files
{
file
:=
files
[
index
]
...
...
@@ -40,7 +45,12 @@ func (j *SqlIdentifierApp) AnalysisPath(codeDir string) {
listener
:=
NewSqlIdentifierListener
()
antlr
.
NewParseTreeWalker
()
.
Walk
(
listener
,
context
)
info
:=
listener
.
GetNodeInfo
()
infos
=
append
(
infos
,
info
)
}
return
infos
}
func
(
j
*
SqlIdentifierApp
)
xmlFiles
(
codeDir
string
)
[]
string
{
...
...
core/adapter/sql/sql_identifier_app_test.go
0 → 100644
浏览文件 @
e0d7f484
package
sql
import
(
.
"github.com/onsi/gomega"
"testing"
)
func
TestJavaIdentifierApp_AnalysisPath
(
t
*
testing
.
T
)
{
g
:=
NewGomegaWithT
(
t
)
identApp
:=
NewSqlIdentifierApp
()
results
:=
identApp
.
AnalysisPath
(
"../../../_fixtures/sql"
)
g
.
Expect
(
len
(
results
))
.
To
(
Equal
(
1
))
}
core/adapter/sql/sql_identifier_listener.go
浏览文件 @
e0d7f484
...
...
@@ -9,6 +9,15 @@ type SqlIdentifierListener struct {
parser
.
BaseSqlListener
}
type
SqlNode
struct
{
}
var
sqlNode
SqlNode
func
init
()
{
sqlNode
=
*&
SqlNode
{}
}
func
NewSqlIdentifierListener
()
*
SqlIdentifierListener
{
return
&
SqlIdentifierListener
{}
}
...
...
@@ -40,3 +49,7 @@ func (s *SqlIdentifierListener) EnterSelect_core(ctx *parser.Select_coreContext)
}
}
}
func
(
s
*
SqlIdentifierListener
)
GetNodeInfo
()
SqlNode
{
return
sqlNode
}
core/domain/count/count_app.go
浏览文件 @
e0d7f484
...
...
@@ -2,9 +2,9 @@ package count
import
"github.com/phodal/coca/core/models"
func
BuildCallMap
(
cparsed
Deps
[]
models
.
JClassNode
)
map
[
string
]
int
{
func
BuildCallMap
(
parser
Deps
[]
models
.
JClassNode
)
map
[
string
]
int
{
var
projectMethods
=
make
(
map
[
string
]
bool
)
for
_
,
clz
:=
range
cparsed
Deps
{
for
_
,
clz
:=
range
parser
Deps
{
for
_
,
method
:=
range
clz
.
Methods
{
projectMethods
[
clz
.
Package
+
"."
+
clz
.
Class
+
"."
+
method
.
Name
]
=
true
}
...
...
@@ -12,7 +12,7 @@ func BuildCallMap(cparsedDeps []models.JClassNode) map[string]int {
// TODO: support identify data class
var
callMap
=
make
(
map
[
string
]
int
)
for
_
,
clz
:=
range
cparsed
Deps
{
for
_
,
clz
:=
range
parser
Deps
{
for
_
,
call
:=
range
clz
.
MethodCalls
{
callMethod
:=
call
.
Package
+
"."
+
call
.
Class
+
"."
+
call
.
MethodName
if
projectMethods
[
callMethod
]
{
...
...
core/domain/refactor/unused_classes/unused_classes_app.go
浏览文件 @
e0d7f484
package
main
package
unused_classes
import
(
"encoding/json"
...
...
@@ -11,7 +11,7 @@ import (
var
parsedDeps
[]
JClassNode
func
main
()
{
func
Refactoring
()
{
var
analysisPackage
=
""
file
:=
support
.
ReadFile
(
"deps.json"
)
if
file
==
nil
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录