Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
4acf652a
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 搜索 >>
未验证
提交
4acf652a
编写于
12月 16, 2019
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: support for ident find override
上级
4419bae9
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
25 addition
and
18 deletion
+25
-18
cmd/analysis.go
cmd/analysis.go
+1
-1
src/adapter/call/JavaCallApp.go
src/adapter/call/JavaCallApp.go
+2
-2
src/adapter/call/JavaCallListener.go
src/adapter/call/JavaCallListener.go
+5
-10
src/adapter/identifier/JavaIdentifierApp.go
src/adapter/identifier/JavaIdentifierApp.go
+0
-1
src/adapter/identifier/JavaIdentifierListener.go
src/adapter/identifier/JavaIdentifierListener.go
+14
-2
src/adapter/models/JMethod.go
src/adapter/models/JMethod.go
+1
-0
src/refactor/main.go
src/refactor/main.go
+1
-1
src/refactor/rename/rename_method.go
src/refactor/rename/rename_method.go
+1
-1
未找到文件。
cmd/analysis.go
浏览文件 @
4acf652a
...
...
@@ -27,7 +27,7 @@ var analysisCmd *cobra.Command = &cobra.Command{
}
callApp
:=
new
(
JavaCallApp
)
callNodes
:=
callApp
.
AnalysisPath
(
importPath
,
classes
)
callNodes
:=
callApp
.
AnalysisPath
(
importPath
,
classes
,
iNodes
)
cModel
,
_
:=
json
.
MarshalIndent
(
callNodes
,
""
,
"
\t
"
)
WriteToFile
(
"deps.json"
,
string
(
cModel
))
...
...
src/adapter/call/JavaCallApp.go
浏览文件 @
4acf652a
...
...
@@ -15,7 +15,7 @@ var nodeInfos []models.JClassNode
type
JavaCallApp
struct
{
}
func
(
j
*
JavaCallApp
)
AnalysisPath
(
codeDir
string
,
classes
[]
string
)
[]
models
.
JClassNode
{
func
(
j
*
JavaCallApp
)
AnalysisPath
(
codeDir
string
,
classes
[]
string
,
identNodes
[]
models
.
JsonIdentifier
)
[]
models
.
JClassNode
{
nodeInfos
=
nil
files
:=
(
*
JavaCallApp
)(
nil
)
.
javaFiles
(
codeDir
)
for
index
:=
range
files
{
...
...
@@ -28,7 +28,7 @@ func (j *JavaCallApp) AnalysisPath(codeDir string, classes []string) []models.JC
parser
:=
(
*
JavaCallApp
)(
nil
)
.
processFile
(
file
)
context
:=
parser
.
CompilationUnit
()
listener
:=
NewJavaCallListener
()
listener
:=
NewJavaCallListener
(
identNodes
)
listener
.
appendClasses
(
classes
)
antlr
.
NewParseTreeWalker
()
.
Walk
(
listener
,
context
)
...
...
src/adapter/call/JavaCallListener.go
浏览文件 @
4acf652a
...
...
@@ -25,11 +25,13 @@ var currentMethod models.JMethod
var
methodMap
=
make
(
map
[
string
]
models
.
JMethod
)
var
methodQueue
[]
models
.
JMethod
var
identNodes
[]
models
.
JsonIdentifier
func
NewJavaCallListener
()
*
JavaCallListener
{
func
NewJavaCallListener
(
nodes
[]
models
.
JsonIdentifier
)
*
JavaCallListener
{
currentClz
=
""
currentPkg
=
""
currentMethod
=
models
.
NewJMethod
()
identNodes
=
nodes
methodMap
=
make
(
map
[
string
]
models
.
JMethod
)
...
...
@@ -85,7 +87,7 @@ func (s *JavaCallListener) EnterInterfaceMethodDeclaration(ctx *parser.Interface
typeType
:=
ctx
.
TypeTypeOrVoid
()
.
GetText
()
method
:=
&
models
.
JMethod
{
name
,
typeType
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
,
nil
,
nil
}
method
:=
&
models
.
JMethod
{
name
,
typeType
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
,
nil
,
nil
,
false
}
methods
=
append
(
methods
,
*
method
)
}
...
...
@@ -123,7 +125,7 @@ func (s *JavaCallListener) EnterMethodDeclaration(ctx *parser.MethodDeclarationC
typeType
:=
ctx
.
TypeTypeOrVoid
()
.
GetText
()
method
:=
&
models
.
JMethod
{
name
,
typeType
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
,
nil
,
nil
}
method
:=
&
models
.
JMethod
{
name
,
typeType
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
,
nil
,
nil
,
false
}
if
ctx
.
FormalParameters
()
!=
nil
{
if
ctx
.
FormalParameters
()
.
GetChild
(
0
)
==
nil
||
ctx
.
FormalParameters
()
.
GetText
()
==
"()"
||
ctx
.
FormalParameters
()
.
GetChild
(
1
)
==
nil
{
...
...
@@ -207,13 +209,6 @@ func (s *JavaCallListener) EnterLocalTypeDeclaration(ctx *parser.LocalTypeDeclar
// TODO
}
func
(
s
*
JavaCallListener
)
EnterAnnotation
(
ctx
*
parser
.
AnnotationContext
)
{
annotationName
:=
ctx
.
QualifiedName
()
.
GetText
()
if
annotationName
==
"Override"
{
}
}
func
(
s
*
JavaCallListener
)
EnterMethodCall
(
ctx
*
parser
.
MethodCallContext
)
{
var
targetCtx
=
ctx
.
GetParent
()
.
GetChild
(
0
)
.
(
antlr
.
ParseTree
)
.
GetText
()
var
targetType
=
parseTargetType
(
targetCtx
)
...
...
src/adapter/identifier/JavaIdentifierApp.go
浏览文件 @
4acf652a
...
...
@@ -37,7 +37,6 @@ func (j *JavaIdentifierApp) AnalysisPath(codeDir string) []models.JsonIdentifier
if
clzInfo
.
Name
!=
""
{
node
=
&
models
.
JsonIdentifier
{
clzInfo
.
Pkg
,
clzInfo
.
Name
,
clzInfo
.
Type
,
clzInfo
.
GetMethods
()}
nodeInfos
=
append
(
nodeInfos
,
*
node
)
}
}
...
...
src/adapter/identifier/JavaIdentifierListener.go
浏览文件 @
4acf652a
...
...
@@ -31,10 +31,12 @@ func (s *JavaIdentifierListener) EnterInterfaceMethodDeclaration(ctx *parser.Int
//XXX: find the start position of {, not public
typeType
:=
ctx
.
TypeTypeOrVoid
()
.
GetText
()
method
:=
&
models
.
JMethod
{
name
,
typeType
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
,
nil
,
nil
}
method
:=
&
models
.
JMethod
{
name
,
typeType
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
,
nil
,
nil
,
isOverrideMethod
}
node
.
AddMethod
(
*
method
)
}
var
isOverrideMethod
=
false
func
(
s
*
JavaIdentifierListener
)
EnterMethodDeclaration
(
ctx
*
parser
.
MethodDeclarationContext
)
{
startLine
:=
ctx
.
GetStart
()
.
GetLine
()
startLinePosition
:=
ctx
.
GetStart
()
.
GetColumn
()
...
...
@@ -45,8 +47,18 @@ func (s *JavaIdentifierListener) EnterMethodDeclaration(ctx *parser.MethodDeclar
typeType
:=
ctx
.
TypeTypeOrVoid
()
.
GetText
()
method
:=
&
models
.
JMethod
{
name
,
typeType
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
,
nil
,
nil
}
method
:=
&
models
.
JMethod
{
name
,
typeType
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
,
nil
,
nil
,
isOverrideMethod
}
node
.
AddMethod
(
*
method
)
isOverrideMethod
=
false
}
func
(
s
*
JavaIdentifierListener
)
EnterAnnotation
(
ctx
*
parser
.
AnnotationContext
)
{
// Todo: support override method
annotationName
:=
ctx
.
QualifiedName
()
.
GetText
()
if
annotationName
==
"Override"
{
isOverrideMethod
=
true
}
}
func
(
s
*
JavaIdentifierListener
)
EnterInterfaceDeclaration
(
ctx
*
parser
.
InterfaceDeclarationContext
)
{
...
...
src/adapter/models/JMethod.go
浏览文件 @
4acf652a
...
...
@@ -9,6 +9,7 @@ type JMethod struct {
StopLinePosition
int
Parameters
[]
JParameter
MethodCalls
[]
JMethodCall
Override
bool
}
func
NewJMethod
()
JMethod
{
...
...
src/refactor/main.go
浏览文件 @
4acf652a
...
...
@@ -18,7 +18,7 @@ func main() {
}
callApp
:=
new
(
JavaCallApp
)
callNodes
:=
callApp
.
AnalysisPath
(
"examples/lambda/LambdaExample.java"
,
classes
)
callNodes
:=
callApp
.
AnalysisPath
(
"examples/lambda/LambdaExample.java"
,
classes
,
nil
)
cModel
,
_
:=
json
.
MarshalIndent
(
callNodes
,
""
,
"
\t
"
)
...
...
src/refactor/rename/rename_method.go
浏览文件 @
4acf652a
...
...
@@ -76,7 +76,7 @@ func startParse(nodes []JClassNode, relates []support2.RefactorChangeRelate) {
}
func
methodCallToMethodModel
(
call
JMethodCall
)
*
JMethod
{
return
&
JMethod
{
call
.
MethodName
,
call
.
Type
,
call
.
StartLine
,
call
.
StartLinePosition
,
call
.
StopLine
,
call
.
StopLinePosition
,
nil
,
nil
}
return
&
JMethod
{
call
.
MethodName
,
call
.
Type
,
call
.
StartLine
,
call
.
StartLinePosition
,
call
.
StopLine
,
call
.
StopLinePosition
,
nil
,
nil
,
false
}
}
func
updateSelfRefs
(
node
JClassNode
,
method
JMethod
,
info
*
support2
.
PackageClassInfo
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录