Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Chapi
提交
9e08616e
C
Chapi
项目概览
Phodal
/
Chapi
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Chapi
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
9e08616e
编写于
6月 03, 2020
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor:move build annotation to parent
上级
ee07ae94
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
28 addition
and
19 deletion
+28
-19
chapi-ast-typescript/src/main/java/chapi/ast/antlr/TypeScriptParserBaseListener.java
...in/java/chapi/ast/antlr/TypeScriptParserBaseListener.java
+10
-2
chapi-ast-typescript/src/main/kotlin/chapi/ast/typescriptast/TypeScriptAstListener.kt
...n/kotlin/chapi/ast/typescriptast/TypeScriptAstListener.kt
+18
-2
chapi-ast-typescript/src/main/kotlin/chapi/ast/typescriptast/TypeScriptFullIdentListener.kt
...in/chapi/ast/typescriptast/TypeScriptFullIdentListener.kt
+0
-15
未找到文件。
chapi-ast-typescript/src/main/java/chapi/ast/antlr/TypeScriptParserBaseListener.java
浏览文件 @
9e08616e
// Generated from TypeScriptParser.g4 by ANTLR 4.8
package
chapi.ast.antlr
;
import
chapi.domain.core.CodeAnnotation
;
import
org.antlr.v4.runtime.ParserRuleContext
;
import
org.antlr.v4.runtime.tree.ErrorNode
;
import
org.antlr.v4.runtime.tree.TerminalNode
;
import
org.jetbrains.annotations.NotNull
;
/**
* This class provides an empty implementation of {@link TypeScriptParserListener},
* which can be extended to create a listener which only needs to handle a subset
* of the available methods.
*/
public
class
TypeScriptParserBaseListener
implements
TypeScriptParserListener
{
public
abstract
class
TypeScriptParserBaseListener
implements
TypeScriptParserListener
{
/**
* {@inheritDoc}
*
...
...
@@ -2592,4 +2594,10 @@ public class TypeScriptParserBaseListener implements TypeScriptParserListener {
* <p>The default implementation does nothing.</p>
*/
@Override
public
void
visitErrorNode
(
ErrorNode
node
)
{
}
}
\ No newline at end of file
@NotNull
protected
abstract
CodeAnnotation
buildAnnotation
(
@NotNull
TypeScriptParser
.
DecoratorContext
decorator
);
@NotNull
protected
abstract
CodeAnnotation
buildAnnotation
(
@NotNull
TypeScriptParser
.
DecoratorContext
decorator
);
}
chapi-ast-typescript/src/main/kotlin/chapi/ast/typescriptast/TypeScriptAstListener.kt
浏览文件 @
9e08616e
...
...
@@ -2,11 +2,12 @@ package chapi.ast.typescriptast
import
chapi.ast.antlr.TypeScriptParser
import
chapi.ast.antlr.TypeScriptParserBaseListener
import
chapi.domain.core.CodeAnnotation
import
chapi.domain.core.CodePosition
import
chapi.domain.core.CodeProperty
import
org.antlr.v4.runtime.ParserRuleContext
open
class
TypeScriptAstListener
()
:
TypeScriptParserBaseListener
()
{
open
class
TypeScriptAstListener
:
TypeScriptParserBaseListener
()
{
fun
buildParameters
(
formalParameterListContext
:
TypeScriptParser
.
FormalParameterListContext
?
):
Array
<
CodeProperty
>
{
...
...
@@ -112,7 +113,7 @@ open class TypeScriptAstListener() : TypeScriptParserBaseListener() {
}
private
fun
buildRequireParameter
(
paramCtx
:
TypeScriptParser
.
RequiredParameterContext
?):
CodeProperty
{
var
paramType
:
String
=
""
var
paramType
=
""
if
(
paramCtx
!!
.
typeAnnotation
()
!=
null
)
{
paramType
=
buildTypeAnnotation
(
paramCtx
.
typeAnnotation
())
!!
}
...
...
@@ -124,4 +125,19 @@ open class TypeScriptAstListener() : TypeScriptParserBaseListener() {
return
parameter
}
override
fun
buildAnnotation
(
decorator
:
TypeScriptParser
.
DecoratorContext
):
CodeAnnotation
{
val
annotation
=
CodeAnnotation
()
val
memberExpression
=
decorator
.
decoratorMemberExpression
()
val
callExpression
=
decorator
.
decoratorCallExpression
()
if
(
memberExpression
!=
null
)
{
annotation
.
Name
=
memberExpression
.
Identifier
().
text
}
if
(
callExpression
!=
null
)
{
val
member
=
callExpression
.
decoratorMemberExpression
()
annotation
.
Name
=
member
.
Identifier
().
text
}
return
annotation
}
}
chapi-ast-typescript/src/main/kotlin/chapi/ast/typescriptast/TypeScriptFullIdentListener.kt
浏览文件 @
9e08616e
...
...
@@ -71,21 +71,6 @@ class TypeScriptFullIdentListener(private var node: TSIdentify) : TypeScriptAstL
}
}
private
fun
buildAnnotation
(
decorator
:
TypeScriptParser
.
DecoratorContext
):
CodeAnnotation
{
val
annotation
=
CodeAnnotation
()
val
memberExpression
=
decorator
.
decoratorMemberExpression
()
val
callExpression
=
decorator
.
decoratorCallExpression
()
if
(
memberExpression
!=
null
)
{
annotation
.
Name
=
memberExpression
.
Identifier
().
text
}
if
(
callExpression
!=
null
)
{
val
member
=
callExpression
.
decoratorMemberExpression
()
annotation
.
Name
=
member
.
Identifier
().
text
}
return
annotation
}
private
fun
handleClassBodyElements
(
classTailCtx
:
TypeScriptParser
.
ClassTailContext
?)
{
for
(
clzElementCtx
in
classTailCtx
!!
.
classElement
())
{
val
childCtx
=
clzElementCtx
.
getChild
(
0
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录