Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
ead706b8
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,发现更多精彩内容 >>
未验证
提交
ead706b8
编写于
12月 26, 2019
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: try to rename files
上级
e78c0c2d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
73 addition
and
14 deletion
+73
-14
_fixtures/refactor/rename.config
_fixtures/refactor/rename.config
+1
-0
_fixtures/refactor/rename_back.config
_fixtures/refactor/rename_back.config
+1
-0
_fixtures/refactor/unused/Overload.java
_fixtures/refactor/unused/Overload.java
+1
-1
cmd/refactor.go
cmd/refactor.go
+11
-1
core/domain/refactor/rename/rename_method.go
core/domain/refactor/rename/rename_method.go
+2
-11
core/domain/refactor/rename/rename_method_test.go
core/domain/refactor/rename/rename_method_test.go
+54
-0
core/domain/refactor/rename/support/related_parser.go
core/domain/refactor/rename/support/related_parser.go
+3
-1
未找到文件。
_fixtures/refactor/rename.config
0 → 100644
浏览文件 @
ead706b8
polymorphism
.
Overload
.
demo
->
polymorphism
.
Overload
.
demoA
_fixtures/refactor/rename_back.config
0 → 100644
浏览文件 @
ead706b8
polymorphism
.
Overload
.
demoA
->
polymorphism
.
Overload
.
demo
_fixtures/refactor/unused/Overload.java
浏览文件 @
ead706b8
...
...
@@ -5,7 +5,7 @@ import java.util.Optional;
import
java.util.UUID
;
public
class
Overload
{
void
demo
(
int
a
)
{
void
demo
A
(
int
a
)
{
System
.
out
.
println
(
"a: "
+
a
);
}
}
cmd/refactor.go
浏览文件 @
ead706b8
package
cmd
import
(
"encoding/json"
"github.com/phodal/coca/config"
.
"github.com/phodal/coca/core/domain/refactor/move_class"
.
"github.com/phodal/coca/core/domain/refactor/rename"
.
"github.com/phodal/coca/core/domain/refactor/unused"
"github.com/phodal/coca/core/support"
"github.com/spf13/cobra"
)
...
...
@@ -28,7 +30,15 @@ var refactorCmd = &cobra.Command{
}
if
dependence
!=
""
&&
rename
!=
""
{
renameApp
:=
RenameMethodApp
(
dependence
,
rename
)
file
:=
support
.
ReadFile
(
dependence
)
if
file
==
nil
{
return
}
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
renameApp
:=
RenameMethodApp
(
parsedDeps
,
rename
)
renameApp
.
Start
()
}
},
...
...
core/domain/refactor/rename/rename_method.go
浏览文件 @
ead706b8
package
unused
import
(
"encoding/json"
support3
"github.com/phodal/coca/core/domain/refactor/rename/support"
.
"github.com/phodal/coca/core/models"
"github.com/phodal/coca/core/support"
...
...
@@ -15,25 +14,17 @@ var parsedChange []support3.RefactorChangeRelate
type
RemoveMethodApp
struct
{
}
var
depsFile
string
var
configPath
string
var
conf
string
var
parsedDeps
[]
JClassNode
func
RenameMethodApp
(
dep
string
,
p
string
)
*
RemoveMethodApp
{
depsFile
=
dep
func
RenameMethodApp
(
dep
s
[]
JClassNode
,
p
string
)
*
RemoveMethodApp
{
parsedDeps
=
deps
configPath
=
p
return
&
RemoveMethodApp
{}
}
func
(
j
*
RemoveMethodApp
)
Start
()
{
file
:=
support
.
ReadFile
(
depsFile
)
if
file
==
nil
{
return
}
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
configBytes
:=
support
.
ReadFile
(
configPath
)
if
configBytes
==
nil
{
return
...
...
core/domain/refactor/rename/rename_method_test.go
0 → 100644
浏览文件 @
ead706b8
package
unused
import
(
.
"github.com/onsi/gomega"
"github.com/phodal/coca/core/adapter/call"
"github.com/phodal/coca/core/adapter/identifier"
"sync"
"testing"
)
func
TestRenameMethodApp
(
t
*
testing
.
T
)
{
g
:=
NewGomegaWithT
(
t
)
var
wg
sync
.
WaitGroup
codePath
:=
"../../../../_fixtures/refactor/unused"
configPath
:=
"../../../../_fixtures/refactor/rename.config"
identifierApp
:=
new
(
identifier
.
JavaIdentifierApp
)
identifiers
:=
identifierApp
.
AnalysisPath
(
codePath
)
var
classes
[]
string
=
nil
for
_
,
node
:=
range
identifiers
{
classes
=
append
(
classes
,
node
.
Package
+
"."
+
node
.
ClassName
)
}
wg
.
Add
(
1
)
callApp
:=
call
.
NewJavaCallApp
()
callNodes
:=
callApp
.
AnalysisPath
(
codePath
,
classes
,
identifiers
)
wg
.
Add
(
1
)
go
func
()
{
RenameMethodApp
(
callNodes
,
configPath
)
.
Start
()
defer
wg
.
Done
()
newnodes
:=
callApp
.
AnalysisPath
(
codePath
,
classes
,
identifiers
)
g
.
Expect
(
newnodes
[
0
]
.
Methods
[
0
]
.
Name
)
.
To
(
Equal
(
"demoA"
))
}()
wg
.
Add
(
1
)
go
func
()
{
wg
.
Wait
()
configPath2
:=
"../../../../_fixtures/refactor/rename_back.config"
RenameMethodApp
(
callNodes
,
configPath2
)
.
Start
()
defer
wg
.
Done
()
renameBackNodes
:=
callApp
.
AnalysisPath
(
codePath
,
classes
,
identifiers
)
g
.
Expect
(
renameBackNodes
[
0
]
.
Methods
[
0
]
.
Name
)
.
To
(
Equal
(
"demo"
))
wg
.
Wait
()
}()
}
core/domain/refactor/rename/support/related_parser.go
浏览文件 @
ead706b8
...
...
@@ -22,7 +22,9 @@ func ParseRelates(str string) []RefactorChangeRelate {
lines
:=
strings
.
Split
(
str
,
"
\n
"
)
for
_
,
line
:=
range
lines
{
related
:=
parseRelated
(
line
)
relates
=
append
(
relates
,
*
related
)
if
related
!=
nil
{
relates
=
append
(
relates
,
*
related
)
}
}
return
relates
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录