Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
6d61d95e
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 搜索 >>
未验证
提交
6d61d95e
编写于
1月 17, 2020
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: refactor position
上级
8c41e0f1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
47 deletion
+23
-47
pkg/infrastructure/ast/full/java_full_listener.go
pkg/infrastructure/ast/full/java_full_listener.go
+23
-47
未找到文件。
pkg/infrastructure/ast/full/java_full_listener.go
浏览文件 @
6d61d95e
...
...
@@ -195,24 +195,14 @@ func (s *JavaFullListener) EnterInterfaceBodyDeclaration(ctx *parser.InterfaceBo
}
func
(
s
*
JavaFullListener
)
EnterInterfaceMethodDeclaration
(
ctx
*
parser
.
InterfaceMethodDeclarationContext
)
{
startLine
:=
ctx
.
GetStart
()
.
GetLine
()
startLinePosition
:=
ctx
.
IDENTIFIER
()
.
GetSymbol
()
.
GetColumn
()
stopLine
:=
ctx
.
GetStop
()
.
GetLine
()
name
:=
ctx
.
IDENTIFIER
()
.
GetText
()
stopLinePosition
:=
startLinePosition
+
len
(
name
)
typeType
:=
ctx
.
TypeTypeOrVoid
()
.
GetText
()
if
reflect
.
TypeOf
(
ctx
.
GetParent
()
.
GetParent
()
.
GetChild
(
0
))
.
String
()
==
"*parser.ModifierContext"
{
common_listener
.
BuildAnnotationForMethod
(
ctx
.
GetParent
()
.
GetParent
()
.
GetChild
(
0
)
.
(
*
parser
.
ModifierContext
),
&
currentMethod
)
}
position
:=
core_domain
.
CodePosition
{
StartLine
:
startLine
,
StartLinePosition
:
startLinePosition
,
StopLine
:
stopLine
,
StopLinePosition
:
stopLinePosition
,
}
position
:=
BuildPosition
(
ctx
.
BaseParserRuleContext
,
name
)
method
:=
&
core_domain
.
CodeFunction
{
Name
:
name
,
ReturnType
:
typeType
,
Position
:
position
}
updateMethod
(
method
)
...
...
@@ -289,15 +279,11 @@ func (s *JavaFullListener) EnterAnnotation(ctx *parser.AnnotationContext) {
}
func
(
s
*
JavaFullListener
)
EnterConstructorDeclaration
(
ctx
*
parser
.
ConstructorDeclarationContext
)
{
position
:=
core_domain
.
CodePosition
{
StartLine
:
ctx
.
GetStart
()
.
GetLine
(),
StartLinePosition
:
ctx
.
GetStart
()
.
GetColumn
(),
StopLine
:
ctx
.
GetStop
()
.
GetLine
(),
StopLinePosition
:
ctx
.
GetStop
()
.
GetColumn
(),
}
name
:=
ctx
.
IDENTIFIER
()
.
GetText
()
position
:=
BuildPosition
(
ctx
.
BaseParserRuleContext
,
name
)
method
:=
&
core_domain
.
CodeFunction
{
Name
:
ctx
.
IDENTIFIER
()
.
GetText
()
,
Name
:
name
,
ReturnType
:
""
,
Override
:
isOverrideMethod
,
Parameters
:
nil
,
...
...
@@ -320,23 +306,19 @@ func (s *JavaFullListener) ExitConstructorDeclaration(ctx *parser.ConstructorDec
}
func
(
s
*
JavaFullListener
)
EnterMethodDeclaration
(
ctx
*
parser
.
MethodDeclarationContext
)
{
startLine
:=
ctx
.
GetStart
()
.
GetLine
()
startLinePosition
:=
ctx
.
IDENTIFIER
()
.
GetSymbol
()
.
GetColumn
()
stopLine
:=
ctx
.
GetStop
()
.
GetLine
()
name
:=
ctx
.
IDENTIFIER
()
.
GetText
()
stopLinePosition
:=
startLinePosition
+
len
(
name
)
typeType
:=
ctx
.
TypeTypeOrVoid
()
.
GetText
()
if
reflect
.
TypeOf
(
ctx
.
GetParent
()
.
GetParent
()
.
GetChild
(
0
))
.
String
()
==
"*parser.ModifierContext"
{
common_listener
.
BuildAnnotationForMethod
(
ctx
.
GetParent
()
.
GetParent
()
.
GetChild
(
0
)
.
(
*
parser
.
ModifierContext
),
&
currentMethod
)
}
// check, before your refactor
position
:=
core_domain
.
CodePosition
{
StartLine
:
startLine
,
StartLinePosition
:
startLinePosition
,
StopLine
:
stopLine
,
StopLinePosition
:
stopLinePosition
,
StartLine
:
ctx
.
GetStart
()
.
GetLine
()
,
StartLinePosition
:
ctx
.
IDENTIFIER
()
.
GetSymbol
()
.
GetColumn
(),
// different
StopLine
:
ctx
.
GetStop
()
.
GetLine
()
,
StopLinePosition
:
ctx
.
IDENTIFIER
()
.
GetSymbol
()
.
GetColumn
()
+
len
(
name
)
,
}
method
:=
&
core_domain
.
CodeFunction
{
...
...
@@ -483,12 +465,7 @@ func buildCreatedCall(createdName string, ctx *parser.CreatorContext) {
method
:=
methodMap
[
getMethodMapName
(
currentMethod
)]
fullType
,
_
:=
WarpTargetFullType
(
createdName
)
position
:=
core_domain
.
CodePosition
{
StartLine
:
ctx
.
GetStart
()
.
GetLine
(),
StartLinePosition
:
ctx
.
GetStart
()
.
GetColumn
(),
StopLine
:
ctx
.
GetStop
()
.
GetLine
(),
StopLinePosition
:
ctx
.
GetStop
()
.
GetColumn
(),
}
position
:=
BuildPosition
(
ctx
.
BaseParserRuleContext
,
createdName
)
jMethodCall
:=
&
core_domain
.
CodeCall
{
Package
:
RemoveTarget
(
fullType
),
...
...
@@ -501,6 +478,17 @@ func buildCreatedCall(createdName string, ctx *parser.CreatorContext) {
methodMap
[
getMethodMapName
(
currentMethod
)]
=
method
}
func
BuildPosition
(
ctx
*
antlr
.
BaseParserRuleContext
,
nodeName
string
)
core_domain
.
CodePosition
{
position
:=
core_domain
.
CodePosition
{
StartLine
:
ctx
.
GetStart
()
.
GetLine
(),
StartLinePosition
:
ctx
.
GetStart
()
.
GetColumn
(),
StopLine
:
ctx
.
GetStop
()
.
GetLine
(),
StopLinePosition
:
ctx
.
GetStop
()
.
GetColumn
()
+
len
(
nodeName
),
}
return
position
}
func
(
s
*
JavaFullListener
)
EnterMethodCall
(
ctx
*
parser
.
MethodCallContext
)
{
var
jMethodCall
=
core_domain
.
NewCodeMethodCall
()
...
...
@@ -561,14 +549,7 @@ func (s *JavaFullListener) EnterExpression(ctx *parser.ExpressionContext) {
fullType
,
_
:=
WarpTargetFullType
(
targetType
)
startLinePosition
:=
ctx
.
GetStart
()
.
GetColumn
()
position
:=
core_domain
.
CodePosition
{
StartLine
:
ctx
.
GetStart
()
.
GetLine
(),
StartLinePosition
:
startLinePosition
,
StopLine
:
ctx
.
GetStop
()
.
GetLine
(),
StopLinePosition
:
startLinePosition
+
len
(
text
),
}
position
:=
BuildPosition
(
ctx
.
BaseParserRuleContext
,
text
)
jMethodCall
:=
&
core_domain
.
CodeCall
{
Package
:
RemoveTarget
(
fullType
),
...
...
@@ -595,12 +576,7 @@ func buildExtend(extendName string) {
func
buildFieldCall
(
typeType
string
,
ctx
*
parser
.
FieldDeclarationContext
)
{
target
,
_
:=
WarpTargetFullType
(
typeType
)
if
target
!=
""
{
position
:=
core_domain
.
CodePosition
{
StartLine
:
ctx
.
GetStart
()
.
GetLine
(),
StartLinePosition
:
ctx
.
GetStart
()
.
GetColumn
(),
StopLine
:
ctx
.
GetStop
()
.
GetLine
(),
StopLinePosition
:
ctx
.
GetStop
()
.
GetColumn
(),
}
position
:=
BuildPosition
(
ctx
.
BaseParserRuleContext
,
target
)
jMethodCall
:=
&
core_domain
.
CodeCall
{
Package
:
RemoveTarget
(
target
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录