Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
5721d74b
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 搜索 >>
未验证
提交
5721d74b
编写于
2月 13, 2020
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: rename codefile to codecontainer for c#
上级
d06f9ee5
变更
26
展开全部
隐藏空白更改
内联
并排
Showing
26 changed file
with
822 addition
and
23 deletion
+822
-23
cmd/analysis.go
cmd/analysis.go
+2
-2
gen/GoLexer.interp
gen/GoLexer.interp
+250
-0
gen/GoLexer.java
gen/GoLexer.java
+399
-0
gen/GoLexer.tokens
gen/GoLexer.tokens
+137
-0
pkg/application/analysis/app_concept/abstract_analysis_app.go
...application/analysis/app_concept/abstract_analysis_app.go
+1
-1
pkg/application/analysis/goapp/go_ident_app.go
pkg/application/analysis/goapp/go_ident_app.go
+1
-1
pkg/application/analysis/pyapp/py_ident_app.go
pkg/application/analysis/pyapp/py_ident_app.go
+1
-1
pkg/application/analysis/tsapp/ts_ident_app.go
pkg/application/analysis/tsapp/ts_ident_app.go
+1
-1
pkg/domain/core_domain/code_file.go
pkg/domain/core_domain/code_file.go
+2
-1
pkg/domain/core_domain/code_package.go
pkg/domain/core_domain/code_package.go
+1
-1
pkg/infrastructure/ast/ast_go/cocago_builder.go
pkg/infrastructure/ast/ast_go/cocago_builder.go
+1
-1
pkg/infrastructure/ast/ast_go/cocago_parser.go
pkg/infrastructure/ast/ast_go/cocago_parser.go
+9
-9
pkg/infrastructure/ast/ast_go/testdata/method_call/local_var_method_call.json
...st/ast_go/testdata/method_call/local_var_method_call.json
+1
-0
pkg/infrastructure/ast/ast_go/testdata/method_call/param_method_call.json
...re/ast/ast_go/testdata/method_call/param_method_call.json
+1
-0
pkg/infrastructure/ast/ast_go/testdata/method_call/var_inside_method_with_call.json
..._go/testdata/method_call/var_inside_method_with_call.json
+1
-0
pkg/infrastructure/ast/ast_go/testdata/node_infos/basic_interface.json
...cture/ast/ast_go/testdata/node_infos/basic_interface.json
+1
-0
pkg/infrastructure/ast/ast_go/testdata/node_infos/data_struct_property.json
.../ast/ast_go/testdata/node_infos/data_struct_property.json
+1
-0
pkg/infrastructure/ast/ast_go/testdata/node_infos/hello_world.json
...structure/ast/ast_go/testdata/node_infos/hello_world.json
+1
-0
pkg/infrastructure/ast/ast_go/testdata/node_infos/multiple_method_call.json
.../ast/ast_go/testdata/node_infos/multiple_method_call.json
+1
-0
pkg/infrastructure/ast/ast_go/testdata/node_infos/nested_method.json
...ructure/ast/ast_go/testdata/node_infos/nested_method.json
+1
-0
pkg/infrastructure/ast/ast_go/testdata/node_infos/normal_method.json
...ructure/ast/ast_go/testdata/node_infos/normal_method.json
+1
-0
pkg/infrastructure/ast/ast_go/testdata/node_infos/struct_type_zero.json
...ture/ast/ast_go/testdata/node_infos/struct_type_zero.json
+1
-0
pkg/infrastructure/ast/ast_go/testdata/node_infos/struct_with_func.json
...ture/ast/ast_go/testdata/node_infos/struct_with_func.json
+1
-0
pkg/infrastructure/ast/ast_go/testdata/node_infos/struct_with_func_decl.json
...ast/ast_go/testdata/node_infos/struct_with_func_decl.json
+1
-0
pkg/infrastructure/ast/ast_python/python_ident_listener.go
pkg/infrastructure/ast/ast_python/python_ident_listener.go
+3
-3
pkg/infrastructure/ast/ast_typescript/typescript_ident_listener.go
...structure/ast/ast_typescript/typescript_ident_listener.go
+2
-2
未找到文件。
cmd/analysis.go
浏览文件 @
5721d74b
...
...
@@ -66,7 +66,7 @@ func AnalysisGo() []core_domain.CodeDataStruct {
}
func
CommentAnalysis
(
path
string
,
app
app_concept
.
AbstractAnalysisApp
,
filter
func
(
path
string
)
bool
,
isFunctionBase
bool
)
[]
core_domain
.
CodeDataStruct
{
var
results
[]
core_domain
.
Code
File
var
results
[]
core_domain
.
Code
Container
files
:=
cocafile
.
GetFilesWithFilter
(
path
,
filter
)
var
codeMembers
[]
core_domain
.
CodeMember
...
...
@@ -103,7 +103,7 @@ func CommentAnalysis(path string, app app_concept.AbstractAnalysisApp, filter fu
return
ds
}
func
BuildMethodDs
(
result
core_domain
.
Code
File
)
[]
core_domain
.
CodeDataStruct
{
func
BuildMethodDs
(
result
core_domain
.
Code
Container
)
[]
core_domain
.
CodeDataStruct
{
var
methodsDs
[]
core_domain
.
CodeDataStruct
for
_
,
member
:=
range
result
.
Members
{
for
_
,
node
:=
range
member
.
FunctionNodes
{
...
...
gen/GoLexer.interp
0 → 100644
浏览文件 @
5721d74b
此差异已折叠。
点击以展开。
gen/GoLexer.java
0 → 100644
浏览文件 @
5721d74b
此差异已折叠。
点击以展开。
gen/GoLexer.tokens
0 → 100644
浏览文件 @
5721d74b
BREAK=1
DEFAULT=2
FUNC=3
INTERFACE=4
SELECT=5
CASE=6
DEFER=7
GO=8
MAP=9
STRUCT=10
CHAN=11
ELSE=12
GOTO=13
PACKAGE=14
SWITCH=15
CONST=16
FALLTHROUGH=17
IF=18
RANGE=19
TYPE=20
CONTINUE=21
FOR=22
IMPORT=23
RETURN=24
VAR=25
NIL_LIT=26
IDENTIFIER=27
L_PAREN=28
R_PAREN=29
L_CURLY=30
R_CURLY=31
L_BRACKET=32
R_BRACKET=33
ASSIGN=34
COMMA=35
SEMI=36
COLON=37
DOT=38
PLUS_PLUS=39
MINUS_MINUS=40
DECLARE_ASSIGN=41
ELLIPSIS=42
LOGICAL_OR=43
LOGICAL_AND=44
EQUALS=45
NOT_EQUALS=46
LESS=47
LESS_OR_EQUALS=48
GREATER=49
GREATER_OR_EQUALS=50
OR=51
DIV=52
MOD=53
LSHIFT=54
RSHIFT=55
BIT_CLEAR=56
EXCLAMATION=57
PLUS=58
MINUS=59
CARET=60
STAR=61
AMPERSAND=62
RECEIVE=63
DECIMAL_LIT=64
OCTAL_LIT=65
HEX_LIT=66
FLOAT_LIT=67
IMAGINARY_LIT=68
RUNE_LIT=69
RAW_STRING_LIT=70
INTERPRETED_STRING_LIT=71
WS=72
COMMENT=73
TERMINATOR=74
LINE_COMMENT=75
'break'=1
'default'=2
'func'=3
'interface'=4
'select'=5
'case'=6
'defer'=7
'go'=8
'map'=9
'struct'=10
'chan'=11
'else'=12
'goto'=13
'package'=14
'switch'=15
'const'=16
'fallthrough'=17
'if'=18
'range'=19
'type'=20
'continue'=21
'for'=22
'import'=23
'return'=24
'var'=25
'nil'=26
'('=28
')'=29
'{'=30
'}'=31
'['=32
']'=33
'='=34
','=35
';'=36
':'=37
'.'=38
'++'=39
'--'=40
':='=41
'...'=42
'||'=43
'&&'=44
'=='=45
'!='=46
'<'=47
'<='=48
'>'=49
'>='=50
'|'=51
'/'=52
'%'=53
'<<'=54
'>>'=55
'&^'=56
'!'=57
'+'=58
'-'=59
'^'=60
'*'=61
'&'=62
'<-'=63
pkg/application/analysis/app_concept/abstract_analysis_app.go
浏览文件 @
5721d74b
...
...
@@ -3,7 +3,7 @@ package app_concept
import
"github.com/phodal/coca/pkg/domain/core_domain"
type
AbstractAnalysisApp
interface
{
Analysis
(
code
string
,
path
string
)
core_domain
.
Code
File
Analysis
(
code
string
,
path
string
)
core_domain
.
Code
Container
IdentAnalysis
(
s
string
,
file
string
)
[]
core_domain
.
CodeMember
SetExtensions
(
extension
interface
{})
AnalysisPackageManager
(
path
string
)
core_domain
.
CodePackageManagerInfo
...
...
pkg/application/analysis/goapp/go_ident_app.go
浏览文件 @
5721d74b
...
...
@@ -29,7 +29,7 @@ func (g *GoIdentApp) AnalysisPackageManager(path string) core_domain.CodePackage
return
*
pmInfo
}
func
(
g
*
GoIdentApp
)
Analysis
(
code
string
,
fileName
string
)
core_domain
.
Code
File
{
func
(
g
*
GoIdentApp
)
Analysis
(
code
string
,
fileName
string
)
core_domain
.
Code
Container
{
parser
:=
ast_go
.
NewCocagoParser
()
var
codeMembers
[]
core_domain
.
CodeMember
if
g
.
Extensions
!=
nil
{
...
...
pkg/application/analysis/pyapp/py_ident_app.go
浏览文件 @
5721d74b
...
...
@@ -26,7 +26,7 @@ func (p *PythonIdentApp) AnalysisPackageManager(path string) core_domain.CodePac
return
core_domain
.
CodePackageManagerInfo
{}
}
func
(
p
*
PythonIdentApp
)
Analysis
(
code
string
,
fileName
string
)
core_domain
.
Code
File
{
func
(
p
*
PythonIdentApp
)
Analysis
(
code
string
,
fileName
string
)
core_domain
.
Code
Container
{
scriptParser
:=
ProcessPythonString
(
code
)
context
:=
scriptParser
.
Root
()
...
...
pkg/application/analysis/tsapp/ts_ident_app.go
浏览文件 @
5721d74b
...
...
@@ -26,7 +26,7 @@ func (t *TypeScriptIdentApp) AnalysisPackageManager(path string) core_domain.Cod
return
core_domain
.
CodePackageManagerInfo
{}
}
func
(
t
*
TypeScriptIdentApp
)
Analysis
(
code
string
,
fileName
string
)
core_domain
.
Code
File
{
func
(
t
*
TypeScriptIdentApp
)
Analysis
(
code
string
,
fileName
string
)
core_domain
.
Code
Container
{
scriptParser
:=
ProcessTsString
(
code
)
context
:=
scriptParser
.
Program
()
...
...
pkg/domain/core_domain/code_file.go
浏览文件 @
5721d74b
package
core_domain
type
Code
File
struct
{
type
Code
Container
struct
{
FullName
string
PackageName
string
Imports
[]
CodeImport
Members
[]
CodeMember
DataStructures
[]
CodeDataStruct
Fields
[]
CodeField
Containers
[]
CodeContainer
}
pkg/domain/core_domain/code_package.go
浏览文件 @
5721d74b
...
...
@@ -3,7 +3,7 @@ package core_domain
type
CodePackage
struct
{
Name
string
ID
string
CodeFiles
[]
Code
File
CodeFiles
[]
Code
Container
Extension
interface
{}
}
...
...
pkg/infrastructure/ast/ast_go/cocago_builder.go
浏览文件 @
5721d74b
...
...
@@ -75,7 +75,7 @@ func getStarExprName(starExpr ast.StarExpr) string {
}
}
func
BuildFunction
(
x
*
ast
.
FuncDecl
,
file
*
Code
File
)
*
CodeFunction
{
func
BuildFunction
(
x
*
ast
.
FuncDecl
,
file
*
Code
Container
)
*
CodeFunction
{
codeFunc
:=
&
CodeFunction
{
Name
:
x
.
Name
.
String
(),
}
...
...
pkg/infrastructure/ast/ast_go/cocago_parser.go
浏览文件 @
5721d74b
...
...
@@ -41,7 +41,7 @@ func (n *CocagoParser) SetOutput(out io.Writer) io.Writer {
return
output
}
func
(
n
*
CocagoParser
)
ProcessFile
(
fileName
string
)
core_domain
.
Code
File
{
func
(
n
*
CocagoParser
)
ProcessFile
(
fileName
string
)
core_domain
.
Code
Container
{
absPath
,
_
:=
filepath
.
Abs
(
fileName
)
content
,
_
:=
ioutil
.
ReadFile
(
absPath
)
...
...
@@ -53,7 +53,7 @@ func (n *CocagoParser) ProcessFile(fileName string) core_domain.CodeFile {
return
*
codeFile
}
func
(
n
*
CocagoParser
)
ProcessString
(
code
string
,
fileName
string
,
codeMembers
[]
core_domain
.
CodeMember
)
*
core_domain
.
Code
File
{
func
(
n
*
CocagoParser
)
ProcessString
(
code
string
,
fileName
string
,
codeMembers
[]
core_domain
.
CodeMember
)
*
core_domain
.
Code
Container
{
identCodeMembers
=
codeMembers
n
.
CodeMembers
=
codeMembers
fset
:=
token
.
NewFileSet
()
...
...
@@ -67,7 +67,7 @@ func (n *CocagoParser) ProcessString(code string, fileName string, codeMembers [
return
codeFile
}
func
(
n
*
CocagoParser
)
IdentAnalysis
(
code
string
,
fileName
string
)
*
core_domain
.
Code
File
{
func
(
n
*
CocagoParser
)
IdentAnalysis
(
code
string
,
fileName
string
)
*
core_domain
.
Code
Container
{
fset
:=
token
.
NewFileSet
()
f
,
err
:=
parser
.
ParseFile
(
fset
,
fileName
,
code
,
0
)
if
err
!=
nil
{
...
...
@@ -78,9 +78,9 @@ func (n *CocagoParser) IdentAnalysis(code string, fileName string) *core_domain.
return
codeFile
}
func
(
n
*
CocagoParser
)
Visitor
(
f
*
ast
.
File
,
fset
*
token
.
FileSet
,
fileName
string
)
*
core_domain
.
Code
File
{
func
(
n
*
CocagoParser
)
Visitor
(
f
*
ast
.
File
,
fset
*
token
.
FileSet
,
fileName
string
)
*
core_domain
.
Code
Container
{
var
currentStruct
core_domain
.
CodeDataStruct
var
currentFile
core_domain
.
Code
File
var
currentFile
core_domain
.
Code
Container
var
currentFunc
*
core_domain
.
CodeFunction
var
dsMap
=
make
(
map
[
string
]
*
core_domain
.
CodeDataStruct
)
...
...
@@ -213,7 +213,7 @@ func BuildImportName(fileName string) string {
return
importName
}
func
AddInterface
(
x
*
ast
.
InterfaceType
,
ident
string
,
codeFile
*
core_domain
.
Code
File
)
core_domain
.
CodeDataStruct
{
func
AddInterface
(
x
*
ast
.
InterfaceType
,
ident
string
,
codeFile
*
core_domain
.
Code
Container
)
core_domain
.
CodeDataStruct
{
properties
:=
BuildFieldToProperty
(
x
.
Methods
.
List
)
dataStruct
:=
core_domain
.
CodeDataStruct
{
...
...
@@ -231,7 +231,7 @@ func AddInterface(x *ast.InterfaceType, ident string, codeFile *core_domain.Code
return
dataStruct
}
func
setMemberPackageInfo
(
member
*
core_domain
.
CodeMember
,
codeFile
*
core_domain
.
Code
File
)
{
func
setMemberPackageInfo
(
member
*
core_domain
.
CodeMember
,
codeFile
*
core_domain
.
Code
Container
)
{
member
.
AliasPackage
=
codeFile
.
PackageName
member
.
FileID
=
codeFile
.
FullName
member
.
BuildMemberId
()
...
...
@@ -241,7 +241,7 @@ func AddNestedFunction(currentFunc *core_domain.CodeFunction, x *ast.FuncType) {
}
func
AddFunctionDecl
(
x
*
ast
.
FuncDecl
,
currentFile
*
core_domain
.
Code
File
)
(
*
core_domain
.
CodeFunction
,
string
)
{
func
AddFunctionDecl
(
x
*
ast
.
FuncDecl
,
currentFile
*
core_domain
.
Code
Container
)
(
*
core_domain
.
CodeFunction
,
string
)
{
recv
:=
""
if
x
.
Recv
!=
nil
{
recv
=
BuildReceiver
(
x
,
recv
)
...
...
@@ -329,7 +329,7 @@ func getFieldName(field *ast.Field) string {
return
field
.
Names
[
0
]
.
Name
}
func
AddStructType
(
currentNodeName
string
,
x
*
ast
.
StructType
,
currentFile
*
core_domain
.
Code
File
,
dsMap
map
[
string
]
*
core_domain
.
CodeDataStruct
)
{
func
AddStructType
(
currentNodeName
string
,
x
*
ast
.
StructType
,
currentFile
*
core_domain
.
Code
Container
,
dsMap
map
[
string
]
*
core_domain
.
CodeDataStruct
)
{
member
:=
core_domain
.
NewCodeMember
()
member
.
DataStructID
=
currentNodeName
member
.
Type
=
"struct"
...
...
pkg/infrastructure/ast/ast_go/testdata/method_call/local_var_method_call.json
浏览文件 @
5721d74b
{
"Containers"
:
null
,
"DataStructures"
:
null
,
"Fields"
:
[
{
...
...
pkg/infrastructure/ast/ast_go/testdata/method_call/param_method_call.json
浏览文件 @
5721d74b
{
"Containers"
:
null
,
"DataStructures"
:
null
,
"Fields"
:
null
,
"FullName"
:
"testdata.method_call"
,
...
...
pkg/infrastructure/ast/ast_go/testdata/method_call/var_inside_method_with_call.json
浏览文件 @
5721d74b
{
"Containers"
:
null
,
"DataStructures"
:
null
,
"Fields"
:
null
,
"FullName"
:
"testdata.method_call"
,
...
...
pkg/infrastructure/ast/ast_go/testdata/node_infos/basic_interface.json
浏览文件 @
5721d74b
{
"Containers"
:
null
,
"DataStructures"
:
[
{
"Annotations"
:
null
,
...
...
pkg/infrastructure/ast/ast_go/testdata/node_infos/data_struct_property.json
浏览文件 @
5721d74b
{
"Containers"
:
null
,
"DataStructures"
:
[
{
"Annotations"
:
null
,
...
...
pkg/infrastructure/ast/ast_go/testdata/node_infos/hello_world.json
浏览文件 @
5721d74b
{
"Containers"
:
null
,
"DataStructures"
:
null
,
"Fields"
:
null
,
"FullName"
:
"testdata.node_infos"
,
...
...
pkg/infrastructure/ast/ast_go/testdata/node_infos/multiple_method_call.json
浏览文件 @
5721d74b
{
"Containers"
:
null
,
"DataStructures"
:
null
,
"Fields"
:
[
{
...
...
pkg/infrastructure/ast/ast_go/testdata/node_infos/nested_method.json
浏览文件 @
5721d74b
{
"Containers"
:
null
,
"DataStructures"
:
null
,
"Fields"
:
null
,
"FullName"
:
"testdata.node_infos"
,
...
...
pkg/infrastructure/ast/ast_go/testdata/node_infos/normal_method.json
浏览文件 @
5721d74b
{
"Containers"
:
null
,
"DataStructures"
:
null
,
"Fields"
:
null
,
"FullName"
:
"testdata.node_infos"
,
...
...
pkg/infrastructure/ast/ast_go/testdata/node_infos/struct_type_zero.json
浏览文件 @
5721d74b
{
"Containers"
:
null
,
"DataStructures"
:
[
{
"Annotations"
:
null
,
...
...
pkg/infrastructure/ast/ast_go/testdata/node_infos/struct_with_func.json
浏览文件 @
5721d74b
{
"Containers"
:
null
,
"DataStructures"
:
[
{
"Annotations"
:
null
,
...
...
pkg/infrastructure/ast/ast_go/testdata/node_infos/struct_with_func_decl.json
浏览文件 @
5721d74b
{
"Containers"
:
null
,
"DataStructures"
:
[
{
"Annotations"
:
null
,
...
...
pkg/infrastructure/ast/ast_python/python_ident_listener.go
浏览文件 @
5721d74b
...
...
@@ -15,14 +15,14 @@ type PythonIdentListener struct {
parser
.
BasePythonParserListener
}
var
currentCodeFile
*
core_domain
.
Code
File
var
currentCodeFile
*
core_domain
.
Code
Container
var
currentDataStruct
*
core_domain
.
CodeDataStruct
var
debug
=
false
var
output
io
.
Writer
var
hasEnterMember
=
false
func
NewPythonIdentListener
(
fileName
string
)
*
PythonIdentListener
{
currentCodeFile
=
&
core_domain
.
Code
File
{}
currentCodeFile
=
&
core_domain
.
Code
Container
{}
currentCodeFile
.
FullName
=
fileName
output
=
os
.
Stdout
...
...
@@ -165,6 +165,6 @@ func BuildArgList(context *parser.ArglistContext) []core_domain.AnnotationKeyVal
return
arguments
}
func
(
s
*
PythonIdentListener
)
GetCodeFileInfo
()
core_domain
.
Code
File
{
func
(
s
*
PythonIdentListener
)
GetCodeFileInfo
()
core_domain
.
Code
Container
{
return
*
currentCodeFile
}
pkg/infrastructure/ast/ast_typescript/typescript_ident_listener.go
浏览文件 @
5721d74b
...
...
@@ -15,7 +15,7 @@ type TypeScriptIdentListener struct {
dataStructures
[]
core_domain
.
CodeDataStruct
dataStructQueue
[]
core_domain
.
CodeDataStruct
filePath
string
codeFile
core_domain
.
Code
File
codeFile
core_domain
.
Code
Container
parser
.
BaseTypeScriptParserListener
}
...
...
@@ -26,7 +26,7 @@ func NewTypeScriptIdentListener(fileName string) *TypeScriptIdentListener {
return
listener
}
func
(
s
*
TypeScriptIdentListener
)
GetNodeInfo
()
core_domain
.
Code
File
{
func
(
s
*
TypeScriptIdentListener
)
GetNodeInfo
()
core_domain
.
Code
Container
{
isScriptCalls
:=
s
.
currentDataStruct
!=
nil
&&
s
.
currentDataStruct
.
IsNotEmpty
()
if
isScriptCalls
{
if
len
(
s
.
currentDataStruct
.
Functions
)
<
1
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录