Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
4bfe6bc7
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 搜索 >>
未验证
提交
4bfe6bc7
编写于
12月 17, 2019
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: refactor path
上级
4f55b3ed
变更
31
隐藏空白更改
内联
并排
Showing
31 changed file
with
87 addition
and
87 deletion
+87
-87
cmd/api.go
cmd/api.go
+1
-1
cmd/bs.go
cmd/bs.go
+1
-1
cmd/call_graph.go
cmd/call_graph.go
+1
-1
cmd/concept.go
cmd/concept.go
+1
-1
cmd/git_cmd.go
cmd/git_cmd.go
+1
-1
cmd/refactor.go
cmd/refactor.go
+3
-3
gitt_test.go
gitt_test.go
+1
-1
src/domain/bs/BadSmellApp.go
src/domain/bs/BadSmellApp.go
+5
-5
src/domain/bs/BadSmellListener.go
src/domain/bs/BadSmellListener.go
+19
-19
src/domain/bs/models/BsModel.go
src/domain/bs/models/BsModel.go
+0
-0
src/domain/call_graph/call_graph.go
src/domain/call_graph/call_graph.go
+0
-0
src/domain/call_graph/call_model.go
src/domain/call_graph/call_model.go
+0
-0
src/domain/call_graph/stop_words/it.go
src/domain/call_graph/stop_words/it.go
+0
-0
src/domain/call_graph/stop_words/languages/en.go
src/domain/call_graph/stop_words/languages/en.go
+0
-0
src/domain/concept/concept_analyser.go
src/domain/concept/concept_analyser.go
+2
-2
src/domain/gitt/README.md
src/domain/gitt/README.md
+0
-0
src/domain/gitt/apriori/apriori.go
src/domain/gitt/apriori/apriori.go
+0
-0
src/domain/gitt/gitt.go
src/domain/gitt/gitt.go
+4
-4
src/domain/gitt/models.go
src/domain/gitt/models.go
+0
-0
src/domain/refactor/base/JavaRefactorListener.go
src/domain/refactor/base/JavaRefactorListener.go
+18
-18
src/domain/refactor/base/models/JFullIdentifier.go
src/domain/refactor/base/models/JFullIdentifier.go
+0
-0
src/domain/refactor/base/models/JMoveStruct.go
src/domain/refactor/base/models/JMoveStruct.go
+0
-0
src/domain/refactor/main.go
src/domain/refactor/main.go
+0
-0
src/domain/refactor/move_class/move_class_app.go
src/domain/refactor/move_class/move_class_app.go
+11
-11
src/domain/refactor/rename/rename_method.go
src/domain/refactor/rename/rename_method.go
+9
-9
src/domain/refactor/rename/support/package_info_helper.go
src/domain/refactor/rename/support/package_info_helper.go
+0
-0
src/domain/refactor/rename/support/refactor_change_model.go
src/domain/refactor/rename/support/refactor_change_model.go
+0
-0
src/domain/refactor/rename/support/related_parser.go
src/domain/refactor/rename/support/related_parser.go
+0
-0
src/domain/refactor/unused/remove_unused_import.go
src/domain/refactor/unused/remove_unused_import.go
+10
-10
src/domain/refactor/unused_classes/UnusedClassesApp.go
src/domain/refactor/unused_classes/UnusedClassesApp.go
+0
-0
src/domain/refactor/utils/file_analysis_helper.go
src/domain/refactor/utils/file_analysis_helper.go
+0
-0
未找到文件。
cmd/api.go
浏览文件 @
4bfe6bc7
...
...
@@ -3,7 +3,7 @@ package cmd
import
(
.
"coca/src/adapter/api"
"coca/src/adapter/models"
"coca/src/call_graph"
"coca/src/
domain/
call_graph"
.
"coca/src/support"
"encoding/json"
"github.com/olekukonko/tablewriter"
...
...
cmd/bs.go
浏览文件 @
4bfe6bc7
package
cmd
import
(
"coca/src/bs"
"coca/src/
domain/
bs"
"coca/src/support"
"encoding/json"
"github.com/spf13/cobra"
...
...
cmd/call_graph.go
浏览文件 @
4bfe6bc7
...
...
@@ -2,7 +2,7 @@ package cmd
import
(
"coca/src/adapter/models"
.
"coca/src/call_graph"
.
"coca/src/
domain/
call_graph"
.
"coca/src/support"
"encoding/json"
"github.com/spf13/cobra"
...
...
cmd/concept.go
浏览文件 @
4bfe6bc7
...
...
@@ -2,7 +2,7 @@ package cmd
import
(
"coca/src/adapter/models"
"coca/src/concept"
"coca/src/
domain/
concept"
.
"coca/src/support"
"encoding/json"
"github.com/spf13/cobra"
...
...
cmd/git_cmd.go
浏览文件 @
4bfe6bc7
package
cmd
import
(
.
"coca/src/gitt"
.
"coca/src/
domain/
gitt"
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
...
...
cmd/refactor.go
浏览文件 @
4bfe6bc7
package
cmd
import
(
.
"coca/src/refactor/move_class"
.
"coca/src/refactor/rename"
.
"coca/src/refactor/unused"
.
"coca/src/
domain/
refactor/move_class"
.
"coca/src/
domain/
refactor/rename"
.
"coca/src/
domain/
refactor/unused"
"github.com/spf13/cobra"
)
...
...
gitt_test.go
浏览文件 @
4bfe6bc7
...
...
@@ -2,7 +2,7 @@ package main_test
import
(
"coca/src/gitt"
"coca/src/
domain/
gitt"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
)
...
...
src/bs/BadSmellApp.go
→
src/
domain/
bs/BadSmellApp.go
浏览文件 @
4bfe6bc7
package
bs
import
(
"coca/src/domain/bs/models"
"coca/src/support"
"encoding/json"
"fmt"
...
...
@@ -10,11 +11,10 @@ import (
"strconv"
"strings"
.
"coca/src/bs/models"
.
"coca/src/language/java"
)
var
nodeInfos
[]
JFullClassNode
var
nodeInfos
[]
models
.
JFullClassNode
type
BadSmellModel
struct
{
File
string
`json:"File,omitempty"`
...
...
@@ -30,7 +30,7 @@ func (j *BadSmellApp) AnalysisPath(codeDir string, ignoreRules []string) []BadSm
nodeInfos
=
nil
files
:=
(
*
BadSmellApp
)(
nil
)
.
javaFiles
(
codeDir
)
for
index
:=
range
files
{
nodeInfo
:=
NewJFullClassNode
()
nodeInfo
:=
models
.
NewJFullClassNode
()
file
:=
files
[
index
]
displayName
:=
filepath
.
Base
(
file
)
...
...
@@ -72,7 +72,7 @@ func filterBadsmellList(models []BadSmellModel, ignoreRules map[string]bool) []B
return
results
}
func
analysisBadSmell
(
nodes
[]
JFullClassNode
)
[]
BadSmellModel
{
func
analysisBadSmell
(
nodes
[]
models
.
JFullClassNode
)
[]
BadSmellModel
{
var
badSmellList
[]
BadSmellModel
for
_
,
node
:=
range
nodes
{
// To be Defined number
...
...
@@ -140,7 +140,7 @@ func analysisBadSmell(nodes []JFullClassNode) []BadSmellModel {
return
badSmellList
}
func
withOutGetterSetterClass
(
fullMethods
[]
JFullMethod
)
int
{
func
withOutGetterSetterClass
(
fullMethods
[]
models
.
JFullMethod
)
int
{
var
normalMethodSize
=
0
for
_
,
method
:=
range
fullMethods
{
if
!
strings
.
Contains
(
method
.
Name
,
"get"
)
&&
!
strings
.
Contains
(
method
.
Name
,
"set"
)
{
...
...
src/bs/BadSmellListener.go
→
src/
domain/
bs/BadSmellListener.go
浏览文件 @
4bfe6bc7
package
bs
import
(
.
"coca/src
/bs/models"
"coca/src/domain
/bs/models"
.
"coca/src/language/java"
"github.com/antlr/antlr4/runtime/Go/antlr"
"reflect"
...
...
@@ -17,13 +17,13 @@ var currentClzType string
var
currentClzExtends
string
var
currentClzImplements
[]
string
var
methods
[]
JFullMethod
var
methodCalls
[]
JFullMethodCall
var
methods
[]
models
.
JFullMethod
var
methodCalls
[]
models
.
JFullMethodCall
var
fields
=
make
(
map
[
string
]
string
)
var
localVars
=
make
(
map
[
string
]
string
)
var
formalParameters
=
make
(
map
[
string
]
string
)
var
currentClassBs
ClassBadSmellInfo
var
currentClassBs
models
.
ClassBadSmellInfo
func
NewBadSmellListener
()
*
BadSmellListener
{
currentClz
=
""
...
...
@@ -39,8 +39,8 @@ type BadSmellListener struct {
BaseJavaParserListener
}
func
(
s
*
BadSmellListener
)
getNodeInfo
()
*
JFullClassNode
{
return
&
JFullClassNode
{
func
(
s
*
BadSmellListener
)
getNodeInfo
()
*
models
.
JFullClassNode
{
return
&
models
.
JFullClassNode
{
currentPkg
,
currentClz
,
currentClzType
,
...
...
@@ -105,7 +105,7 @@ func (s *BadSmellListener) EnterInterfaceMethodDeclaration(ctx *InterfaceMethodD
typeType
:=
ctx
.
TypeTypeOrVoid
()
.
GetText
()
var
methodParams
[]
JFullParameter
=
nil
var
methodParams
[]
models
.
JFullParameter
=
nil
parameters
:=
ctx
.
FormalParameters
()
if
parameters
!=
nil
{
if
reflect
.
TypeOf
(
parameters
.
GetChild
(
1
))
.
String
()
==
"*parser.FormalParameterListContext"
{
...
...
@@ -115,14 +115,14 @@ func (s *BadSmellListener) EnterInterfaceMethodDeclaration(ctx *InterfaceMethodD
paramContext
:=
param
.
(
*
FormalParameterContext
)
paramType
:=
paramContext
.
TypeType
()
.
GetText
()
paramValue
:=
paramContext
.
VariableDeclaratorId
()
.
(
*
VariableDeclaratorIdContext
)
.
IDENTIFIER
()
.
GetText
()
methodParams
=
append
(
methodParams
,
*&
JFullParameter
{
paramType
,
paramValue
})
methodParams
=
append
(
methodParams
,
*&
models
.
JFullParameter
{
paramType
,
paramValue
})
}
}
}
methodBSInfo
:=
*&
MethodBadSmellInfo
{
0
,
0
}
methodBSInfo
:=
*&
models
.
MethodBadSmellInfo
{
0
,
0
}
method
:=
&
JFullMethod
{
method
:=
&
models
.
JFullMethod
{
name
,
typeType
,
startLine
,
...
...
@@ -168,7 +168,7 @@ func (s *BadSmellListener) EnterMethodDeclaration(ctx *MethodDeclarationContext)
typeType
:=
ctx
.
TypeTypeOrVoid
()
.
GetText
()
methodBody
:=
ctx
.
MethodBody
()
.
GetText
()
var
methodParams
[]
JFullParameter
=
nil
var
methodParams
[]
models
.
JFullParameter
=
nil
parameters
:=
ctx
.
FormalParameters
()
if
parameters
!=
nil
{
if
reflect
.
TypeOf
(
parameters
.
GetChild
(
1
))
.
String
()
==
"*parser.FormalParameterListContext"
{
...
...
@@ -178,17 +178,17 @@ func (s *BadSmellListener) EnterMethodDeclaration(ctx *MethodDeclarationContext)
paramContext
:=
param
.
(
*
FormalParameterContext
)
paramType
:=
paramContext
.
TypeType
()
.
GetText
()
paramValue
:=
paramContext
.
VariableDeclaratorId
()
.
(
*
VariableDeclaratorIdContext
)
.
IDENTIFIER
()
.
GetText
()
methodParams
=
append
(
methodParams
,
*&
JFullParameter
{
paramType
,
paramValue
})
methodParams
=
append
(
methodParams
,
*&
models
.
JFullParameter
{
paramType
,
paramValue
})
localVars
[
paramValue
]
=
paramType
}
}
}
methodBSInfo
:=
*&
MethodBadSmellInfo
{
0
,
0
}
methodBSInfo
:=
*&
models
.
MethodBadSmellInfo
{
0
,
0
}
methodBadSmellInfo
:=
buildMethodBSInfo
(
ctx
,
methodBSInfo
)
method
:=
&
JFullMethod
{
method
:=
&
models
.
JFullMethod
{
name
,
typeType
,
startLine
,
...
...
@@ -202,7 +202,7 @@ func (s *BadSmellListener) EnterMethodDeclaration(ctx *MethodDeclarationContext)
methods
=
append
(
methods
,
*
method
)
}
func
buildMethodBSInfo
(
context
*
MethodDeclarationContext
,
bsInfo
MethodBadSmellInfo
)
MethodBadSmellInfo
{
func
buildMethodBSInfo
(
context
*
MethodDeclarationContext
,
bsInfo
models
.
MethodBadSmellInfo
)
models
.
MethodBadSmellInfo
{
methodBody
:=
context
.
MethodBody
()
blockContext
:=
methodBody
.
GetChild
(
0
)
if
reflect
.
TypeOf
(
blockContext
)
.
String
()
==
"*parser.BlockContext"
{
...
...
@@ -275,16 +275,16 @@ func (s *BadSmellListener) EnterMethodCall(ctx *MethodCallContext) {
targetType
=
currentClzExtends
}
if
fullType
!=
""
{
jMethodCall
:=
&
JFullMethodCall
{
removeTarget
(
fullType
),
""
,
targetType
,
callee
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
}
jMethodCall
:=
&
models
.
JFullMethodCall
{
removeTarget
(
fullType
),
""
,
targetType
,
callee
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
}
methodCalls
=
append
(
methodCalls
,
*
jMethodCall
)
}
else
{
if
ctx
.
GetText
()
==
targetType
{
methodName
:=
ctx
.
IDENTIFIER
()
.
GetText
()
jMethodCall
:=
&
JFullMethodCall
{
currentPkg
,
""
,
currentClz
,
methodName
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
}
jMethodCall
:=
&
models
.
JFullMethodCall
{
currentPkg
,
""
,
currentClz
,
methodName
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
}
methodCalls
=
append
(
methodCalls
,
*
jMethodCall
)
}
else
{
methodName
:=
ctx
.
IDENTIFIER
()
.
GetText
()
jMethodCall
:=
&
JFullMethodCall
{
currentPkg
,
"NEEDFIX"
,
targetType
,
methodName
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
}
jMethodCall
:=
&
models
.
JFullMethodCall
{
currentPkg
,
"NEEDFIX"
,
targetType
,
methodName
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
}
methodCalls
=
append
(
methodCalls
,
*
jMethodCall
)
}
}
...
...
@@ -303,7 +303,7 @@ func (s *BadSmellListener) EnterExpression(ctx *ExpressionContext) {
stopLine
:=
ctx
.
GetStop
()
.
GetLine
()
stopLinePosition
:=
startLinePosition
+
len
(
text
)
jMethodCall
:=
&
JFullMethodCall
{
removeTarget
(
fullType
),
""
,
targetType
,
methodName
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
}
jMethodCall
:=
&
models
.
JFullMethodCall
{
removeTarget
(
fullType
),
""
,
targetType
,
methodName
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
}
methodCalls
=
append
(
methodCalls
,
*
jMethodCall
)
}
}
...
...
src/bs/models/BsModel.go
→
src/
domain/
bs/models/BsModel.go
浏览文件 @
4bfe6bc7
文件已移动
src/call_graph/call_graph.go
→
src/
domain/
call_graph/call_graph.go
浏览文件 @
4bfe6bc7
文件已移动
src/call_graph/call_model.go
→
src/
domain/
call_graph/call_model.go
浏览文件 @
4bfe6bc7
文件已移动
src/call_graph/stop_words/it.go
→
src/
domain/
call_graph/stop_words/it.go
浏览文件 @
4bfe6bc7
文件已移动
src/call_graph/stop_words/languages/en.go
→
src/
domain/
call_graph/stop_words/languages/en.go
浏览文件 @
4bfe6bc7
文件已移动
src/concept/concept_analyser.go
→
src/
domain/
concept/concept_analyser.go
浏览文件 @
4bfe6bc7
...
...
@@ -2,7 +2,7 @@ package concept
import
(
"coca/src/adapter/models"
"coca/src
/call_graph/stop_words/languages"
languages2
"coca/src/domain
/call_graph/stop_words/languages"
"coca/src/support"
"fmt"
)
...
...
@@ -116,7 +116,7 @@ var itStopWords = []string{
func
removeNormalWords
(
words
map
[
string
]
int
)
map
[
string
]
int
{
var
newWords
=
words
var
stopwords
=
languages
.
ENGLISH_STOP_WORDS
var
stopwords
=
languages
2
.
ENGLISH_STOP_WORDS
stopwords
=
append
(
stopwords
,
itStopWords
...
)
for
_
,
normalWord
:=
range
stopwords
{
if
newWords
[
normalWord
]
>
0
{
...
...
src/gitt/README.md
→
src/
domain/
gitt/README.md
浏览文件 @
4bfe6bc7
文件已移动
src/gitt/apriori/apriori.go
→
src/
domain/
gitt/apriori/apriori.go
浏览文件 @
4bfe6bc7
文件已移动
src/gitt/gitt.go
→
src/
domain/
gitt/gitt.go
浏览文件 @
4bfe6bc7
...
...
@@ -2,7 +2,7 @@ package gitt
import
(
"bytes"
.
"coca/src
/gitt/apriori"
"coca/src/domain
/gitt/apriori"
"encoding/json"
"fmt"
"log"
...
...
@@ -103,7 +103,7 @@ type TopAuthor struct {
LineCount
int
}
func
GetRelatedFiles
(
commitMessages
[]
CommitMessage
,
relatedConfig
[]
byte
)
[]
RelationRecord
{
func
GetRelatedFiles
(
commitMessages
[]
CommitMessage
,
relatedConfig
[]
byte
)
[]
apriori
.
RelationRecord
{
var
dataset
[][]
string
for
_
,
commitMessage
:=
range
commitMessages
{
var
set
[]
string
...
...
@@ -123,7 +123,7 @@ func GetRelatedFiles(commitMessages []CommitMessage, relatedConfig []byte) []Rel
}
}
var
newOptions
Options
=
NewOptions
(
0.1
,
0.9
,
0
,
0
)
var
newOptions
apriori
.
Options
=
apriori
.
NewOptions
(
0.1
,
0.9
,
0
,
0
)
decoder
:=
json
.
NewDecoder
(
bytes
.
NewReader
(
relatedConfig
))
decoder
.
UseNumber
()
...
...
@@ -134,7 +134,7 @@ func GetRelatedFiles(commitMessages []CommitMessage, relatedConfig []byte) []Rel
}
fmt
.
Println
(
newOptions
)
apriori
:=
NewApriori
(
dataset
)
apriori
:=
apriori
.
NewApriori
(
dataset
)
result
:=
apriori
.
Calculate
(
newOptions
)
for
_
,
res
:=
range
result
{
...
...
src/gitt/models.go
→
src/
domain/
gitt/models.go
浏览文件 @
4bfe6bc7
文件已移动
src/refactor/base/JavaRefactorListener.go
→
src/
domain/
refactor/base/JavaRefactorListener.go
浏览文件 @
4bfe6bc7
package
base
import
(
models2
"coca/src/domain/refactor/base/models"
.
"coca/src/language/java"
"coca/src/refactor/base/models"
"strings"
"unicode"
)
var
node
*
models
.
JFullIdentifier
;
var
node
*
models
2
.
JFullIdentifier
;
type
JavaRefactorListener
struct
{
BaseJavaParserListener
...
...
@@ -19,7 +19,7 @@ func (s *JavaRefactorListener) EnterPackageDeclaration(ctx *PackageDeclarationCo
startLine
:=
ctx
.
GetStart
()
.
GetLine
()
stopLine
:=
ctx
.
GetStop
()
.
GetLine
()
pkgInfo
:=
&
models
.
JPkgInfo
{
node
.
Pkg
,
startLine
,
stopLine
}
pkgInfo
:=
&
models
2
.
JPkgInfo
{
node
.
Pkg
,
startLine
,
stopLine
}
node
.
SetPkgInfo
(
*
pkgInfo
)
}
...
...
@@ -31,7 +31,7 @@ func (s *JavaRefactorListener) EnterImportDeclaration(ctx *ImportDeclarationCont
startLine
:=
ctx
.
GetStart
()
.
GetLine
()
stopLine
:=
ctx
.
GetStop
()
.
GetLine
()
jImport
:=
&
models
.
JImport
{
importText
,
startLine
,
stopLine
}
jImport
:=
&
models
2
.
JImport
{
importText
,
startLine
,
stopLine
}
node
.
AddImport
(
*
jImport
)
}
...
...
@@ -46,7 +46,7 @@ func (s *JavaRefactorListener) EnterQualifiedNameList(ctx *QualifiedNameListCont
for
_
,
qualified
:=
range
ctx
.
AllQualifiedName
()
{
startLine
:=
ctx
.
GetStart
()
.
GetLine
()
stopLine
:=
ctx
.
GetStop
()
.
GetLine
()
field
:=
&
models
.
JField
{
qualified
.
GetText
(),
node
.
Pkg
,
startLine
,
stopLine
}
field
:=
&
models
2
.
JField
{
qualified
.
GetText
(),
node
.
Pkg
,
startLine
,
stopLine
}
node
.
AddField
(
*
field
)
}
}
...
...
@@ -55,7 +55,7 @@ func (s *JavaRefactorListener) EnterCatchType(ctx *CatchTypeContext) {
for
_
,
qualified
:=
range
ctx
.
AllQualifiedName
()
{
startLine
:=
ctx
.
GetStart
()
.
GetLine
()
stopLine
:=
ctx
.
GetStop
()
.
GetLine
()
field
:=
&
models
.
JField
{
qualified
.
GetText
(),
node
.
Pkg
,
startLine
,
stopLine
}
field
:=
&
models
2
.
JField
{
qualified
.
GetText
(),
node
.
Pkg
,
startLine
,
stopLine
}
node
.
AddField
(
*
field
)
}
}
...
...
@@ -68,7 +68,7 @@ func (s *JavaRefactorListener) EnterInterfaceMethodDeclaration(ctx *InterfaceMet
stopLinePosition
:=
ctx
.
GetStop
()
.
GetColumn
()
name
:=
ctx
.
IDENTIFIER
()
.
GetText
()
//XXX: find the start position of {, not public
method
:=
&
models
.
JFullMethod
{
name
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
}
method
:=
&
models
2
.
JFullMethod
{
name
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
}
node
.
AddMethod
(
*
method
)
}
...
...
@@ -80,7 +80,7 @@ func (s *JavaRefactorListener) EnterInterfaceDeclaration(ctx *InterfaceDeclarati
func
(
s
*
JavaRefactorListener
)
EnterTypeType
(
ctx
*
TypeTypeContext
)
{
startLine
:=
ctx
.
GetStart
()
.
GetLine
()
stopLine
:=
ctx
.
GetStop
()
.
GetLine
()
field
:=
&
models
.
JField
{
ctx
.
GetText
(),
node
.
Pkg
,
startLine
,
stopLine
}
field
:=
&
models
2
.
JField
{
ctx
.
GetText
(),
node
.
Pkg
,
startLine
,
stopLine
}
node
.
AddField
(
*
field
)
}
...
...
@@ -92,7 +92,7 @@ func (s *JavaRefactorListener) EnterClassOrInterfaceType(ctx *ClassOrInterfaceTy
startLine
:=
ctx
.
GetStart
()
.
GetLine
()
stopLine
:=
ctx
.
GetStop
()
.
GetLine
()
field
:=
&
models
.
JField
{
name
,
node
.
Pkg
,
startLine
,
stopLine
}
field
:=
&
models
2
.
JField
{
name
,
node
.
Pkg
,
startLine
,
stopLine
}
node
.
AddField
(
*
field
)
}
}
...
...
@@ -103,7 +103,7 @@ func (s *JavaRefactorListener) EnterAnnotation(ctx *AnnotationContext) {
startLine
:=
ctx
.
GetStart
()
.
GetLine
()
stopLine
:=
ctx
.
GetStop
()
.
GetLine
()
field
:=
&
models
.
JField
{
annotation
,
node
.
Pkg
,
startLine
,
stopLine
}
field
:=
&
models
2
.
JField
{
annotation
,
node
.
Pkg
,
startLine
,
stopLine
}
node
.
AddField
(
*
field
)
}
...
...
@@ -115,7 +115,7 @@ func (s *JavaRefactorListener) EnterLambdaParameters(ctx *LambdaParametersContex
startLine
:=
ctx
.
GetStart
()
.
GetLine
()
stopLine
:=
ctx
.
GetStop
()
.
GetLine
()
field
:=
&
models
.
JField
{
name
,
node
.
Pkg
,
startLine
,
stopLine
}
field
:=
&
models
2
.
JField
{
name
,
node
.
Pkg
,
startLine
,
stopLine
}
node
.
AddField
(
*
field
)
}
}
...
...
@@ -124,7 +124,7 @@ func (s *JavaRefactorListener) EnterMethodCall(ctx *MethodCallContext) {
text
:=
ctx
.
IDENTIFIER
()
.
GetText
()
startLine
:=
ctx
.
GetStart
()
.
GetLine
()
stopLine
:=
ctx
.
GetStop
()
.
GetLine
()
field
:=
&
models
.
JField
{
text
,
node
.
Pkg
,
startLine
,
stopLine
}
field
:=
&
models
2
.
JField
{
text
,
node
.
Pkg
,
startLine
,
stopLine
}
node
.
AddField
(
*
field
)
}
...
...
@@ -134,7 +134,7 @@ func (s *JavaRefactorListener) EnterExpressionList(ctx *ExpressionListContext) {
if
isUppercaseText
(
expText
)
{
startLine
:=
ctx
.
GetStart
()
.
GetLine
()
stopLine
:=
ctx
.
GetStop
()
.
GetLine
()
field
:=
&
models
.
JField
{
expText
,
node
.
Pkg
,
startLine
,
stopLine
}
field
:=
&
models
2
.
JField
{
expText
,
node
.
Pkg
,
startLine
,
stopLine
}
node
.
AddField
(
*
field
)
}
}
...
...
@@ -146,7 +146,7 @@ func (s *JavaRefactorListener) EnterStatement(ctx *StatementContext) {
if
isUppercaseText
(
expText
)
{
startLine
:=
ctx
.
GetStart
()
.
GetLine
()
stopLine
:=
ctx
.
GetStop
()
.
GetLine
()
field
:=
&
models
.
JField
{
expText
,
node
.
Pkg
,
startLine
,
stopLine
}
field
:=
&
models
2
.
JField
{
expText
,
node
.
Pkg
,
startLine
,
stopLine
}
node
.
AddField
(
*
field
)
}
}
...
...
@@ -160,7 +160,7 @@ func (s *JavaRefactorListener) EnterCreatedName(ctx *CreatedNameContext) {
startLine
:=
ctx
.
GetStart
()
.
GetLine
()
stopLine
:=
ctx
.
GetStop
()
.
GetLine
()
field
:=
&
models
.
JField
{
name
,
node
.
Pkg
,
startLine
,
stopLine
}
field
:=
&
models
2
.
JField
{
name
,
node
.
Pkg
,
startLine
,
stopLine
}
node
.
AddField
(
*
field
)
}
}
...
...
@@ -172,7 +172,7 @@ func (s *JavaRefactorListener) EnterExpression(ctx *ExpressionContext) {
if
isUppercaseText
(
expText
)
{
startLine
:=
ctx
.
GetStart
()
.
GetLine
()
stopLine
:=
ctx
.
GetStop
()
.
GetLine
()
field
:=
&
models
.
JField
{
expText
,
node
.
Pkg
,
startLine
,
stopLine
}
field
:=
&
models
2
.
JField
{
expText
,
node
.
Pkg
,
startLine
,
stopLine
}
node
.
AddField
(
*
field
)
}
}
...
...
@@ -192,7 +192,7 @@ func (s *JavaRefactorListener) EnterExpression(ctx *ExpressionContext) {
if
isUppercaseText
(
expText
)
{
startLine
:=
ctx
.
GetStart
()
.
GetLine
()
stopLine
:=
ctx
.
GetStop
()
.
GetLine
()
field
:=
&
models
.
JField
{
expText
,
node
.
Pkg
,
startLine
,
stopLine
}
field
:=
&
models
2
.
JField
{
expText
,
node
.
Pkg
,
startLine
,
stopLine
}
node
.
AddField
(
*
field
)
}
}
...
...
@@ -203,6 +203,6 @@ func isUppercaseText(text string) bool {
return
!
strings
.
Contains
(
text
,
"."
)
&&
unicode
.
IsUpper
([]
rune
(
text
)[
0
])
}
func
(
s
*
JavaRefactorListener
)
InitNode
(
identifier
*
models
.
JFullIdentifier
)
{
func
(
s
*
JavaRefactorListener
)
InitNode
(
identifier
*
models
2
.
JFullIdentifier
)
{
node
=
identifier
}
src/refactor/base/models/JFullIdentifier.go
→
src/
domain/
refactor/base/models/JFullIdentifier.go
浏览文件 @
4bfe6bc7
文件已移动
src/refactor/base/models/JMoveStruct.go
→
src/
domain/
refactor/base/models/JMoveStruct.go
浏览文件 @
4bfe6bc7
文件已移动
src/refactor/main.go
→
src/
domain/
refactor/main.go
浏览文件 @
4bfe6bc7
文件已移动
src/refactor/move_class/move_class_app.go
→
src/
domain/
refactor/move_class/move_class_app.go
浏览文件 @
4bfe6bc7
...
...
@@ -2,9 +2,9 @@ package move_class
import
(
"bufio"
"coca/src
/refactor/base"
"coca/src
/refactor/base/models"
"coca/src
/refactor/utils"
base2
"coca/src/domain
/refactor/base"
models2
"coca/src/domain
/refactor/base/models"
utils3
"coca/src/domain
/refactor/utils"
utils2
"coca/src/support"
"fmt"
"github.com/antlr/antlr4/runtime/Go/antlr"
...
...
@@ -20,7 +20,7 @@ var currentFile string
var
moveConfig
string
var
configPath
string
var
nodes
[]
models
.
JMoveStruct
var
nodes
[]
models
2
.
JMoveStruct
type
MoveClassApp
struct
{
}
...
...
@@ -35,7 +35,7 @@ func NewMoveClassApp(config string, pPath string) *MoveClassApp {
func
(
j
*
MoveClassApp
)
Analysis
()
{
// TODO: 使用 Deps.json 来移动包
files
:=
utils
.
GetJavaFiles
(
configPath
)
files
:=
utils
3
.
GetJavaFiles
(
configPath
)
fmt
.
Println
(
files
)
for
index
:=
range
files
{
file
:=
files
[
index
]
...
...
@@ -43,16 +43,16 @@ func (j *MoveClassApp) Analysis() {
currentFile
,
_
=
filepath
.
Abs
(
file
)
//displayName := filepath.Base(file)
parser
:=
utils
.
ProcessFile
(
file
)
parser
:=
utils
3
.
ProcessFile
(
file
)
context
:=
parser
.
CompilationUnit
()
node
:=
models
.
NewJFullIdentifier
()
listener
:=
new
(
base
.
JavaRefactorListener
)
node
:=
models
2
.
NewJFullIdentifier
()
listener
:=
new
(
base
2
.
JavaRefactorListener
)
listener
.
InitNode
(
node
)
antlr
.
NewParseTreeWalker
()
.
Walk
(
listener
,
context
)
moveStruct
:=
&
models
.
JMoveStruct
{
node
,
currentFile
,
node
.
GetImports
()}
moveStruct
:=
&
models
2
.
JMoveStruct
{
node
,
currentFile
,
node
.
GetImports
()}
nodes
=
append
(
nodes
,
*
moveStruct
)
}
...
...
@@ -87,8 +87,8 @@ func parseRename() {
}
}
func
updatePackageInfo
(
structs
[]
models
.
JMoveStruct
,
originImport
string
,
newImport
string
)
{
var
originNode
models
.
JMoveStruct
func
updatePackageInfo
(
structs
[]
models
2
.
JMoveStruct
,
originImport
string
,
newImport
string
)
{
var
originNode
models
2
.
JMoveStruct
for
index
:=
range
nodes
{
node
:=
nodes
[
index
]
if
originImport
==
node
.
Pkg
+
"."
+
node
.
Name
{
...
...
src/refactor/rename/rename_method.go
→
src/
domain/
refactor/rename/rename_method.go
浏览文件 @
4bfe6bc7
...
...
@@ -2,8 +2,8 @@ package unused
import
(
.
"coca/src/adapter/models"
"coca/src
/refactor/base/models"
support
2
"coca/src
/refactor/rename/support"
models2
"coca/src/domain
/refactor/base/models"
support
3
"coca/src/domain
/refactor/rename/support"
"coca/src/support"
"encoding/json"
"io/ioutil"
...
...
@@ -11,8 +11,8 @@ import (
"strings"
)
var
parsedChange
[]
support
2
.
RefactorChangeRelate
var
nodes
[]
models
.
JMoveStruct
var
parsedChange
[]
support
3
.
RefactorChangeRelate
var
nodes
[]
models
2
.
JMoveStruct
type
RemoveMethodApp
struct
{
}
...
...
@@ -44,17 +44,17 @@ func (j *RemoveMethodApp) Start() {
conf
=
string
(
configBytes
)
parsedChange
=
support
2
.
ParseRelates
(
conf
)
parsedChange
=
support
3
.
ParseRelates
(
conf
)
startParse
(
parsedDeps
,
parsedChange
)
}
func
startParse
(
nodes
[]
JClassNode
,
relates
[]
support
2
.
RefactorChangeRelate
)
{
func
startParse
(
nodes
[]
JClassNode
,
relates
[]
support
3
.
RefactorChangeRelate
)
{
for
_
,
pkgNode
:=
range
nodes
{
for
_
,
related
:=
range
relates
{
oldInfo
:=
support
2
.
BuildMethodPackageInfo
(
related
.
OldObj
)
newInfo
:=
support
2
.
BuildMethodPackageInfo
(
related
.
NewObj
)
oldInfo
:=
support
3
.
BuildMethodPackageInfo
(
related
.
OldObj
)
newInfo
:=
support
3
.
BuildMethodPackageInfo
(
related
.
NewObj
)
if
pkgNode
.
Package
+
pkgNode
.
Class
==
oldInfo
.
Package
+
oldInfo
.
Class
{
for
_
,
method
:=
range
pkgNode
.
Methods
{
...
...
@@ -79,7 +79,7 @@ func methodCallToMethodModel(call JMethodCall) *JMethod {
return
&
JMethod
{
call
.
MethodName
,
call
.
Type
,
call
.
StartLine
,
call
.
StartLinePosition
,
call
.
StopLine
,
call
.
StopLinePosition
,
nil
,
nil
,
false
}
}
func
updateSelfRefs
(
node
JClassNode
,
method
JMethod
,
info
*
support
2
.
PackageClassInfo
)
{
func
updateSelfRefs
(
node
JClassNode
,
method
JMethod
,
info
*
support
3
.
PackageClassInfo
)
{
path
:=
node
.
Path
input
,
err
:=
ioutil
.
ReadFile
(
path
)
if
err
!=
nil
{
...
...
src/refactor/rename/support/package_info_helper.go
→
src/
domain/
refactor/rename/support/package_info_helper.go
浏览文件 @
4bfe6bc7
文件已移动
src/refactor/rename/support/refactor_change_model.go
→
src/
domain/
refactor/rename/support/refactor_change_model.go
浏览文件 @
4bfe6bc7
文件已移动
src/refactor/rename/support/related_parser.go
→
src/
domain/
refactor/rename/support/related_parser.go
浏览文件 @
4bfe6bc7
文件已移动
src/refactor/unused/remove_unused_import.go
→
src/
domain/
refactor/unused/remove_unused_import.go
浏览文件 @
4bfe6bc7
package
unused
import
(
"coca/src
/refactor/base"
"coca/src
/refactor/base/models"
"coca/src
/refactor/utils"
base2
"coca/src/domain
/refactor/base"
models2
"coca/src/domain
/refactor/base/models"
utils2
"coca/src/domain
/refactor/utils"
"fmt"
"github.com/antlr/antlr4/runtime/Go/antlr"
"io/ioutil"
...
...
@@ -19,7 +19,7 @@ var configPath string
type
RemoveUnusedImportApp
struct
{
}
var
nodes
[]
models
.
JMoveStruct
var
nodes
[]
models
2
.
JMoveStruct
func
NewRemoveUnusedImportApp
(
config
string
,
pPath
string
)
*
RemoveUnusedImportApp
{
moveConfig
=
config
...
...
@@ -30,7 +30,7 @@ func NewRemoveUnusedImportApp(config string, pPath string) *RemoveUnusedImportAp
}
func
(
j
*
RemoveUnusedImportApp
)
Analysis
()
{
files
:=
utils
.
GetJavaFiles
(
configPath
)
files
:=
utils
2
.
GetJavaFiles
(
configPath
)
for
index
:=
range
files
{
file
:=
files
[
index
]
...
...
@@ -38,11 +38,11 @@ func (j *RemoveUnusedImportApp) Analysis() {
displayName
:=
filepath
.
Base
(
file
)
fmt
.
Println
(
"Start parse java call: "
+
displayName
)
parser
:=
utils
.
ProcessFile
(
file
)
parser
:=
utils
2
.
ProcessFile
(
file
)
context
:=
parser
.
CompilationUnit
()
node
:=
models
.
NewJFullIdentifier
()
listener
:=
new
(
base
.
JavaRefactorListener
)
node
:=
models
2
.
NewJFullIdentifier
()
listener
:=
new
(
base
2
.
JavaRefactorListener
)
listener
.
InitNode
(
node
)
antlr
.
NewParseTreeWalker
()
.
Walk
(
listener
,
context
)
...
...
@@ -53,7 +53,7 @@ func (j *RemoveUnusedImportApp) Analysis() {
}
}
func
handleNode
(
node
*
models
.
JFullIdentifier
)
{
func
handleNode
(
node
*
models
2
.
JFullIdentifier
)
{
var
fields
=
node
.
GetFields
()
var
imports
=
node
.
GetImports
()
...
...
@@ -87,7 +87,7 @@ func removeImportByLines(file string, errorLines []int) {
}
}
func
removeImportByLineNum
(
imp
models
.
JImport
,
line
int
)
{
func
removeImportByLineNum
(
imp
models
2
.
JImport
,
line
int
)
{
removeLine
(
currentFile
,
line
)
}
...
...
src/refactor/unused_classes/UnusedClassesApp.go
→
src/
domain/
refactor/unused_classes/UnusedClassesApp.go
浏览文件 @
4bfe6bc7
文件已移动
src/refactor/utils/file_analysis_helper.go
→
src/
domain/
refactor/utils/file_analysis_helper.go
浏览文件 @
4bfe6bc7
文件已移动
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录