Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
6280dfc5
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 搜索 >>
未验证
提交
6280dfc5
编写于
1月 16, 2020
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: merge class node & data struct
上级
cbf40cdf
变更
41
隐藏空白更改
内联
并排
Showing
41 changed file
with
91 addition
and
116 deletion
+91
-116
cmd/call.go
cmd/call.go
+1
-1
cmd/cmd_util/deps_loader.go
cmd/cmd_util/deps_loader.go
+2
-2
cmd/concept.go
cmd/concept.go
+1
-1
cmd/count.go
cmd/count.go
+1
-1
cmd/deps.go
cmd/deps.go
+1
-1
cocatest/testhelper/generate.go
cocatest/testhelper/generate.go
+1
-1
pkg/application/analysis/java_full_app.go
pkg/application/analysis/java_full_app.go
+3
-3
pkg/application/analysis/java_full_app_test.go
pkg/application/analysis/java_full_app_test.go
+1
-1
pkg/application/api/java_api_app.go
pkg/application/api/java_api_app.go
+1
-1
pkg/application/arch/arch_app.go
pkg/application/arch/arch_app.go
+4
-4
pkg/application/call/call_graph.go
pkg/application/call/call_graph.go
+3
-3
pkg/application/call/call_graph_test.go
pkg/application/call/call_graph_test.go
+1
-1
pkg/application/concept/concept_analyser.go
pkg/application/concept/concept_analyser.go
+2
-2
pkg/application/concept/concept_analyser_test.go
pkg/application/concept/concept_analyser_test.go
+1
-1
pkg/application/count/count_app.go
pkg/application/count/count_app.go
+1
-1
pkg/application/count/count_app_test.go
pkg/application/count/count_app_test.go
+1
-1
pkg/application/deps/dep_app.go
pkg/application/deps/dep_app.go
+2
-2
pkg/application/evaluate/analyser.go
pkg/application/evaluate/analyser.go
+3
-3
pkg/application/evaluate/analyser_test.go
pkg/application/evaluate/analyser_test.go
+4
-4
pkg/application/evaluate/evaluate.go
pkg/application/evaluate/evaluate.go
+4
-4
pkg/application/evaluate/evaluator/controller.go
pkg/application/evaluate/evaluator/controller.go
+1
-1
pkg/application/evaluate/evaluator/empty.go
pkg/application/evaluate/evaluator/empty.go
+2
-2
pkg/application/evaluate/evaluator/null_exception.go
pkg/application/evaluate/evaluator/null_exception.go
+2
-2
pkg/application/evaluate/evaluator/service.go
pkg/application/evaluate/evaluator/service.go
+3
-3
pkg/application/evaluate/evaluator/util.go
pkg/application/evaluate/evaluator/util.go
+2
-2
pkg/application/rcall/rcall_graph.go
pkg/application/rcall/rcall_graph.go
+3
-3
pkg/application/rcall/rcall_graph_test.go
pkg/application/rcall/rcall_graph_test.go
+2
-2
pkg/application/refactor/rename/rename_method.go
pkg/application/refactor/rename/rename_method.go
+4
-4
pkg/application/refactor/unusedclasses/unused_classes_app.go
pkg/application/refactor/unusedclasses/unused_classes_app.go
+1
-1
pkg/application/refactor/unusedclasses/unused_classes_app_test.go
...ication/refactor/unusedclasses/unused_classes_app_test.go
+1
-1
pkg/application/suggest/suggest_app.go
pkg/application/suggest/suggest_app.go
+2
-2
pkg/application/suggest/suggest_app_test.go
pkg/application/suggest/suggest_app_test.go
+1
-1
pkg/application/tbs/tbs_app.go
pkg/application/tbs/tbs_app.go
+4
-4
pkg/application/tbs/tbs_app_test.go
pkg/application/tbs/tbs_app_test.go
+1
-1
pkg/domain/core_domain/code_data_struct.go
pkg/domain/core_domain/code_data_struct.go
+6
-29
pkg/domain/core_domain/code_function.go
pkg/domain/core_domain/code_function.go
+2
-2
pkg/domain/core_domain/jclass_node.go
pkg/domain/core_domain/jclass_node.go
+0
-2
pkg/domain/support_domain/suggest.go
pkg/domain/support_domain/suggest.go
+2
-2
pkg/infrastructure/ast/api/java_api_listener.go
pkg/infrastructure/ast/api/java_api_listener.go
+2
-2
pkg/infrastructure/ast/full/java_full_listener.go
pkg/infrastructure/ast/full/java_full_listener.go
+11
-11
trial/pkg/application/processor/process_test.go
trial/pkg/application/processor/process_test.go
+1
-1
未找到文件。
cmd/call.go
浏览文件 @
6280dfc5
...
...
@@ -24,7 +24,7 @@ var callGraphCmd = &cobra.Command{
Short
:
"show call graph with specific method"
,
Long
:
``
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
var
parsedDeps
[]
core_domain
.
JClassNode
var
parsedDeps
[]
core_domain
.
CodeDataStruct
dependence
:=
callCmdConfig
.
Path
className
:=
cmd
.
Flag
(
"className"
)
.
Value
.
String
()
...
...
cmd/cmd_util/deps_loader.go
浏览文件 @
6280dfc5
...
...
@@ -5,8 +5,8 @@ import (
"github.com/phodal/coca/pkg/domain/core_domain"
)
func
GetDepsFromJson
(
depPath
string
)
[]
core_domain
.
JClassNode
{
var
parsedDeps
[]
core_domain
.
JClassNode
func
GetDepsFromJson
(
depPath
string
)
[]
core_domain
.
CodeDataStruct
{
var
parsedDeps
[]
core_domain
.
CodeDataStruct
file
:=
ReadFile
(
depPath
)
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
...
...
cmd/concept.go
浏览文件 @
6280dfc5
...
...
@@ -10,7 +10,7 @@ import (
"strconv"
)
var
parsedDeps
[]
core_domain
.
JClassNode
var
parsedDeps
[]
core_domain
.
CodeDataStruct
var
conceptCmd
=
&
cobra
.
Command
{
Use
:
"concept"
,
...
...
cmd/count.go
浏览文件 @
6280dfc5
...
...
@@ -20,7 +20,7 @@ var (
countCmdConfig
CountCmdConfig
)
var
cparsedDeps
[]
core_domain
.
JClassNode
var
cparsedDeps
[]
core_domain
.
CodeDataStruct
var
countCmd
=
&
cobra
.
Command
{
Use
:
"count"
,
...
...
cmd/deps.go
浏览文件 @
6280dfc5
...
...
@@ -21,7 +21,7 @@ var (
)
type
DepApp
interface
{
AnalysisPath
(
path
string
,
nodes
[]
core_domain
.
JClassNode
)
[]
api_domain
.
JDependency
AnalysisPath
(
path
string
,
nodes
[]
core_domain
.
CodeDataStruct
)
[]
api_domain
.
JDependency
}
var
depsCmd
=
&
cobra
.
Command
{
...
...
cocatest/testhelper/generate.go
浏览文件 @
6280dfc5
...
...
@@ -6,7 +6,7 @@ import (
"path/filepath"
)
func
BuildAnalysisDeps
(
codePath
string
)
([]
core_domain
.
JClassNode
,
map
[
string
]
core_domain
.
JIdentifier
,
[]
core_domain
.
JIdentifier
)
{
func
BuildAnalysisDeps
(
codePath
string
)
([]
core_domain
.
CodeDataStruct
,
map
[
string
]
core_domain
.
JIdentifier
,
[]
core_domain
.
JIdentifier
)
{
codePath
=
filepath
.
FromSlash
(
codePath
)
identifierApp
:=
analysis
.
NewJavaIdentifierApp
()
...
...
pkg/application/analysis/java_full_app.go
浏览文件 @
6280dfc5
...
...
@@ -17,13 +17,13 @@ func NewJavaFullApp() JavaFullApp {
return
JavaFullApp
{}
}
func
(
j
*
JavaFullApp
)
AnalysisPath
(
codeDir
string
,
classes
[]
string
,
identNodes
[]
core_domain
.
JIdentifier
)
[]
core_domain
.
JClassNode
{
func
(
j
*
JavaFullApp
)
AnalysisPath
(
codeDir
string
,
classes
[]
string
,
identNodes
[]
core_domain
.
JIdentifier
)
[]
core_domain
.
CodeDataStruct
{
files
:=
cocafile
.
GetJavaFiles
(
codeDir
)
return
j
.
AnalysisFiles
(
identNodes
,
files
,
classes
)
}
func
(
j
*
JavaFullApp
)
AnalysisFiles
(
identNodes
[]
core_domain
.
JIdentifier
,
files
[]
string
,
classes
[]
string
)
[]
core_domain
.
JClassNode
{
var
nodeInfos
[]
core_domain
.
JClassNode
func
(
j
*
JavaFullApp
)
AnalysisFiles
(
identNodes
[]
core_domain
.
JIdentifier
,
files
[]
string
,
classes
[]
string
)
[]
core_domain
.
CodeDataStruct
{
var
nodeInfos
[]
core_domain
.
CodeDataStruct
var
identMap
=
make
(
map
[
string
]
core_domain
.
JIdentifier
)
for
_
,
ident
:=
range
identNodes
{
...
...
pkg/application/analysis/java_full_app_test.go
浏览文件 @
6280dfc5
...
...
@@ -36,7 +36,7 @@ func TestJavaCallListener_EnterConstructorDeclaration(t *testing.T) {
g
.
Expect
(
len
(
callNodes
[
0
]
.
Functions
))
.
To
(
Equal
(
3
))
}
func
getCallNodes
(
codePath
string
)
[]
core_domain
.
JClassNode
{
func
getCallNodes
(
codePath
string
)
[]
core_domain
.
CodeDataStruct
{
identifierApp
:=
NewJavaIdentifierApp
()
iNodes
:=
identifierApp
.
AnalysisPath
(
codePath
)
var
classes
[]
string
=
nil
...
...
pkg/application/api/java_api_app.go
浏览文件 @
6280dfc5
...
...
@@ -16,7 +16,7 @@ var allApis []api_domain.RestAPI
type
JavaApiApp
struct
{
}
func
(
j
*
JavaApiApp
)
AnalysisPath
(
codeDir
string
,
parsedDeps
[]
core_domain
.
JClassNode
,
identifiersMap
map
[
string
]
core_domain
.
JIdentifier
,
diMap
map
[
string
]
string
)
[]
api_domain
.
RestAPI
{
func
(
j
*
JavaApiApp
)
AnalysisPath
(
codeDir
string
,
parsedDeps
[]
core_domain
.
CodeDataStruct
,
identifiersMap
map
[
string
]
core_domain
.
JIdentifier
,
diMap
map
[
string
]
string
)
[]
api_domain
.
RestAPI
{
files
:=
cocafile
.
GetJavaFiles
(
codeDir
)
allApis
=
nil
for
index
:=
range
files
{
...
...
pkg/application/arch/arch_app.go
浏览文件 @
6280dfc5
...
...
@@ -12,7 +12,7 @@ func NewArchApp() ArchApp {
return
ArchApp
{}
}
func
(
a
ArchApp
)
Analysis
(
deps
[]
core_domain
.
JClassNode
,
identifiersMap
map
[
string
]
core_domain
.
JIdentifier
)
*
tequila
.
FullGraph
{
func
(
a
ArchApp
)
Analysis
(
deps
[]
core_domain
.
CodeDataStruct
,
identifiersMap
map
[
string
]
core_domain
.
JIdentifier
)
*
tequila
.
FullGraph
{
fullGraph
:=
&
tequila
.
FullGraph
{
NodeList
:
make
(
map
[
string
]
string
),
RelationList
:
make
(
map
[
string
]
*
tequila
.
Relation
),
...
...
@@ -44,7 +44,7 @@ func (a ArchApp) Analysis(deps []core_domain.JClassNode, identifiersMap map[stri
return
fullGraph
}
func
addCallInField
(
clz
core_domain
.
JClassNode
,
src
string
,
fullGraph
tequila
.
FullGraph
)
{
func
addCallInField
(
clz
core_domain
.
CodeDataStruct
,
src
string
,
fullGraph
tequila
.
FullGraph
)
{
for
_
,
field
:=
range
clz
.
FunctionCalls
{
dst
:=
field
.
Package
+
"."
+
field
.
NodeName
relation
:=
&
tequila
.
Relation
{
...
...
@@ -57,7 +57,7 @@ func addCallInField(clz core_domain.JClassNode, src string, fullGraph tequila.Fu
}
}
func
addCallInMethod
(
clz
core_domain
.
JClassNode
,
identifiersMap
map
[
string
]
core_domain
.
JIdentifier
,
src
string
,
fullGraph
tequila
.
FullGraph
)
{
func
addCallInMethod
(
clz
core_domain
.
CodeDataStruct
,
identifiersMap
map
[
string
]
core_domain
.
JIdentifier
,
src
string
,
fullGraph
tequila
.
FullGraph
)
{
for
_
,
method
:=
range
clz
.
Functions
{
if
method
.
Name
==
"main"
{
continue
...
...
@@ -83,7 +83,7 @@ func addCallInMethod(clz core_domain.JClassNode, identifiersMap map[string]core_
}
}
func
addExtend
(
clz
core_domain
.
JClassNode
,
src
string
,
fullGraph
tequila
.
FullGraph
)
{
func
addExtend
(
clz
core_domain
.
CodeDataStruct
,
src
string
,
fullGraph
tequila
.
FullGraph
)
{
if
clz
.
Extend
!=
""
{
relation
:=
&
tequila
.
Relation
{
From
:
src
,
...
...
pkg/application/call/call_graph.go
浏览文件 @
6280dfc5
...
...
@@ -14,7 +14,7 @@ func NewCallGraph() CallGraph {
return
CallGraph
{}
}
func
(
c
CallGraph
)
Analysis
(
funcName
string
,
clzs
[]
core_domain
.
JClassNode
)
string
{
func
(
c
CallGraph
)
Analysis
(
funcName
string
,
clzs
[]
core_domain
.
CodeDataStruct
)
string
{
methodMap
:=
BuildMethodMap
(
clzs
)
chain
:=
BuildCallChain
(
funcName
,
methodMap
,
nil
)
dotContent
:=
ToGraphviz
(
chain
)
...
...
@@ -56,7 +56,7 @@ func BuildCallChain(funcName string, methodMap map[string][]string, diMap map[st
return
"
\n
"
}
func
(
c
CallGraph
)
AnalysisByFiles
(
restApis
[]
api_domain
.
RestAPI
,
deps
[]
core_domain
.
JClassNode
,
diMap
map
[
string
]
string
)
(
string
,
[]
api_domain
.
CallAPI
)
{
func
(
c
CallGraph
)
AnalysisByFiles
(
restApis
[]
api_domain
.
RestAPI
,
deps
[]
core_domain
.
CodeDataStruct
,
diMap
map
[
string
]
string
)
(
string
,
[]
api_domain
.
CallAPI
)
{
methodMap
:=
BuildMethodMap
(
deps
)
var
apiCallSCounts
[]
api_domain
.
CallAPI
...
...
@@ -88,7 +88,7 @@ func escapeStr(caller string) string {
return
strings
.
ReplaceAll
(
caller
,
"
\"
"
,
"
\\\"
"
)
}
func
BuildMethodMap
(
clzs
[]
core_domain
.
JClassNode
)
map
[
string
][]
string
{
func
BuildMethodMap
(
clzs
[]
core_domain
.
CodeDataStruct
)
map
[
string
][]
string
{
var
methodMap
=
make
(
map
[
string
][]
string
)
for
_
,
clz
:=
range
clzs
{
for
_
,
method
:=
range
clz
.
Functions
{
...
...
pkg/application/call/call_graph_test.go
浏览文件 @
6280dfc5
...
...
@@ -16,7 +16,7 @@ import (
func
Test_ShouldBuildSuccessDataFromJson
(
t
*
testing
.
T
)
{
g
:=
NewGomegaWithT
(
t
)
var
parsedDeps
[]
core_domain
.
JClassNode
var
parsedDeps
[]
core_domain
.
CodeDataStruct
analyser
:=
call
.
NewCallGraph
()
codePath
:=
"../../../_fixtures/call/call_api_test.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
...
...
pkg/application/concept/concept_analyser.go
浏览文件 @
6280dfc5
...
...
@@ -14,11 +14,11 @@ func NewConceptAnalyser() ConceptAnalyser {
return
ConceptAnalyser
{}
}
func
(
c
ConceptAnalyser
)
Analysis
(
clzs
*
[]
core_domain
.
JClassNode
)
string_helper
.
PairList
{
func
(
c
ConceptAnalyser
)
Analysis
(
clzs
*
[]
core_domain
.
CodeDataStruct
)
string_helper
.
PairList
{
return
buildMethodsFromDeps
(
*
clzs
)
}
func
buildMethodsFromDeps
(
clzs
[]
core_domain
.
JClassNode
)
string_helper
.
PairList
{
func
buildMethodsFromDeps
(
clzs
[]
core_domain
.
CodeDataStruct
)
string_helper
.
PairList
{
var
methodsName
[]
string
var
methodStr
string
for
_
,
clz
:=
range
clzs
{
...
...
pkg/application/concept/concept_analyser_test.go
浏览文件 @
6280dfc5
...
...
@@ -14,7 +14,7 @@ import (
func
TestConceptAnalyser_Analysis
(
t
*
testing
.
T
)
{
g
:=
NewGomegaWithT
(
t
)
var
parsedDeps
[]
core_domain
.
JClassNode
var
parsedDeps
[]
core_domain
.
CodeDataStruct
analyser
:=
NewConceptAnalyser
()
codePath
:=
"../../../_fixtures/call/call_api_test.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
...
...
pkg/application/count/count_app.go
浏览文件 @
6280dfc5
...
...
@@ -4,7 +4,7 @@ import (
"github.com/phodal/coca/pkg/domain/core_domain"
)
func
BuildCallMap
(
parserDeps
[]
core_domain
.
JClassNode
)
map
[
string
]
int
{
func
BuildCallMap
(
parserDeps
[]
core_domain
.
CodeDataStruct
)
map
[
string
]
int
{
var
projectMethods
=
make
(
map
[
string
]
string
)
for
_
,
clz
:=
range
parserDeps
{
clz
.
BuildStringMethodMap
(
projectMethods
)
...
...
pkg/application/count/count_app_test.go
浏览文件 @
6280dfc5
...
...
@@ -11,7 +11,7 @@ import (
func
TestBuildCallMap
(
t
*
testing
.
T
)
{
g
:=
NewGomegaWithT
(
t
)
var
parsedDeps
[]
core_domain
.
JClassNode
var
parsedDeps
[]
core_domain
.
CodeDataStruct
codePath
:=
"../../../_fixtures/count/call.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
file
:=
cmd_util
.
ReadFile
(
codePath
)
...
...
pkg/application/deps/dep_app.go
浏览文件 @
6280dfc5
...
...
@@ -15,7 +15,7 @@ func NewDepApp() *DepAnalysisApp {
return
&
DepAnalysisApp
{}
}
func
(
d
*
DepAnalysisApp
)
BuildImportMap
(
deps
[]
core_domain
.
JClassNode
)
map
[
string
]
core_domain
.
CodeImport
{
func
(
d
*
DepAnalysisApp
)
BuildImportMap
(
deps
[]
core_domain
.
CodeDataStruct
)
map
[
string
]
core_domain
.
CodeImport
{
var
impMap
=
make
(
map
[
string
]
core_domain
.
CodeImport
)
for
_
,
clz
:=
range
deps
{
for
_
,
imp
:=
range
clz
.
Imports
{
...
...
@@ -26,7 +26,7 @@ func (d *DepAnalysisApp) BuildImportMap(deps []core_domain.JClassNode) map[strin
return
impMap
}
func
(
d
*
DepAnalysisApp
)
AnalysisPath
(
path
string
,
nodes
[]
core_domain
.
JClassNode
)
[]
api_domain
.
JDependency
{
func
(
d
*
DepAnalysisApp
)
AnalysisPath
(
path
string
,
nodes
[]
core_domain
.
CodeDataStruct
)
[]
api_domain
.
JDependency
{
path
,
_
=
filepath
.
Abs
(
path
)
pomXmls
:=
cocafile
.
GetFilesWithFilter
(
path
,
cocafile
.
PomXmlFilter
)
gradleFiles
:=
cocafile
.
GetFilesWithFilter
(
path
,
cocafile
.
BuildGradleFilter
)
...
...
pkg/application/evaluate/analyser.go
浏览文件 @
6280dfc5
...
...
@@ -13,12 +13,12 @@ func NewEvaluateAnalyser() Analyser {
return
Analyser
{}
}
func
(
a
Analyser
)
Analysis
(
classNodes
[]
core_domain
.
JClassNode
,
identifiers
[]
core_domain
.
JIdentifier
)
evaluator
.
EvaluateModel
{
var
servicesNode
[]
core_domain
.
JClassNode
=
nil
func
(
a
Analyser
)
Analysis
(
classNodes
[]
core_domain
.
CodeDataStruct
,
identifiers
[]
core_domain
.
JIdentifier
)
evaluator
.
EvaluateModel
{
var
servicesNode
[]
core_domain
.
CodeDataStruct
=
nil
var
evaluation
Evaluation
var
result
=
evaluator
.
NewEvaluateModel
()
var
nodeMap
=
make
(
map
[
string
]
core_domain
.
JClassNode
)
var
nodeMap
=
make
(
map
[
string
]
core_domain
.
CodeDataStruct
)
for
_
,
node
:=
range
classNodes
{
nodeMap
[
node
.
NodeName
]
=
node
...
...
pkg/application/evaluate/analyser_test.go
浏览文件 @
6280dfc5
...
...
@@ -14,7 +14,7 @@ import (
func
TestAnalyser_Analysis
(
t
*
testing
.
T
)
{
g
:=
NewGomegaWithT
(
t
)
var
parsedDeps
[]
core_domain
.
JClassNode
var
parsedDeps
[]
core_domain
.
CodeDataStruct
analyser
:=
NewEvaluateAnalyser
()
codePath
:=
"../../../_fixtures/evaluate/service.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
...
...
@@ -29,7 +29,7 @@ func TestAnalyser_Analysis(t *testing.T) {
func
Test_Service_LifeCycle
(
t
*
testing
.
T
)
{
g
:=
NewGomegaWithT
(
t
)
var
parsedDeps
[]
core_domain
.
JClassNode
var
parsedDeps
[]
core_domain
.
CodeDataStruct
analyser
:=
NewEvaluateAnalyser
()
codePath
:=
"../../../_fixtures/evaluate/service_lifecycle.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
...
...
@@ -46,7 +46,7 @@ func Test_Service_LifeCycle(t *testing.T) {
func
Test_Service_Same_Return_Type
(
t
*
testing
.
T
)
{
g
:=
NewGomegaWithT
(
t
)
var
parsedDeps
[]
core_domain
.
JClassNode
var
parsedDeps
[]
core_domain
.
CodeDataStruct
analyser
:=
NewEvaluateAnalyser
()
codePath
:=
"../../../_fixtures/evaluate/service_same_return_type.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
...
...
@@ -61,7 +61,7 @@ func Test_Service_Same_Return_Type(t *testing.T) {
func
Test_Long_Parameters
(
t
*
testing
.
T
)
{
g
:=
NewGomegaWithT
(
t
)
var
parsedDeps
[]
core_domain
.
JClassNode
var
parsedDeps
[]
core_domain
.
CodeDataStruct
analyser
:=
NewEvaluateAnalyser
()
codePath
:=
"../../../_fixtures/evaluate/service_long_parameters.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
...
...
pkg/application/evaluate/evaluate.go
浏览文件 @
6280dfc5
...
...
@@ -6,18 +6,18 @@ import (
)
type
Evaluator
interface
{
Evaluate
(
result
*
evaluator
.
EvaluateModel
,
node
core_domain
.
JClassNode
)
EvaluateList
(
evaluateModel
*
evaluator
.
EvaluateModel
,
nodes
[]
core_domain
.
JClassNode
,
nodeMap
map
[
string
]
core_domain
.
JClassNode
,
identifiers
[]
core_domain
.
JIdentifier
)
Evaluate
(
result
*
evaluator
.
EvaluateModel
,
node
core_domain
.
CodeDataStruct
)
EvaluateList
(
evaluateModel
*
evaluator
.
EvaluateModel
,
nodes
[]
core_domain
.
CodeDataStruct
,
nodeMap
map
[
string
]
core_domain
.
CodeDataStruct
,
identifiers
[]
core_domain
.
JIdentifier
)
}
type
Evaluation
struct
{
Evaluator
Evaluator
}
func
(
o
*
Evaluation
)
Evaluate
(
result
*
evaluator
.
EvaluateModel
,
node
core_domain
.
JClassNode
)
{
func
(
o
*
Evaluation
)
Evaluate
(
result
*
evaluator
.
EvaluateModel
,
node
core_domain
.
CodeDataStruct
)
{
o
.
Evaluator
.
Evaluate
(
result
,
node
)
}
func
(
o
*
Evaluation
)
EvaluateList
(
evaluateModel
*
evaluator
.
EvaluateModel
,
nodes
[]
core_domain
.
JClassNode
,
nodeMap
map
[
string
]
core_domain
.
JClassNode
,
identifiers
[]
core_domain
.
JIdentifier
)
{
func
(
o
*
Evaluation
)
EvaluateList
(
evaluateModel
*
evaluator
.
EvaluateModel
,
nodes
[]
core_domain
.
CodeDataStruct
,
nodeMap
map
[
string
]
core_domain
.
CodeDataStruct
,
identifiers
[]
core_domain
.
JIdentifier
)
{
o
.
Evaluator
.
EvaluateList
(
evaluateModel
,
nodes
,
nodeMap
,
identifiers
)
}
pkg/application/evaluate/evaluator/controller.go
浏览文件 @
6280dfc5
...
...
@@ -9,6 +9,6 @@ type Controller struct {
}
func
(
Controller
)
Evaluate
(
node
core_domain
.
JClassNode
)
{
func
(
Controller
)
Evaluate
(
node
core_domain
.
CodeDataStruct
)
{
fmt
.
Println
(
"controller"
)
}
pkg/application/evaluate/evaluator/empty.go
浏览文件 @
6280dfc5
...
...
@@ -8,10 +8,10 @@ type Empty struct {
}
func
(
Empty
)
Evaluate
(
*
EvaluateModel
,
core_domain
.
JClassNode
)
{
func
(
Empty
)
Evaluate
(
*
EvaluateModel
,
core_domain
.
CodeDataStruct
)
{
}
func
(
Empty
)
EvaluateList
(
*
EvaluateModel
,
[]
core_domain
.
JClassNode
,
map
[
string
]
core_domain
.
JClassNode
,
[]
core_domain
.
JIdentifier
)
{
func
(
Empty
)
EvaluateList
(
*
EvaluateModel
,
[]
core_domain
.
CodeDataStruct
,
map
[
string
]
core_domain
.
CodeDataStruct
,
[]
core_domain
.
JIdentifier
)
{
}
\ No newline at end of file
pkg/application/evaluate/evaluator/null_exception.go
浏览文件 @
6280dfc5
...
...
@@ -7,11 +7,11 @@ import (
type
NullPointException
struct
{
}
func
(
NullPointException
)
Evaluate
(
*
EvaluateModel
,
core_domain
.
JClassNode
)
{
func
(
NullPointException
)
Evaluate
(
*
EvaluateModel
,
core_domain
.
CodeDataStruct
)
{
}
func
(
n
NullPointException
)
EvaluateList
(
evaluateModel
*
EvaluateModel
,
nodes
[]
core_domain
.
JClassNode
,
nodeMap
map
[
string
]
core_domain
.
JClassNode
,
identifiers
[]
core_domain
.
JIdentifier
)
{
func
(
n
NullPointException
)
EvaluateList
(
evaluateModel
*
EvaluateModel
,
nodes
[]
core_domain
.
CodeDataStruct
,
nodeMap
map
[
string
]
core_domain
.
CodeDataStruct
,
identifiers
[]
core_domain
.
JIdentifier
)
{
var
nullableList
[]
string
=
nil
var
nullableMap
=
make
(
map
[
string
]
string
)
for
_
,
ident
:=
range
identifiers
{
...
...
pkg/application/evaluate/evaluator/service.go
浏览文件 @
6280dfc5
...
...
@@ -10,11 +10,11 @@ import (
type
Service
struct
{
}
var
serviceNodeMap
map
[
string
]
core_domain
.
JClassNode
var
serviceNodeMap
map
[
string
]
core_domain
.
CodeDataStruct
var
returnTypeMap
map
[
string
][]
string
var
longParameterList
[]
core_domain
.
CodeFunction
func
(
s
Service
)
EvaluateList
(
evaluateModel
*
EvaluateModel
,
nodes
[]
core_domain
.
JClassNode
,
nodeMap
map
[
string
]
core_domain
.
JClassNode
,
identifiers
[]
core_domain
.
JIdentifier
)
{
func
(
s
Service
)
EvaluateList
(
evaluateModel
*
EvaluateModel
,
nodes
[]
core_domain
.
CodeDataStruct
,
nodeMap
map
[
string
]
core_domain
.
CodeDataStruct
,
identifiers
[]
core_domain
.
JIdentifier
)
{
serviceNodeMap
=
nodeMap
longParameterList
=
nil
returnTypeMap
=
make
(
map
[
string
][]
string
)
...
...
@@ -49,7 +49,7 @@ func findRelatedMethodParameters(model *EvaluateModel, list []core_domain.CodeFu
}
}
func
(
s
Service
)
Evaluate
(
result
*
EvaluateModel
,
node
core_domain
.
JClassNode
)
{
func
(
s
Service
)
Evaluate
(
result
*
EvaluateModel
,
node
core_domain
.
CodeDataStruct
)
{
var
methodNameArray
[][]
string
for
_
,
method
:=
range
node
.
Functions
{
methodNameArray
=
append
(
methodNameArray
,
SplitCamelcase
(
method
.
Name
))
...
...
pkg/application/evaluate/evaluator/util.go
浏览文件 @
6280dfc5
...
...
@@ -7,10 +7,10 @@ import (
type
Util
struct
{
}
func
(
Util
)
Evaluate
(
result
*
EvaluateModel
,
node
core_domain
.
JClassNode
)
{
func
(
Util
)
Evaluate
(
result
*
EvaluateModel
,
node
core_domain
.
CodeDataStruct
)
{
}
func
(
s
Util
)
EvaluateList
(
evaluateModel
*
EvaluateModel
,
nodes
[]
core_domain
.
JClassNode
,
nodeMap
map
[
string
]
core_domain
.
JClassNode
,
identifiers
[]
core_domain
.
JIdentifier
)
{
func
(
s
Util
)
EvaluateList
(
evaluateModel
*
EvaluateModel
,
nodes
[]
core_domain
.
CodeDataStruct
,
nodeMap
map
[
string
]
core_domain
.
CodeDataStruct
,
identifiers
[]
core_domain
.
JIdentifier
)
{
}
pkg/application/rcall/rcall_graph.go
浏览文件 @
6280dfc5
...
...
@@ -12,7 +12,7 @@ func NewRCallGraph() RCallGraph {
return
RCallGraph
{}
}
func
(
c
RCallGraph
)
Analysis
(
funcName
string
,
clzs
[]
core_domain
.
JClassNode
,
writeCallback
func
(
rcallMap
map
[
string
][]
string
))
string
{
func
(
c
RCallGraph
)
Analysis
(
funcName
string
,
clzs
[]
core_domain
.
CodeDataStruct
,
writeCallback
func
(
rcallMap
map
[
string
][]
string
))
string
{
var
projectMethodMap
=
BuildProjectMethodMap
(
clzs
)
rcallMap
:=
BuildRCallMethodMap
(
clzs
,
projectMethodMap
)
...
...
@@ -26,7 +26,7 @@ func (c RCallGraph) Analysis(funcName string, clzs []core_domain.JClassNode, wri
return
dotContent
}
func
BuildProjectMethodMap
(
clzs
[]
core_domain
.
JClassNode
)
map
[
string
]
int
{
func
BuildProjectMethodMap
(
clzs
[]
core_domain
.
CodeDataStruct
)
map
[
string
]
int
{
var
maps
=
make
(
map
[
string
]
int
)
for
_
,
clz
:=
range
clzs
{
for
_
,
method
:=
range
clz
.
Functions
{
...
...
@@ -37,7 +37,7 @@ func BuildProjectMethodMap(clzs []core_domain.JClassNode) map[string]int {
return
maps
}
func
BuildRCallMethodMap
(
parserDeps
[]
core_domain
.
JClassNode
,
projectMaps
map
[
string
]
int
)
map
[
string
][]
string
{
func
BuildRCallMethodMap
(
parserDeps
[]
core_domain
.
CodeDataStruct
,
projectMaps
map
[
string
]
int
)
map
[
string
][]
string
{
var
methodMap
=
make
(
map
[
string
][]
string
)
for
_
,
clz
:=
range
parserDeps
{
for
_
,
method
:=
range
clz
.
Functions
{
...
...
pkg/application/rcall/rcall_graph_test.go
浏览文件 @
6280dfc5
...
...
@@ -17,7 +17,7 @@ func MockWriteCallMap(rcallMap map[string][]string) {
func
TestRCallGraph_Analysis
(
t
*
testing
.
T
)
{
g
:=
NewGomegaWithT
(
t
)
var
parsedDeps
[]
core_domain
.
JClassNode
var
parsedDeps
[]
core_domain
.
CodeDataStruct
analyser
:=
NewRCallGraph
()
file
:=
cmd_util
.
ReadFile
(
"../../../_fixtures/call/call_api_test.json"
)
if
file
==
nil
{
...
...
@@ -39,7 +39,7 @@ edge [dir="back"];
func
TestRCallGraph_Constructor
(
t
*
testing
.
T
)
{
g
:=
NewGomegaWithT
(
t
)
var
parsedDeps
[]
core_domain
.
JClassNode
var
parsedDeps
[]
core_domain
.
CodeDataStruct
analyser
:=
NewRCallGraph
()
file
:=
cmd_util
.
ReadFile
(
"../../../_fixtures/rcall/constructor_call.json"
)
if
file
==
nil
{
...
...
pkg/application/refactor/rename/rename_method.go
浏览文件 @
6280dfc5
...
...
@@ -13,9 +13,9 @@ var parsedChange []support.RefactorChangeRelate
type
RemoveMethodApp
struct
{
}
var
parsedDeps
[]
core_domain
.
JClassNode
var
parsedDeps
[]
core_domain
.
CodeDataStruct
func
RenameMethodApp
(
deps
[]
core_domain
.
JClassNode
)
*
RemoveMethodApp
{
func
RenameMethodApp
(
deps
[]
core_domain
.
CodeDataStruct
)
*
RemoveMethodApp
{
parsedDeps
=
deps
return
&
RemoveMethodApp
{}
}
...
...
@@ -25,7 +25,7 @@ func (j *RemoveMethodApp) Refactoring(conf string) {
startParse
(
parsedDeps
,
parsedChange
)
}
func
startParse
(
nodes
[]
core_domain
.
JClassNode
,
relates
[]
support
.
RefactorChangeRelate
)
{
func
startParse
(
nodes
[]
core_domain
.
CodeDataStruct
,
relates
[]
support
.
RefactorChangeRelate
)
{
for
_
,
pkgNode
:=
range
nodes
{
for
_
,
related
:=
range
relates
{
oldInfo
:=
support
.
BuildMethodPackageInfo
(
related
.
OldObj
)
...
...
@@ -66,7 +66,7 @@ func methodCallToMethodModel(call core_domain.CodeCall) core_domain.CodeFunction
}
}
func
updateSelfRefs
(
node
core_domain
.
JClassNode
,
method
core_domain
.
CodeFunction
,
info
*
support
.
PackageClassInfo
)
{
func
updateSelfRefs
(
node
core_domain
.
CodeDataStruct
,
method
core_domain
.
CodeFunction
,
info
*
support
.
PackageClassInfo
)
{
path
:=
node
.
FilePath
input
,
err
:=
ioutil
.
ReadFile
(
path
)
if
err
!=
nil
{
...
...
pkg/application/refactor/unusedclasses/unused_classes_app.go
浏览文件 @
6280dfc5
...
...
@@ -8,7 +8,7 @@ import (
var
analysisPackage
=
""
func
Refactoring
(
parsedDeps
[]
core_domain
.
JClassNode
)
[]
string
{
func
Refactoring
(
parsedDeps
[]
core_domain
.
CodeDataStruct
)
[]
string
{
sourceClasses
:=
make
(
map
[
string
]
string
)
targetClasses
:=
make
(
map
[
string
]
string
)
...
...
pkg/application/refactor/unusedclasses/unused_classes_app_test.go
浏览文件 @
6280dfc5
...
...
@@ -13,7 +13,7 @@ func TestRefactoring(t *testing.T) {
g
:=
NewGomegaWithT
(
t
)
var
parsedDeps
[]
core_domain
.
JClassNode
var
parsedDeps
[]
core_domain
.
CodeDataStruct
codePath
:=
"../../../../_fixtures/count/call.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
file
:=
cmd_util
.
ReadFile
(
codePath
)
...
...
pkg/application/suggest/suggest_app.go
浏览文件 @
6280dfc5
...
...
@@ -12,7 +12,7 @@ func NewSuggestApp() SuggestApp {
return
SuggestApp
{}
}
func
(
a
SuggestApp
)
AnalysisPath
(
deps
[]
core_domain
.
JClassNode
)
[]
api_domain
.
Suggest
{
func
(
a
SuggestApp
)
AnalysisPath
(
deps
[]
core_domain
.
CodeDataStruct
)
[]
api_domain
.
Suggest
{
var
suggests
[]
api_domain
.
Suggest
for
_
,
clz
:=
range
deps
{
if
clz
.
Type
==
"NodeName"
{
...
...
@@ -27,7 +27,7 @@ func (a SuggestApp) AnalysisPath(deps []core_domain.JClassNode) []api_domain.Sug
return
suggests
}
func
factorySuggest
(
clz
core_domain
.
JClassNode
,
suggests
[]
api_domain
.
Suggest
)
[]
api_domain
.
Suggest
{
func
factorySuggest
(
clz
core_domain
.
CodeDataStruct
,
suggests
[]
api_domain
.
Suggest
)
[]
api_domain
.
Suggest
{
var
constructorCount
=
0
var
longestParaConstructorMethod
=
clz
.
Functions
[
0
]
...
...
pkg/application/suggest/suggest_app_test.go
浏览文件 @
6280dfc5
...
...
@@ -14,7 +14,7 @@ import (
func
TestConceptAnalyser_Analysis
(
t
*
testing
.
T
)
{
g
:=
NewGomegaWithT
(
t
)
var
parsedDeps
[]
core_domain
.
JClassNode
var
parsedDeps
[]
core_domain
.
CodeDataStruct
analyser
:=
NewSuggestApp
()
codePath
:=
"../../../_fixtures/suggest/factory/factory_suggest.json"
codePath
=
filepath
.
FromSlash
(
codePath
)
...
...
pkg/application/tbs/tbs_app.go
浏览文件 @
6280dfc5
...
...
@@ -19,7 +19,7 @@ type TestBadSmell struct {
Line
int
}
func
(
a
TbsApp
)
AnalysisPath
(
deps
[]
core_domain
.
JClassNode
,
identifiersMap
map
[
string
]
core_domain
.
JIdentifier
)
[]
TestBadSmell
{
func
(
a
TbsApp
)
AnalysisPath
(
deps
[]
core_domain
.
CodeDataStruct
,
identifiersMap
map
[
string
]
core_domain
.
JIdentifier
)
[]
TestBadSmell
{
var
results
[]
TestBadSmell
=
nil
callMethodMap
:=
core_domain
.
BuildCallMethodMap
(
deps
)
for
_
,
clz
:=
range
deps
{
...
...
@@ -69,7 +69,7 @@ func (a TbsApp) AnalysisPath(deps []core_domain.JClassNode, identifiersMap map[s
return
results
}
func
checkAssert
(
hasAssert
bool
,
clz
core_domain
.
JClassNode
,
method
core_domain
.
CodeFunction
,
results
*
[]
TestBadSmell
,
testType
*
string
)
{
func
checkAssert
(
hasAssert
bool
,
clz
core_domain
.
CodeDataStruct
,
method
core_domain
.
CodeFunction
,
results
*
[]
TestBadSmell
,
testType
*
string
)
{
if
!
hasAssert
{
*
testType
=
"UnknownTest"
tbs
:=
TestBadSmell
{
...
...
@@ -84,7 +84,7 @@ func checkAssert(hasAssert bool, clz core_domain.JClassNode, method core_domain.
}
}
func
updateMethodCallsForSelfCall
(
method
core_domain
.
CodeFunction
,
clz
core_domain
.
JClassNode
,
callMethodMap
map
[
string
]
core_domain
.
CodeFunction
)
[]
core_domain
.
CodeCall
{
func
updateMethodCallsForSelfCall
(
method
core_domain
.
CodeFunction
,
clz
core_domain
.
CodeDataStruct
,
callMethodMap
map
[
string
]
core_domain
.
CodeFunction
)
[]
core_domain
.
CodeCall
{
currentMethodCalls
:=
method
.
MethodCalls
for
_
,
methodCall
:=
range
currentMethodCalls
{
if
methodCall
.
NodeName
==
clz
.
NodeName
{
...
...
@@ -114,7 +114,7 @@ func checkRedundantAssertionTest(path string, call core_domain.CodeCall, method
}
}
func
checkDuplicateAssertTest
(
clz
core_domain
.
JClassNode
,
results
*
[]
TestBadSmell
,
methodCallMap
map
[
string
][]
core_domain
.
CodeCall
,
method
core_domain
.
CodeFunction
,
testType
*
string
)
{
func
checkDuplicateAssertTest
(
clz
core_domain
.
CodeDataStruct
,
results
*
[]
TestBadSmell
,
methodCallMap
map
[
string
][]
core_domain
.
CodeCall
,
method
core_domain
.
CodeFunction
,
testType
*
string
)
{
var
isDuplicateAssert
=
false
for
_
,
methodCall
:=
range
methodCallMap
{
if
len
(
methodCall
)
>=
constants
.
DuplicatedAssertionLimitLength
{
...
...
pkg/application/tbs/tbs_app_test.go
浏览文件 @
6280dfc5
...
...
@@ -139,7 +139,7 @@ func buildTbsResult(codePath string) []TestBadSmell {
return
result
}
func
BuildTestAnalysisResultsByPath
(
codePath
string
)
(
map
[
string
]
core_domain
.
JIdentifier
,
[]
core_domain
.
JClassNode
)
{
func
BuildTestAnalysisResultsByPath
(
codePath
string
)
(
map
[
string
]
core_domain
.
JIdentifier
,
[]
core_domain
.
CodeDataStruct
)
{
files
:=
cocafile
.
GetJavaTestFiles
(
codePath
)
identifiers
:=
cmd_util
.
LoadTestIdentify
(
files
)
...
...
pkg/domain/core_domain/code_data_struct.go
浏览文件 @
6280dfc5
...
...
@@ -25,38 +25,15 @@ func NewDataStruct() *CodeDataStruct {
return
&
CodeDataStruct
{}
}
func
(
d
*
CodeDataStruct
)
IsNotEmpty
()
bool
{
return
len
(
d
.
Functions
)
>
0
||
len
(
d
.
FunctionCalls
)
>
0
}
type
JClassNode
struct
{
NodeName
string
Type
string
Package
string
FilePath
string
Fields
[]
CodeField
Extend
string
Implements
[]
string
Functions
[]
CodeFunction
FunctionCalls
[]
CodeCall
Annotations
[]
CodeAnnotation
InnerStructures
[]
JClassNode
Imports
[]
CodeImport
}
func
NewClassNode
()
*
JClassNode
{
return
&
JClassNode
{}
}
func
(
j
*
JClassNode
)
IsUtilClass
()
bool
{
func
(
j
*
CodeDataStruct
)
IsUtilClass
()
bool
{
return
strings
.
Contains
(
strings
.
ToLower
(
j
.
NodeName
),
"util"
)
||
strings
.
Contains
(
strings
.
ToLower
(
j
.
NodeName
),
"utils"
)
}
func
(
j
*
JClassNode
)
IsServiceClass
()
bool
{
func
(
j
*
CodeDataStruct
)
IsServiceClass
()
bool
{
return
strings
.
Contains
(
strings
.
ToLower
(
j
.
NodeName
),
"service"
)
}
func
(
j
*
JClassNode
)
SetMethodFromMap
(
methodMap
map
[
string
]
CodeFunction
)
{
func
(
j
*
CodeDataStruct
)
SetMethodFromMap
(
methodMap
map
[
string
]
CodeFunction
)
{
var
methodsArray
[]
CodeFunction
for
_
,
value
:=
range
methodMap
{
methodsArray
=
append
(
methodsArray
,
value
)
...
...
@@ -65,17 +42,17 @@ func (j *JClassNode) SetMethodFromMap(methodMap map[string]CodeFunction) {
j
.
Functions
=
methodsArray
}
func
(
j
*
JClassNode
)
BuildStringMethodMap
(
projectMethods
map
[
string
]
string
)
{
func
(
j
*
CodeDataStruct
)
BuildStringMethodMap
(
projectMethods
map
[
string
]
string
)
{
for
_
,
method
:=
range
j
.
Functions
{
projectMethods
[
method
.
BuildFullMethodName
(
*
j
)]
=
method
.
BuildFullMethodName
(
*
j
)
}
}
func
(
j
*
JClassNode
)
IsNotEmpty
()
bool
{
func
(
j
*
CodeDataStruct
)
IsNotEmpty
()
bool
{
return
len
(
j
.
Functions
)
>
0
||
len
(
j
.
FunctionCalls
)
>
0
}
func
BuildCallMethodMap
(
deps
[]
JClassNode
)
map
[
string
]
CodeFunction
{
func
BuildCallMethodMap
(
deps
[]
CodeDataStruct
)
map
[
string
]
CodeFunction
{
var
callMethodMap
=
make
(
map
[
string
]
CodeFunction
)
for
_
,
clz
:=
range
deps
{
for
_
,
method
:=
range
clz
.
Functions
{
...
...
pkg/domain/core_domain/code_function.go
浏览文件 @
6280dfc5
...
...
@@ -18,7 +18,7 @@ type CodeFunction struct {
IsReturnNull
bool
// todo: move to extension
Modifiers
[]
string
InnerStructures
[]
JClassNode
InnerStructures
[]
CodeDataStruct
InnerFunctions
[]
CodeFunction
Extension
interface
{}
Position
CodePosition
...
...
@@ -46,7 +46,7 @@ func (m *CodeFunction) IsGetterSetter() bool {
return
strings
.
HasPrefix
(
m
.
Name
,
"set"
)
||
strings
.
HasPrefix
(
m
.
Name
,
"get"
)
}
func
(
m
*
CodeFunction
)
BuildFullMethodName
(
node
JClassNode
)
string
{
func
(
m
*
CodeFunction
)
BuildFullMethodName
(
node
CodeDataStruct
)
string
{
return
node
.
Package
+
"."
+
node
.
NodeName
+
"."
+
m
.
Name
}
...
...
pkg/domain/core_domain/jclass_node.go
已删除
100644 → 0
浏览文件 @
cbf40cdf
package
core_domain
pkg/domain/support_domain/suggest.go
浏览文件 @
6280dfc5
...
...
@@ -15,7 +15,7 @@ type Suggest struct {
Line
int
}
func
NewSuggest
(
clz
core_domain
.
JClassNode
,
pattern
,
reason
string
)
Suggest
{
func
NewSuggest
(
clz
core_domain
.
CodeDataStruct
,
pattern
,
reason
string
)
Suggest
{
return
Suggest
{
File
:
clz
.
FilePath
,
Package
:
clz
.
Package
,
...
...
@@ -25,7 +25,7 @@ func NewSuggest(clz core_domain.JClassNode, pattern, reason string) Suggest {
}
}
func
MergeSuggest
(
clz
core_domain
.
JClassNode
,
currentSuggestList
[]
Suggest
)
Suggest
{
func
MergeSuggest
(
clz
core_domain
.
CodeDataStruct
,
currentSuggestList
[]
Suggest
)
Suggest
{
var
suggest
=
NewSuggest
(
clz
,
""
,
""
)
for
_
,
s
:=
range
currentSuggestList
{
if
!
strings
.
Contains
(
suggest
.
Pattern
,
s
.
Pattern
)
{
...
...
pkg/infrastructure/ast/api/java_api_listener.go
浏览文件 @
6280dfc5
...
...
@@ -9,7 +9,7 @@ import (
"strings"
)
var
jClassNodes
[]
core_domain
.
JClassNode
var
jClassNodes
[]
core_domain
.
CodeDataStruct
var
hasEnterClass
=
false
var
isSpringRestController
=
false
...
...
@@ -300,7 +300,7 @@ func buildMethodParameters(requestBodyClass string) {
currentRestAPI
.
MethodParams
=
params
}
func
(
s
*
JavaAPIListener
)
AppendClasses
(
classes
[]
core_domain
.
JClassNode
)
{
func
(
s
*
JavaAPIListener
)
AppendClasses
(
classes
[]
core_domain
.
CodeDataStruct
)
{
jClassNodes
=
classes
}
...
...
pkg/infrastructure/ast/full/java_full_listener.go
浏览文件 @
6280dfc5
...
...
@@ -32,12 +32,12 @@ var classStringQueue []string
var
identMap
map
[
string
]
core_domain
.
JIdentifier
var
isOverrideMethod
=
false
var
classNodeQueue
[]
core_domain
.
JClassNode
var
classNodeQueue
[]
core_domain
.
CodeDataStruct
var
currentNode
*
core_domain
.
JClassNode
var
classNodes
[]
core_domain
.
JClassNode
var
creatorNodes
[]
core_domain
.
JClassNode
var
currentCreatorNode
core_domain
.
JClassNode
var
currentNode
*
core_domain
.
CodeDataStruct
var
classNodes
[]
core_domain
.
CodeDataStruct
var
creatorNodes
[]
core_domain
.
CodeDataStruct
var
currentCreatorNode
core_domain
.
CodeDataStruct
var
fileName
=
""
var
hasEnterClass
=
false
...
...
@@ -47,7 +47,7 @@ func NewJavaFullListener(nodes map[string]core_domain.JIdentifier, file string)
fileName
=
file
currentPkg
=
""
classNodes
=
nil
currentNode
=
core_domain
.
New
ClassNode
()
currentNode
=
core_domain
.
New
DataStruct
()
classStringQueue
=
nil
classNodeQueue
=
nil
methodQueue
=
nil
...
...
@@ -72,7 +72,7 @@ type JavaFullListener struct {
parser
.
BaseJavaParserListener
}
func
(
s
*
JavaFullListener
)
GetNodeInfo
()
[]
core_domain
.
JClassNode
{
func
(
s
*
JavaFullListener
)
GetNodeInfo
()
[]
core_domain
.
CodeDataStruct
{
return
classNodes
}
...
...
@@ -99,7 +99,7 @@ func (s *JavaFullListener) exitBody() {
}
if
currentNode
.
NodeName
==
""
{
currentNode
=
core_domain
.
New
ClassNode
()
currentNode
=
core_domain
.
New
DataStruct
()
initClass
()
return
}
...
...
@@ -118,7 +118,7 @@ func (s *JavaFullListener) exitBody() {
currentNode
=
&
classNodeQueue
[
len
(
classNodeQueue
)
-
1
]
}
}
else
{
currentNode
=
core_domain
.
New
ClassNode
()
currentNode
=
core_domain
.
New
DataStruct
()
}
initClass
()
...
...
@@ -444,7 +444,7 @@ func (s *JavaFullListener) EnterCreator(ctx *parser.CreatorContext) {
currentType
=
"CreatorClass"
text
:=
ctx
.
CreatedName
()
.
GetText
()
creatorNode
:=
&
core_domain
.
JClassNode
{
creatorNode
:=
&
core_domain
.
CodeDataStruct
{
Package
:
currentPkg
,
NodeName
:
text
,
Type
:
"CreatorClass"
,
...
...
@@ -472,7 +472,7 @@ func (s *JavaFullListener) ExitCreator(ctx *parser.CreatorContext) {
if
currentType
==
"CreatorClass"
{
currentType
=
""
}
currentCreatorNode
=
*
core_domain
.
New
ClassNode
()
currentCreatorNode
=
*
core_domain
.
New
DataStruct
()
if
classNodeQueue
==
nil
||
len
(
classNodeQueue
)
<
1
{
return
...
...
trial/pkg/application/processor/process_test.go
浏览文件 @
6280dfc5
...
...
@@ -10,5 +10,5 @@ func Test_ProcessPackage(t *testing.T) {
g
:=
NewGomegaWithT
(
t
)
results
:=
ProcessPackage
(
"../../../../pkg/domain"
,
true
)
g
.
Expect
(
len
(
results
))
.
To
(
Equal
(
2
3
))
g
.
Expect
(
len
(
results
))
.
To
(
Equal
(
2
2
))
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录