Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
58ecc373
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,发现更多精彩内容 >>
未验证
提交
58ecc373
编写于
1月 15, 2020
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: update data struct field
上级
b3f83de9
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
67 addition
and
9 deletion
+67
-9
pkg/domain/trial/code_data_struct.go
pkg/domain/trial/code_data_struct.go
+17
-8
pkg/domain/trial/code_file.go
pkg/domain/trial/code_file.go
+2
-1
trial/cocago/testdata/node_infos/basic_interface.json
trial/cocago/testdata/node_infos/basic_interface.json
+12
-0
trial/cocago/testdata/node_infos/data_struct_property.json
trial/cocago/testdata/node_infos/data_struct_property.json
+4
-0
trial/cocago/testdata/node_infos/struct_type_zero.json
trial/cocago/testdata/node_infos/struct_type_zero.json
+4
-0
trial/cocago/testdata/node_infos/struct_with_func.json
trial/cocago/testdata/node_infos/struct_with_func.json
+4
-0
trial/cocago/testdata/node_infos/struct_with_func_decl.json
trial/cocago/testdata/node_infos/struct_with_func_decl.json
+4
-0
trial/pkg/application/pyapp/py_ident_app_test.go
trial/pkg/application/pyapp/py_ident_app_test.go
+11
-0
trial/pkg/ast/pyast/python_ident_listener.go
trial/pkg/ast/pyast/python_ident_listener.go
+9
-0
未找到文件。
pkg/domain/trial/code_data_struct.go
浏览文件 @
58ecc373
...
...
@@ -5,10 +5,19 @@ type CodeDataStruct struct {
ID
string
MemberIds
[]
string
Properties
[]
CodeProperty
//Fields []CodeProperty
//MethodCalls []CodeCall
//Extend string
//Implements []string
//Annotations []interface{}
//Tag []interface{}
Extend
string
Implements
[]
string
Annotations
[]
interface
{}
Extension
interface
{}
}
type
JavaExtension
struct
{
MethodCalls
[]
CodeCall
Fields
[]
CodeProperty
Tag
[]
interface
{}
}
type
PythonAnnotation
struct
{
Name
string
Properties
[]
CodeProperty
}
pkg/domain/trial/code_file.go
浏览文件 @
58ecc373
...
...
@@ -7,6 +7,7 @@ type CodeFile struct {
PackageName
string
Imports
[]
string
Members
[]
*
CodeMember
ClassNodes
[]
domain
.
JClassNode
DataStructures
[]
CodeDataStruct
// Deprecated: support for migration only
ClassNodes
[]
domain
.
JClassNode
}
trial/cocago/testdata/node_infos/basic_interface.json
浏览文件 @
58ecc373
...
...
@@ -2,7 +2,11 @@
"ClassNodes"
:
null
,
"DataStructures"
:
[
{
"Annotations"
:
null
,
"Extend"
:
""
,
"Extension"
:
null
,
"ID"
:
""
,
"Implements"
:
null
,
"MemberIds"
:
null
,
"Name"
:
"Shape"
,
"Properties"
:
[
...
...
@@ -35,7 +39,11 @@
]
},
{
"Annotations"
:
null
,
"Extend"
:
""
,
"Extension"
:
null
,
"ID"
:
""
,
"Implements"
:
null
,
"MemberIds"
:
null
,
"Name"
:
"Object"
,
"Properties"
:
[
...
...
@@ -59,7 +67,11 @@
]
},
{
"Annotations"
:
null
,
"Extend"
:
""
,
"Extension"
:
null
,
"ID"
:
""
,
"Implements"
:
null
,
"MemberIds"
:
null
,
"Name"
:
"Material"
,
"Properties"
:
[
...
...
trial/cocago/testdata/node_infos/data_struct_property.json
浏览文件 @
58ecc373
...
...
@@ -2,7 +2,11 @@
"ClassNodes"
:
null
,
"DataStructures"
:
[
{
"Annotations"
:
null
,
"Extend"
:
""
,
"Extension"
:
null
,
"ID"
:
""
,
"Implements"
:
null
,
"MemberIds"
:
null
,
"Name"
:
"CodeFile"
,
"Properties"
:
[
...
...
trial/cocago/testdata/node_infos/struct_type_zero.json
浏览文件 @
58ecc373
...
...
@@ -2,7 +2,11 @@
"ClassNodes"
:
null
,
"DataStructures"
:
[
{
"Annotations"
:
null
,
"Extend"
:
""
,
"Extension"
:
null
,
"ID"
:
""
,
"Implements"
:
null
,
"MemberIds"
:
null
,
"Name"
:
"O"
,
"Properties"
:
null
...
...
trial/cocago/testdata/node_infos/struct_with_func.json
浏览文件 @
58ecc373
...
...
@@ -2,7 +2,11 @@
"ClassNodes"
:
null
,
"DataStructures"
:
[
{
"Annotations"
:
null
,
"Extend"
:
""
,
"Extension"
:
null
,
"ID"
:
""
,
"Implements"
:
null
,
"MemberIds"
:
null
,
"Name"
:
"Person"
,
"Properties"
:
[
...
...
trial/cocago/testdata/node_infos/struct_with_func_decl.json
浏览文件 @
58ecc373
...
...
@@ -2,7 +2,11 @@
"ClassNodes"
:
null
,
"DataStructures"
:
[
{
"Annotations"
:
null
,
"Extend"
:
""
,
"Extension"
:
null
,
"ID"
:
""
,
"Implements"
:
null
,
"MemberIds"
:
null
,
"Name"
:
"person"
,
"Properties"
:
[
...
...
trial/pkg/application/pyapp/py_ident_app_test.go
浏览文件 @
58ecc373
...
...
@@ -42,3 +42,14 @@ func Test_PythonClass(t *testing.T) {
results
:=
app
.
Analysis
(
string
(
defs
),
"testdata/grammar/classdef.py"
)
g
.
Expect
(
len
(
results
.
DataStructures
))
.
To
(
Equal
(
3
))
}
func
Test_PythonClassWithDecorator
(
t
*
testing
.
T
)
{
g
:=
NewGomegaWithT
(
t
)
app
:=
new
(
PythonApiApp
)
file
,
_
:=
ioutil
.
ReadFile
(
"testdata/grammar/class_or_func_def_stmt.py"
)
codeFile
:=
app
.
Analysis
(
string
(
file
),
"testdata/grammar/class_or_func_def_stmt.py"
)
g
.
Expect
(
len
(
codeFile
.
DataStructures
))
.
To
(
Equal
(
1
))
}
trial/pkg/ast/pyast/python_ident_listener.go
浏览文件 @
58ecc373
package
pyast
import
(
"fmt"
parser
"github.com/phodal/coca/languages/python"
"github.com/phodal/coca/pkg/domain/trial"
"reflect"
)
type
PythonIdentListener
struct
{
...
...
@@ -25,6 +27,13 @@ func (s *PythonIdentListener) EnterClassdef(ctx *parser.ClassdefContext) {
Properties
:
nil
,
}
switch
x
:=
ctx
.
GetParent
()
.
GetChild
(
0
)
.
(
type
)
{
case
*
parser
.
DecoratorContext
:
default
:
fmt
.
Println
(
reflect
.
TypeOf
(
x
))
}
currentCodeFile
.
DataStructures
=
append
(
currentCodeFile
.
DataStructures
,
dataStruct
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录