Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
b6a4f74e
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 搜索 >>
未验证
提交
b6a4f74e
编写于
12月 25, 2019
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: fix one class issue in ident
上级
29f9bb65
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
31 addition
and
26 deletion
+31
-26
core/adapter/identifier/JavaIdentifierApp.go
core/adapter/identifier/JavaIdentifierApp.go
+2
-6
core/adapter/identifier/JavaIdentifierApp_test.go
core/adapter/identifier/JavaIdentifierApp_test.go
+6
-5
core/adapter/identifier/JavaIdentifierListener.go
core/adapter/identifier/JavaIdentifierListener.go
+22
-14
languages/sql/sql_parser.go
languages/sql/sql_parser.go
+1
-1
未找到文件。
core/adapter/identifier/JavaIdentifierApp.go
浏览文件 @
b6a4f74e
...
...
@@ -24,16 +24,12 @@ func (j *JavaIdentifierApp) AnalysisPath(codeDir string) []models.JIdentifier {
parser
:=
support
.
ProcessFile
(
file
)
context
:=
parser
.
CompilationUnit
()
clzInfo
:=
models
.
NewJIdentifier
()
listener
:=
NewJavaIdentifierListener
()
listener
.
InitNode
(
clzInfo
)
antlr
.
NewParseTreeWalker
()
.
Walk
(
listener
,
context
)
if
clzInfo
.
ClassName
!=
""
{
clzInfo
.
Methods
=
clzInfo
.
GetMethods
()
nodeInfos
=
append
(
nodeInfos
,
*
clzInfo
)
}
identifiers
:=
listener
.
getNodes
()
nodeInfos
=
append
(
nodeInfos
,
identifiers
...
)
}
return
nodeInfos
...
...
core/adapter/identifier/JavaIdentifierApp_test.go
浏览文件 @
b6a4f74e
...
...
@@ -9,7 +9,7 @@ import (
func
TestJavaIdentifierApp_AnalysisPath
(
t
*
testing
.
T
)
{
g
:=
NewGomegaWithT
(
t
)
identApp
:=
new
(
JavaIdentifierApp
)
identApp
:=
NewJavaIdentifierApp
(
)
identifiers
:=
identApp
.
AnalysisPath
(
"../../../_fixtures/call"
)
g
.
Expect
(
len
(
identifiers
))
.
To
(
Equal
(
1
))
...
...
@@ -22,9 +22,10 @@ func TestJavaIdentifierApp_AnalysisPath(t *testing.T) {
func
TestPolymorphism_Method
(
t
*
testing
.
T
)
{
g
:=
NewGomegaWithT
(
t
)
identApp
:=
new
(
JavaIdentifierApp
)
identApp
:=
NewJavaIdentifierApp
(
)
identifiers
:=
identApp
.
AnalysisPath
(
"../../../_fixtures/suggest/polymorphism"
)
fmt
.
Println
(
identifiers
)
g
.
Expect
(
len
(
identifiers
))
.
To
(
Equal
(
1
))
g
.
Expect
(
identifiers
[
0
]
.
ClassName
)
.
To
(
Equal
(
"Overload"
))
g
.
Expect
(
len
(
identifiers
[
0
]
.
Methods
))
.
To
(
Equal
(
3
))
...
...
@@ -36,7 +37,7 @@ func TestPolymorphism_Constructor(t *testing.T) {
identApp
:=
new
(
JavaIdentifierApp
)
identifiers
:=
identApp
.
AnalysisPath
(
"../../../_fixtures/suggest/factory"
)
fmt
.
Println
(
identifiers
)
g
.
Expect
(
len
(
identifiers
))
.
To
(
Equal
(
1
))
g
.
Expect
(
identifiers
[
0
]
.
ClassName
)
.
To
(
Equal
(
"Bee"
))
g
.
Expect
(
len
(
identifiers
))
.
To
(
Equal
(
2
)
)
g
.
Expect
(
identifiers
[
0
]
.
ClassName
)
.
To
(
Equal
(
"Insect"
))
g
.
Expect
(
identifiers
[
1
]
.
ClassName
)
.
To
(
Equal
(
"Bee"
))
}
\ No newline at end of file
core/adapter/identifier/JavaIdentifierListener.go
浏览文件 @
b6a4f74e
...
...
@@ -7,7 +7,8 @@ import (
"strings"
)
var
node
*
models
.
JIdentifier
var
currentNode
*
models
.
JIdentifier
var
nodes
[]
models
.
JIdentifier
var
currentMethod
models
.
JMethod
var
hasEnterClass
=
false
...
...
@@ -15,7 +16,9 @@ var hasEnterMethod = false
var
imports
[]
string
func
NewJavaIdentifierListener
()
*
JavaIdentifierListener
{
hasEnterClass
=
false
nodes
=
nil
currentNode
=
models
.
NewJIdentifier
()
currentMethod
=
models
.
NewJMethod
()
return
&
JavaIdentifierListener
{}
}
...
...
@@ -29,19 +32,19 @@ func (s *JavaIdentifierListener) EnterImportDeclaration(ctx *parser.ImportDeclar
}
func
(
s
*
JavaIdentifierListener
)
EnterPackageDeclaration
(
ctx
*
parser
.
PackageDeclarationContext
)
{
n
ode
.
Package
=
ctx
.
QualifiedName
()
.
GetText
()
currentN
ode
.
Package
=
ctx
.
QualifiedName
()
.
GetText
()
}
func
(
s
*
JavaIdentifierListener
)
EnterClassDeclaration
(
ctx
*
parser
.
ClassDeclarationContext
)
{
hasEnterClass
=
true
n
ode
.
ClassType
=
"Class"
currentN
ode
.
ClassType
=
"Class"
if
ctx
.
IDENTIFIER
()
!=
nil
{
n
ode
.
ClassName
=
ctx
.
IDENTIFIER
()
.
GetText
()
currentN
ode
.
ClassName
=
ctx
.
IDENTIFIER
()
.
GetText
()
}
if
ctx
.
EXTENDS
()
!=
nil
{
n
ode
.
ExtendsName
=
ctx
.
TypeType
()
.
GetText
()
currentN
ode
.
ExtendsName
=
ctx
.
TypeType
()
.
GetText
()
}
if
ctx
.
IMPLEMENTS
()
!=
nil
{
...
...
@@ -50,7 +53,7 @@ func (s *JavaIdentifierListener) EnterClassDeclaration(ctx *parser.ClassDeclarat
typeText
:=
typ
.
GetText
()
for
_
,
imp
:=
range
imports
{
if
strings
.
HasSuffix
(
imp
,
"."
+
typeText
)
{
node
.
Implements
=
append
(
n
ode
.
Implements
,
imp
)
currentNode
.
Implements
=
append
(
currentN
ode
.
Implements
,
imp
)
}
}
}
...
...
@@ -59,6 +62,11 @@ func (s *JavaIdentifierListener) EnterClassDeclaration(ctx *parser.ClassDeclarat
func
(
s
*
JavaIdentifierListener
)
ExitClassBody
(
ctx
*
parser
.
ClassBodyContext
)
{
hasEnterClass
=
false
if
currentNode
.
ClassName
!=
""
{
currentNode
.
Methods
=
currentNode
.
GetMethods
()
nodes
=
append
(
nodes
,
*
currentNode
)
}
currentNode
=
models
.
NewJIdentifier
()
}
func
(
s
*
JavaIdentifierListener
)
EnterInterfaceBodyDeclaration
(
ctx
*
parser
.
InterfaceBodyDeclarationContext
)
{
...
...
@@ -98,7 +106,7 @@ func (s *JavaIdentifierListener) EnterInterfaceMethodDeclaration(ctx *parser.Int
func
(
s
*
JavaIdentifierListener
)
ExitInterfaceMethodDeclaration
(
ctx
*
parser
.
InterfaceMethodDeclarationContext
)
{
hasEnterMethod
=
false
n
ode
.
AddMethod
(
currentMethod
)
currentN
ode
.
AddMethod
(
currentMethod
)
currentMethod
=
models
.
NewJMethod
()
}
...
...
@@ -135,7 +143,7 @@ func (s *JavaIdentifierListener) EnterMethodDeclaration(ctx *parser.MethodDeclar
func
(
s
*
JavaIdentifierListener
)
ExitMethodDeclaration
(
ctx
*
parser
.
MethodDeclarationContext
)
{
hasEnterMethod
=
false
n
ode
.
AddMethod
(
currentMethod
)
currentN
ode
.
AddMethod
(
currentMethod
)
currentMethod
=
models
.
NewJMethod
()
}
...
...
@@ -151,7 +159,7 @@ func (s *JavaIdentifierListener) EnterAnnotation(ctx *parser.AnnotationContext)
currentMethod
.
Annotations
=
append
(
currentMethod
.
Annotations
,
annotation
)
}
else
{
annotation
:=
buildAnnotation
(
ctx
)
node
.
Annotations
=
append
(
n
ode
.
Annotations
,
annotation
)
currentNode
.
Annotations
=
append
(
currentN
ode
.
Annotations
,
annotation
)
}
}
...
...
@@ -176,10 +184,10 @@ func buildAnnotation(ctx *parser.AnnotationContext) models.Annotation {
func
(
s
*
JavaIdentifierListener
)
EnterInterfaceDeclaration
(
ctx
*
parser
.
InterfaceDeclarationContext
)
{
hasEnterClass
=
true
n
ode
.
ClassType
=
"Interface"
n
ode
.
ClassName
=
ctx
.
IDENTIFIER
()
.
GetText
()
currentN
ode
.
ClassType
=
"Interface"
currentN
ode
.
ClassName
=
ctx
.
IDENTIFIER
()
.
GetText
()
}
func
(
s
*
JavaIdentifierListener
)
InitNode
(
identifier
*
models
.
JIdentifier
)
{
node
=
identifier
func
(
s
*
JavaIdentifierListener
)
getNodes
()
[]
models
.
JIdentifier
{
return
nodes
}
languages/sql/sql_parser.go
浏览文件 @
b6a4f74e
...
...
@@ -1624,7 +1624,7 @@ func (p *SqlParser) Error() (localctx IErrorContext) {
localctx.(*ErrorContext)._UNEXPECTED_CHAR = _m
}
throw new RuntimeException("UNEXPECTED_CHAR=" + (func() string { if localctx.(*ErrorContext).Get_UNEXPECTED_CHAR() == nil { return "" } else { return localctx.(*ErrorContext).Get_UNEXPECTED_CHAR().GetText() }}()));
//
throw new RuntimeException("UNEXPECTED_CHAR=" + (func() string { if localctx.(*ErrorContext).Get_UNEXPECTED_CHAR() == nil { return "" } else { return localctx.(*ErrorContext).Get_UNEXPECTED_CHAR().GetText() }}()));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录