Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
c60fcd39
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 搜索 >>
未验证
提交
c60fcd39
编写于
10月 29, 2019
作者:
P
Phodal HUANG
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
build: happy copy paste
上级
1855dca3
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
96 addition
and
26 deletion
+96
-26
adapter/identifier/models/JMethod.go
adapter/identifier/models/JMethod.go
+0
-0
helloworld.go
helloworld.go
+4
-5
refactor/base/JavaRefactorApp.go
refactor/base/JavaRefactorApp.go
+8
-1
refactor/base/JavaRefactorCallListener.go
refactor/base/JavaRefactorCallListener.go
+0
-20
refactor/base/JavaRefactorListener.go
refactor/base/JavaRefactorListener.go
+53
-0
refactor/base/models/JFullIdentifier.go
refactor/base/models/JFullIdentifier.go
+31
-0
未找到文件。
adapter/identifier/models/JMethod
Call
.go
→
adapter/identifier/models/JMethod.go
浏览文件 @
c60fcd39
文件已移动
helloworld.go
浏览文件 @
c60fcd39
...
...
@@ -4,12 +4,11 @@ import (
"os"
.
"./adapter/call"
.
"./adapter/identifier"
)
func
main
()
{
//cmd.Execute()
path
:=
"/Users/fdhuang/
test/mall
"
path
:=
"/Users/fdhuang/
learn/coca/poc/src/main
"
if
len
(
os
.
Args
)
>
1
{
path
=
os
.
Args
[
1
:
][
0
]
...
...
@@ -17,7 +16,7 @@ func main() {
callApp
:=
new
(
JavaCallApp
)
callApp
.
AnalysisPath
(
path
)
identifierApp
:=
new
(
JavaIdentifierApp
)
identifierApp
.
AnalysisPath
(
path
)
//
//
identifierApp := new(JavaIdentifierApp)
//
identifierApp.AnalysisPath(path)
}
refactor/base/JavaRefactorApp.go
浏览文件 @
c60fcd39
...
...
@@ -8,6 +8,7 @@ import (
"strings"
.
"../../language/java"
.
"./models"
)
type
JavaRefactorApp
struct
{
...
...
@@ -25,9 +26,15 @@ func (j *JavaRefactorApp) AnalysisPath(codeDir string) {
parser
:=
(
*
JavaRefactorApp
)(
nil
)
.
processFile
(
file
)
context
:=
parser
.
CompilationUnit
()
listener
:=
new
(
JavaRefactorCallListener
)
interfaceIdent
:=
NewJFullIdentifier
()
listener
:=
new
(
JavaRefactorListener
)
listener
.
InitNode
(
interfaceIdent
)
antlr
.
NewParseTreeWalker
()
.
Walk
(
listener
,
context
)
if
interfaceIdent
.
Name
!=
""
{
fmt
.
Println
(
interfaceIdent
.
Type
,
interfaceIdent
.
Pkg
,
interfaceIdent
.
Name
,
interfaceIdent
.
GetMethods
())
}
}
}
...
...
refactor/base/JavaRefactorCallListener.go
已删除
100644 → 0
浏览文件 @
1855dca3
package
base
import
(
.
"../../language/java"
"fmt"
)
type
JavaRefactorCallListener
struct
{
BaseJavaParserListener
}
func
(
s
*
JavaRefactorCallListener
)
EnterCompilationUnit
(
ctx
*
CompilationUnitContext
)
{
declaration
:=
ctx
.
AllImportDeclaration
()
fmt
.
Println
(
declaration
)
}
func
(
s
*
JavaRefactorCallListener
)
EnterImportDeclaration
(
ctx
*
ImportDeclarationContext
)
{
importText
:=
ctx
.
QualifiedName
()
.
GetText
()
fmt
.
Println
(
importText
)
}
\ No newline at end of file
refactor/base/JavaRefactorListener.go
0 → 100644
浏览文件 @
c60fcd39
package
base
import
(
.
"../../language/java"
.
"./models"
)
var
node
*
JFullIdentifier
;
type
JavaRefactorListener
struct
{
BaseJavaParserListener
}
func
(
s
*
JavaRefactorListener
)
EnterPackageDeclaration
(
ctx
*
PackageDeclarationContext
)
{
node
.
Pkg
=
ctx
.
QualifiedName
()
.
GetText
()
}
func
(
s
*
JavaRefactorListener
)
EnterClassDeclaration
(
ctx
*
ClassDeclarationContext
)
{
node
.
Type
=
"Class"
node
.
Name
=
ctx
.
IDENTIFIER
()
.
GetText
()
}
func
(
s
*
JavaRefactorListener
)
EnterInterfaceMethodDeclaration
(
ctx
*
InterfaceMethodDeclarationContext
)
{
startLine
:=
ctx
.
GetStart
()
.
GetLine
()
startLinePosition
:=
ctx
.
GetStart
()
.
GetTokenSource
()
.
GetCharPositionInLine
()
stopLine
:=
ctx
.
GetStop
()
.
GetLine
()
stopLinePosition
:=
ctx
.
GetStop
()
.
GetTokenSource
()
.
GetCharPositionInLine
()
name
:=
ctx
.
IDENTIFIER
()
.
GetText
()
//XXX: find the start position of {, not public
method
:=
&
JFullMethod
{
name
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
}
node
.
AddMethod
(
*
method
)
}
func
(
s
*
JavaRefactorListener
)
EnterMethodDeclaration
(
ctx
*
MethodDeclarationContext
)
{
startLine
:=
ctx
.
GetStart
()
.
GetLine
()
startLinePosition
:=
ctx
.
GetStart
()
.
GetTokenSource
()
.
GetCharPositionInLine
()
stopLine
:=
ctx
.
GetStop
()
.
GetLine
()
stopLinePosition
:=
ctx
.
GetStop
()
.
GetTokenSource
()
.
GetCharPositionInLine
()
name
:=
ctx
.
IDENTIFIER
()
.
GetText
()
//XXX: find the start position of {, not public
method
:=
&
JFullMethod
{
name
,
startLine
,
startLinePosition
,
stopLine
,
stopLinePosition
}
node
.
AddMethod
(
*
method
)
}
func
(
s
*
JavaRefactorListener
)
EnterInterfaceDeclaration
(
ctx
*
InterfaceDeclarationContext
)
{
node
.
Type
=
"Interface"
node
.
Name
=
ctx
.
IDENTIFIER
()
.
GetText
()
}
func
(
s
*
JavaRefactorListener
)
InitNode
(
identifier
*
JFullIdentifier
)
{
node
=
identifier
}
refactor/base/models/JFullIdentifier.go
0 → 100644
浏览文件 @
c60fcd39
package
models
type
JFullMethod
struct
{
Name
string
StartLine
int
StartLinePosition
int
StopLine
int
StopLinePosition
int
}
var
methods
[]
JFullMethod
type
JFullIdentifier
struct
{
Pkg
string
Name
string
Type
string
}
func
NewJFullIdentifier
()
*
JFullIdentifier
{
identifier
:=
&
JFullIdentifier
{
""
,
""
,
""
}
methods
=
nil
return
identifier
}
func
(
identifier
*
JFullIdentifier
)
AddMethod
(
method
JFullMethod
)
{
methods
=
append
(
methods
,
method
)
}
func
(
identifier
*
JFullIdentifier
)
GetMethods
()
[]
JFullMethod
{
return
methods
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录