Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
afbf1b44
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,发现更多精彩内容 >>
未验证
提交
afbf1b44
编写于
12月 29, 2019
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ci: add output for windows & macOS
上级
e4c81f02
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
22 deletion
+27
-22
core/domain/refactor/move_class/move_class_app.go
core/domain/refactor/move_class/move_class_app.go
+11
-17
core/domain/refactor/move_class/move_class_app_test.go
core/domain/refactor/move_class/move_class_app_test.go
+15
-5
core/domain/todo/todo_app.go
core/domain/todo/todo_app.go
+1
-0
未找到文件。
core/domain/refactor/move_class/move_class_app.go
浏览文件 @
afbf1b44
...
...
@@ -12,7 +12,6 @@ import (
"log"
"os"
"path/filepath"
"runtime"
"strings"
)
...
...
@@ -55,11 +54,10 @@ func (j *MoveClassApp) Analysis() []models2.JMoveStruct {
nodes
=
append
(
nodes
,
*
moveStruct
)
}
parseRename
()
return
nodes
}
func
parseRename
()
{
func
(
j
*
MoveClassApp
)
Refactoring
()
{
file
,
err
:=
os
.
Open
(
moveConfig
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
...
...
@@ -76,9 +74,11 @@ func parseRename() {
originImport
:=
splitStr
[
0
]
newImport
:=
splitStr
[
1
]
originFile
,
_
:=
filepath
.
Abs
(
configPath
+
originImport
)
newFile
,
_
:=
filepath
.
Abs
(
configPath
+
newImport
)
originFile
:=
buildJavaPath
(
configPath
,
originImport
)
newFile
:=
buildJavaPath
(
configPath
,
newImport
)
// for travis test
fmt
.
Println
(
originFile
,
newFile
)
copyClass
(
originFile
,
newFile
)
updatePackageInfo
(
originImport
,
newImport
)
...
...
@@ -99,7 +99,7 @@ func updatePackageInfo(originImport string, newImport string) {
return
}
path
:=
buildJavaPath
(
configPath
+
newImport
)
path
:=
buildJavaPath
(
configPath
,
newImport
)
split
:=
strings
.
Split
(
newImport
,
"."
)
pkg
:=
strings
.
Join
(
split
[
:
len
(
split
)
-
1
],
"."
)
updateFile
(
path
,
originNode
.
GetPkgInfo
()
.
StartLine
,
"package "
+
pkg
+
";"
)
...
...
@@ -138,24 +138,18 @@ func updateFile(path string, lineNum int, newImp string) {
}
func
copyClass
(
originFile
string
,
newFile
string
)
{
originFile
=
buildJavaPath
(
originFile
)
newFile
=
buildJavaPath
(
newFile
)
_
,
err
:=
CopyFile
(
originFile
,
newFile
)
if
err
!=
nil
{
log
.
Fatalln
(
err
)
}
}
func
buildJavaPath
(
originFile
string
)
string
{
// TODO: 适配 Windows
str
:=
""
if
runtime
.
GOOS
==
"windows"
{
str
=
strings
.
ReplaceAll
(
originFile
,
"."
,
"
\\
"
)
+
".java"
}
else
{
str
=
strings
.
ReplaceAll
(
originFile
,
"."
,
"/"
)
+
".java"
func
buildJavaPath
(
configPath
string
,
importStr
string
)
string
{
if
!
strings
.
HasSuffix
(
configPath
,
"/"
)
{
configPath
=
configPath
+
"/"
}
return
str
path
:=
configPath
+
strings
.
ReplaceAll
(
importStr
,
"."
,
"/"
)
+
".java"
return
filepath
.
FromSlash
(
path
)
}
func
CopyFile
(
src
,
dst
string
)
(
int64
,
error
)
{
...
...
core/domain/refactor/move_class/move_class_app_test.go
浏览文件 @
afbf1b44
package
move_class
import
(
"fmt"
.
"github.com/onsi/gomega"
"os"
"os/exec"
"path/filepath"
"testing"
)
...
...
@@ -10,14 +13,21 @@ func TestMoveClassApp(t *testing.T) {
g
:=
NewGomegaWithT
(
t
)
config
:=
filepath
.
FromSlash
(
"../../../../_fixtures/refactor/move.config"
)
path
:=
filepath
.
FromSlash
(
"../../../../_fixtures/refactor
/
"
)
path
:=
filepath
.
FromSlash
(
"../../../../_fixtures/refactor"
)
absPath
,
_
:=
filepath
.
Abs
(
path
)
NewMoveClassApp
(
config
,
filepath
.
FromSlash
(
absPath
+
"/"
))
//app.Analysis()
app
:=
NewMoveClassApp
(
config
,
filepath
.
FromSlash
(
absPath
))
app
.
Analysis
()
app
.
Refactoring
()
cmd
:=
exec
.
Command
(
"pwd"
)
output
,
_
:=
cmd
.
CombinedOutput
()
fmt
.
Println
(
"////////////////////////"
)
fmt
.
Println
(
string
(
output
))
// todo: fix in CI
//
stat, _ := os.Stat(filepath.FromSlash(absPath + "/move/b/ImportForB.java"))
//
g.Expect(stat.Name()).To(Equal("ImportForB.java"))
stat
,
_
:=
os
.
Stat
(
filepath
.
FromSlash
(
absPath
+
"/move/b/ImportForB.java"
))
g
.
Expect
(
stat
.
Name
())
.
To
(
Equal
(
"ImportForB.java"
))
g
.
Expect
(
true
)
.
To
(
Equal
(
true
))
}
\ No newline at end of file
core/domain/todo/todo_app.go
浏览文件 @
afbf1b44
...
...
@@ -99,6 +99,7 @@ func runGitGetLog(line int, fileName string) string {
cmd
:=
exec
.
Command
(
"git"
,
historyArgs
...
)
out
,
err
:=
cmd
.
CombinedOutput
()
if
err
!=
nil
{
fmt
.
Println
(
out
)
log
.
Fatalf
(
"cmd.Run() failed with %s
\n
"
,
err
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录