Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
bb47c8b7
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 搜索 >>
未验证
提交
bb47c8b7
编写于
1月 18, 2020
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: refactor members
上级
24df0a84
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
15 addition
and
74 deletion
+15
-74
pkg/application/analysis/goapp/go_ident_app.go
pkg/application/analysis/goapp/go_ident_app.go
+6
-4
pkg/domain/core_domain/code_file.go
pkg/domain/core_domain/code_file.go
+1
-1
pkg/infrastructure/ast/cocago/cocago_parser.go
pkg/infrastructure/ast/cocago/cocago_parser.go
+7
-21
pkg/infrastructure/ast/cocago/testdata/node_infos/normal_method.json
...ructure/ast/cocago/testdata/node_infos/normal_method.json
+0
-47
pkg/infrastructure/ast/pyast/python_ident_listener.go
pkg/infrastructure/ast/pyast/python_ident_listener.go
+1
-1
未找到文件。
pkg/application/analysis/goapp/go_ident_app.go
浏览文件 @
bb47c8b7
package
goapp
import
(
"fmt"
"github.com/phodal/coca/pkg/domain/core_domain"
"github.com/phodal/coca/pkg/infrastructure/ast/cocago"
)
...
...
@@ -18,10 +19,11 @@ func (g *GoIdentApp) Analysis(code string, fileName string) core_domain.CodeFile
return
*
parser
.
ProcessString
(
code
,
fileName
,
codeMembers
)
}
func
(
g
*
GoIdentApp
)
IdentAnalysis
(
s
string
,
file
string
)
[]
core_domain
.
CodeMember
{
//parser := cocago.NewCocagoParser()
//return parser.ProcessImports(code, fileName)
return
nil
func
(
g
*
GoIdentApp
)
IdentAnalysis
(
code
string
,
fileName
string
)
[]
core_domain
.
CodeMember
{
parser
:=
cocago
.
NewCocagoParser
()
codeFile
:=
parser
.
IdentAnalysis
(
code
,
fileName
)
fmt
.
Println
(
codeFile
)
return
codeFile
.
Members
}
func
(
g
*
GoIdentApp
)
SetExtensions
(
extension
interface
{})
{
...
...
pkg/domain/core_domain/code_file.go
浏览文件 @
bb47c8b7
...
...
@@ -4,7 +4,7 @@ type CodeFile struct {
FullName
string
PackageName
string
Imports
[]
CodeImport
Members
[]
*
CodeMember
Members
[]
CodeMember
DataStructures
[]
CodeDataStruct
Fields
[]
CodeField
}
pkg/infrastructure/ast/cocago/cocago_parser.go
浏览文件 @
bb47c8b7
...
...
@@ -59,29 +59,15 @@ func (n *CocagoParser) ProcessString(code string, fileName string, codeMembers [
return
codeFile
}
func
(
n
*
CocagoParser
)
ProcessImports
(
code
string
,
fileName
string
)
[]
core_domain
.
CodeImport
{
func
(
n
*
CocagoParser
)
IdentAnalysis
(
code
string
,
fileName
string
)
*
core_domain
.
CodeFile
{
fset
:=
token
.
NewFileSet
()
f
,
err
:=
parser
.
ParseFile
(
fset
,
fileName
,
code
,
0
)
if
err
!=
nil
{
panic
(
err
)
}
imports
:=
n
.
VisitorImport
(
f
,
fset
,
fileName
)
return
imports
}
func
(
n
*
CocagoParser
)
VisitorImport
(
f
*
ast
.
File
,
fset
*
token
.
FileSet
,
fileName
string
)
[]
core_domain
.
CodeImport
{
var
imports
[]
core_domain
.
CodeImport
ast
.
Inspect
(
f
,
func
(
n
ast
.
Node
)
bool
{
switch
x
:=
n
.
(
type
)
{
case
*
ast
.
ImportSpec
:
imp
:=
BuildImport
(
x
,
fileName
)
imports
=
append
(
imports
,
*
imp
)
}
return
true
})
return
imports
codeFile
:=
n
.
Visitor
(
f
,
fset
,
fileName
)
return
codeFile
}
func
(
n
*
CocagoParser
)
Visitor
(
f
*
ast
.
File
,
fset
*
token
.
FileSet
,
fileName
string
)
*
core_domain
.
CodeFile
{
...
...
@@ -226,7 +212,7 @@ func AddInterface(x *ast.InterfaceType, ident string, codeFile *core_domain.Code
Type
:
"interface"
,
}
codeFile
.
Members
=
append
(
codeFile
.
Members
,
&
member
)
codeFile
.
Members
=
append
(
codeFile
.
Members
,
member
)
return
dataStruct
}
...
...
@@ -252,7 +238,7 @@ func AddFunctionDecl(x *ast.FuncDecl, currentFile *core_domain.CodeFile) (*core_
}
member
.
FunctionNodes
=
append
(
member
.
FunctionNodes
,
*
codeFunc
)
currentFile
.
Members
=
append
(
currentFile
.
Members
,
member
)
currentFile
.
Members
=
append
(
currentFile
.
Members
,
*
member
)
}
return
codeFunc
,
recv
...
...
@@ -326,7 +312,7 @@ func GetMemberFromFile(file core_domain.CodeFile, recv string) *core_domain.Code
var
identMember
*
core_domain
.
CodeMember
for
_
,
member
:=
range
file
.
Members
{
if
member
.
DataStructID
==
recv
{
identMember
=
member
identMember
=
&
member
}
}
return
identMember
...
...
@@ -356,5 +342,5 @@ func AddStructType(currentNodeName string, x *ast.StructType, currentFile *core_
if
dsMap
[
currentNodeName
]
!=
nil
{
dsMap
[
currentNodeName
]
.
InOutProperties
=
ioproperties
}
currentFile
.
Members
=
append
(
currentFile
.
Members
,
&
member
)
currentFile
.
Members
=
append
(
currentFile
.
Members
,
member
)
}
pkg/infrastructure/ast/cocago/testdata/node_infos/normal_method.json
浏览文件 @
bb47c8b7
...
...
@@ -69,53 +69,6 @@
"StopLinePosition"
:
0
},
"ReturnType"
:
""
},
{
"Annotations"
:
null
,
"Extension"
:
null
,
"FunctionCalls"
:
null
,
"InnerFunctions"
:
null
,
"InnerStructures"
:
null
,
"IsConstructor"
:
false
,
"IsReturnNull"
:
false
,
"Modifiers"
:
null
,
"MultipleReturns"
:
[
{
"Modifiers"
:
null
,
"ParamName"
:
"is"
,
"Parameters"
:
null
,
"ReturnTypes"
:
null
,
"TypeType"
:
""
,
"TypeValue"
:
"antlr.CharStream"
},
{
"Modifiers"
:
null
,
"ParamName"
:
""
,
"Parameters"
:
null
,
"ReturnTypes"
:
null
,
"TypeType"
:
"Star"
,
"TypeValue"
:
"parser.TypeScriptParser"
}
],
"Name"
:
"processStream"
,
"Override"
:
false
,
"Parameters"
:
[
{
"Modifiers"
:
null
,
"ParamName"
:
"is"
,
"Parameters"
:
null
,
"ReturnTypes"
:
null
,
"TypeType"
:
""
,
"TypeValue"
:
"antlr.CharStream"
}
],
"Position"
:
{
"StartLine"
:
0
,
"StartLinePosition"
:
0
,
"StopLine"
:
0
,
"StopLinePosition"
:
0
},
"ReturnType"
:
""
}
],
"ID"
:
""
,
...
...
pkg/infrastructure/ast/pyast/python_ident_listener.go
浏览文件 @
bb47c8b7
...
...
@@ -115,7 +115,7 @@ func (s *PythonIdentListener) EnterFuncdef(ctx *parser.FuncdefContext) {
currentDataStruct
.
Functions
=
append
(
currentDataStruct
.
Functions
,
function
)
}
else
{
member
.
FunctionNodes
=
append
(
member
.
FunctionNodes
,
function
)
currentCodeFile
.
Members
=
append
(
currentCodeFile
.
Members
,
member
)
currentCodeFile
.
Members
=
append
(
currentCodeFile
.
Members
,
*
member
)
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录