Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
70589a2d
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 搜索 >>
未验证
提交
70589a2d
编写于
12月 18, 2019
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: use same file analysis helper
上级
c56c1be9
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
14 addition
and
79 deletion
+14
-79
core/adapter/api/JavaApiApp.go
core/adapter/api/JavaApiApp.go
+2
-23
core/adapter/call/JavaCallApp.go
core/adapter/call/JavaCallApp.go
+3
-24
core/adapter/identifier/JavaIdentifierApp.go
core/adapter/identifier/JavaIdentifierApp.go
+3
-24
core/domain/refactor/move_class/move_class_app.go
core/domain/refactor/move_class/move_class_app.go
+2
-3
core/domain/refactor/unused/remove_unused_import.go
core/domain/refactor/unused/remove_unused_import.go
+3
-3
core/support/file_analysis_helper.go
core/support/file_analysis_helper.go
+1
-2
未找到文件。
core/adapter/api/JavaApiApp.go
浏览文件 @
70589a2d
package
api
import
(
parser2
"coca/core/languages/java"
"coca/core/models"
"coca/core/support"
"encoding/json"
"fmt"
"github.com/antlr/antlr4/runtime/Go/antlr"
"os"
"path/filepath"
"strings"
)
var
parsedDeps
[]
models
.
JClassNode
...
...
@@ -28,14 +25,14 @@ func (j *JavaApiApp) AnalysisPath(codeDir string, depPath string) []RestApi {
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
files
:=
(
*
JavaApiApp
)(
nil
)
.
JavaFiles
(
codeDir
)
files
:=
support
.
Get
JavaFiles
(
codeDir
)
for
index
:=
range
files
{
file
:=
files
[
index
]
displayName
:=
filepath
.
Base
(
file
)
fmt
.
Println
(
"Start parse java call: "
+
displayName
)
parser
:=
(
*
JavaApiApp
)(
nil
)
.
ProcessFile
(
file
)
parser
:=
support
.
ProcessFile
(
file
)
context
:=
parser
.
CompilationUnit
()
listener
:=
NewJavaApiListener
()
...
...
@@ -49,21 +46,3 @@ func (j *JavaApiApp) AnalysisPath(codeDir string, depPath string) []RestApi {
return
allApis
}
func
(
j
*
JavaApiApp
)
JavaFiles
(
codeDir
string
)
[]
string
{
files
:=
make
([]
string
,
0
)
_
=
filepath
.
Walk
(
codeDir
,
func
(
path
string
,
fi
os
.
FileInfo
,
err
error
)
error
{
if
strings
.
HasSuffix
(
path
,
".java"
)
&&
!
strings
.
Contains
(
path
,
"Test.java"
)
{
files
=
append
(
files
,
path
)
}
return
nil
})
return
files
}
func
(
j
*
JavaApiApp
)
ProcessFile
(
path
string
)
*
parser2
.
JavaParser
{
is
,
_
:=
antlr
.
NewFileStream
(
path
)
lexer
:=
parser2
.
NewJavaLexer
(
is
)
stream
:=
antlr
.
NewCommonTokenStream
(
lexer
,
0
);
parser
:=
parser2
.
NewJavaParser
(
stream
)
return
parser
}
core/adapter/call/JavaCallApp.go
浏览文件 @
70589a2d
package
call
import
(
parser2
"coca/core/languages/java"
"coca/core/models"
"coca/core/support"
"fmt"
"github.com/antlr/antlr4/runtime/Go/antlr"
"os"
"path/filepath"
"strings"
)
var
nodeInfos
[]
models
.
JClassNode
...
...
@@ -17,7 +15,7 @@ type JavaCallApp struct {
func
(
j
*
JavaCallApp
)
AnalysisPath
(
codeDir
string
,
classes
[]
string
,
identNodes
[]
models
.
JsonIdentifier
)
[]
models
.
JClassNode
{
nodeInfos
=
nil
files
:=
(
*
JavaCallApp
)(
nil
)
.
j
avaFiles
(
codeDir
)
files
:=
support
.
GetJ
avaFiles
(
codeDir
)
for
index
:=
range
files
{
nodeInfo
:=
models
.
NewClassNode
()
file
:=
files
[
index
]
...
...
@@ -25,7 +23,7 @@ func (j *JavaCallApp) AnalysisPath(codeDir string, classes []string, identNodes
displayName
:=
filepath
.
Base
(
file
)
fmt
.
Println
(
"Start parse java call: "
+
displayName
)
parser
:=
(
*
JavaCallApp
)(
nil
)
.
p
rocessFile
(
file
)
parser
:=
support
.
P
rocessFile
(
file
)
context
:=
parser
.
CompilationUnit
()
listener
:=
NewJavaCallListener
(
identNodes
)
...
...
@@ -40,22 +38,3 @@ func (j *JavaCallApp) AnalysisPath(codeDir string, classes []string, identNodes
return
nodeInfos
}
func
(
j
*
JavaCallApp
)
javaFiles
(
codeDir
string
)
[]
string
{
files
:=
make
([]
string
,
0
)
_
=
filepath
.
Walk
(
codeDir
,
func
(
path
string
,
fi
os
.
FileInfo
,
err
error
)
error
{
if
strings
.
HasSuffix
(
path
,
".java"
)
&&
!
strings
.
Contains
(
path
,
"Test.java"
)
&&
!
strings
.
Contains
(
path
,
"Tests.java"
)
{
files
=
append
(
files
,
path
)
}
return
nil
})
return
files
}
func
(
j
*
JavaCallApp
)
processFile
(
path
string
)
*
parser2
.
JavaParser
{
is
,
_
:=
antlr
.
NewFileStream
(
path
)
lexer
:=
parser2
.
NewJavaLexer
(
is
)
stream
:=
antlr
.
NewCommonTokenStream
(
lexer
,
0
)
parser
:=
parser2
.
NewJavaParser
(
stream
)
return
parser
}
core/adapter/identifier/JavaIdentifierApp.go
浏览文件 @
70589a2d
...
...
@@ -3,10 +3,8 @@ package identifier
import
(
parser2
"coca/core/languages/java"
"coca/core/models"
"coca/core/support"
"github.com/antlr/antlr4/runtime/Go/antlr"
"os"
"path/filepath"
"strings"
)
var
nodeInfos
[]
models
.
JsonIdentifier
=
nil
...
...
@@ -16,12 +14,12 @@ type JavaIdentifierApp struct {
func
(
j
*
JavaIdentifierApp
)
AnalysisPath
(
codeDir
string
)
[]
models
.
JsonIdentifier
{
nodeInfos
=
nil
files
:=
(
*
JavaIdentifierApp
)(
nil
)
.
j
avaFiles
(
codeDir
)
files
:=
support
.
GetJ
avaFiles
(
codeDir
)
for
index
:=
range
files
{
file
:=
files
[
index
]
node
:=
models
.
NewJsonIdentifier
()
parser
:=
(
*
JavaIdentifierApp
)(
nil
)
.
p
rocessFile
(
file
)
parser
:=
support
.
P
rocessFile
(
file
)
context
:=
parser
.
CompilationUnit
()
clzInfo
:=
models
.
NewJIdentifier
()
...
...
@@ -38,22 +36,3 @@ func (j *JavaIdentifierApp) AnalysisPath(codeDir string) []models.JsonIdentifier
return
nodeInfos
}
func
(
j
*
JavaIdentifierApp
)
javaFiles
(
codeDir
string
)
[]
string
{
files
:=
make
([]
string
,
0
)
_
=
filepath
.
Walk
(
codeDir
,
func
(
path
string
,
fi
os
.
FileInfo
,
err
error
)
error
{
if
strings
.
HasSuffix
(
path
,
".java"
)
&&
!
strings
.
Contains
(
path
,
"Test.java"
)
{
files
=
append
(
files
,
path
)
}
return
nil
})
return
files
}
func
(
j
*
JavaIdentifierApp
)
processFile
(
path
string
)
*
parser2
.
JavaParser
{
is
,
_
:=
antlr
.
NewFileStream
(
path
)
lexer
:=
parser2
.
NewJavaLexer
(
is
)
stream
:=
antlr
.
NewCommonTokenStream
(
lexer
,
0
);
parser
:=
parser2
.
NewJavaParser
(
stream
)
return
parser
}
core/domain/refactor/move_class/move_class_app.go
浏览文件 @
70589a2d
...
...
@@ -4,7 +4,6 @@ import (
"bufio"
base2
"coca/core/domain/refactor/base"
models2
"coca/core/domain/refactor/base/models"
utils3
"coca/core/domain/refactor/utils"
utils2
"coca/core/support"
"fmt"
"github.com/antlr/antlr4/runtime/Go/antlr"
...
...
@@ -35,7 +34,7 @@ func NewMoveClassApp(config string, pPath string) *MoveClassApp {
func
(
j
*
MoveClassApp
)
Analysis
()
{
// TODO: 使用 Deps.json 来移动包
files
:=
utils
3
.
GetJavaFiles
(
configPath
)
files
:=
utils
2
.
GetJavaFiles
(
configPath
)
fmt
.
Println
(
files
)
for
index
:=
range
files
{
file
:=
files
[
index
]
...
...
@@ -43,7 +42,7 @@ func (j *MoveClassApp) Analysis() {
currentFile
,
_
=
filepath
.
Abs
(
file
)
//displayName := filepath.Base(file)
parser
:=
utils
3
.
ProcessFile
(
file
)
parser
:=
utils
2
.
ProcessFile
(
file
)
context
:=
parser
.
CompilationUnit
()
node
:=
models2
.
NewJFullIdentifier
()
...
...
core/domain/refactor/unused/remove_unused_import.go
浏览文件 @
70589a2d
...
...
@@ -3,7 +3,7 @@ package unused
import
(
base2
"coca/core/domain/refactor/base"
models2
"coca/core/domain/refactor/base/models"
utils2
"coca/core/domain/refactor/utils
"
"coca/core/support
"
"fmt"
"github.com/antlr/antlr4/runtime/Go/antlr"
"io/ioutil"
...
...
@@ -30,7 +30,7 @@ func NewRemoveUnusedImportApp(config string, pPath string) *RemoveUnusedImportAp
}
func
(
j
*
RemoveUnusedImportApp
)
Analysis
()
{
files
:=
utils2
.
GetJavaFiles
(
configPath
)
files
:=
support
.
GetJavaFiles
(
configPath
)
for
index
:=
range
files
{
file
:=
files
[
index
]
...
...
@@ -38,7 +38,7 @@ func (j *RemoveUnusedImportApp) Analysis() {
displayName
:=
filepath
.
Base
(
file
)
fmt
.
Println
(
"Start parse java call: "
+
displayName
)
parser
:=
utils2
.
ProcessFile
(
file
)
parser
:=
support
.
ProcessFile
(
file
)
context
:=
parser
.
CompilationUnit
()
node
:=
models2
.
NewJFullIdentifier
()
...
...
core/
domain/refactor/utils
/file_analysis_helper.go
→
core/
support
/file_analysis_helper.go
浏览文件 @
70589a2d
package
utils
package
support
import
(
"github.com/antlr/antlr4/runtime/Go/antlr"
...
...
@@ -13,7 +13,6 @@ func GetJavaFiles(codeDir string) []string {
files
:=
make
([]
string
,
0
)
_
=
filepath
.
Walk
(
codeDir
,
func
(
path
string
,
fi
os
.
FileInfo
,
err
error
)
error
{
if
strings
.
HasSuffix
(
path
,
".java"
)
&&
!
strings
.
Contains
(
path
,
"Test.java"
)
&&
!
strings
.
Contains
(
path
,
"Tests.java"
){
files
=
append
(
files
,
path
)
}
return
nil
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录