refactor: [ts] add basic code datasturct

上级 0bf4225d
......@@ -24,7 +24,7 @@ type JField struct {
}
func NewClassNode() *JClassNode {
return &JClassNode{"", "", "", "", nil, nil, nil, "", nil, nil, nil, nil}
return &JClassNode{}
}
func (j *JClassNode) IsUtilClass() bool {
......
package trial
type CodeDataStruct struct {
Name string
ID string
MemberIds []string
Extend string
Implements []string
Annotations interface{}
Properties []CodeProperty
Functions []CodeFunction
Extension interface{}
Name string
ID string
MemberIds []string
Extend string
Implements []string
Annotations interface{}
Properties []CodeProperty
Functions []CodeFunction
FunctionCalls []CodeCall
Extension interface{}
}
type JavaExtension struct {
......@@ -22,3 +23,11 @@ type PythonAnnotation struct {
Name string
Properties []CodeProperty
}
func NewDataStruct() *CodeDataStruct {
return &CodeDataStruct{}
}
func (d *CodeDataStruct) IsNotEmpty() bool {
return len(d.Functions) > 0 || len(d.FunctionCalls) > 0
}
......@@ -5,6 +5,7 @@
"Annotations": null,
"Extend": "",
"Extension": null,
"FunctionCalls": null,
"Functions": null,
"ID": "",
"Implements": null,
......@@ -43,6 +44,7 @@
"Annotations": null,
"Extend": "",
"Extension": null,
"FunctionCalls": null,
"Functions": null,
"ID": "",
"Implements": null,
......@@ -72,6 +74,7 @@
"Annotations": null,
"Extend": "",
"Extension": null,
"FunctionCalls": null,
"Functions": null,
"ID": "",
"Implements": null,
......
......@@ -5,6 +5,7 @@
"Annotations": null,
"Extend": "",
"Extension": null,
"FunctionCalls": null,
"Functions": null,
"ID": "",
"Implements": null,
......
......@@ -5,6 +5,7 @@
"Annotations": null,
"Extend": "",
"Extension": null,
"FunctionCalls": null,
"Functions": null,
"ID": "",
"Implements": null,
......
......@@ -5,6 +5,7 @@
"Annotations": null,
"Extend": "",
"Extension": null,
"FunctionCalls": null,
"Functions": null,
"ID": "",
"Implements": null,
......
......@@ -5,6 +5,7 @@
"Annotations": null,
"Extend": "",
"Extension": null,
"FunctionCalls": null,
"Functions": null,
"ID": "",
"Implements": null,
......
......@@ -12,6 +12,10 @@ var currentNode *domain.JClassNode
var classNodeQueue []domain.JClassNode
var classNodes []domain.JClassNode
var currentDataStruct *trial.CodeDataStruct
var dataStructures []trial.CodeDataStruct
var dataStructQueue []domain.JClassNode
var defaultClass = "default"
var filePath string
var codeFile trial.CodeFile
......@@ -24,10 +28,12 @@ func NewTypeScriptIdentListener(fileName string) *TypeScriptIdentListener {
classNodes = nil
filePath = fileName
currentNode = domain.NewClassNode()
currentDataStruct = trial.NewDataStruct()
codeFile = trial.CodeFile{
FullName: filePath,
Imports: nil,
ClassNodes: nil,
FullName: filePath,
Imports: nil,
ClassNodes: nil,
DataStructures: nil,
}
return &TypeScriptIdentListener{}
}
......@@ -39,7 +45,14 @@ func (s *TypeScriptIdentListener) GetNodeInfo() trial.CodeFile {
currentNode = domain.NewClassNode()
}
if currentDataStruct.IsNotEmpty() {
currentDataStruct.Name = defaultClass
dataStructures = append(dataStructures, *currentDataStruct)
currentDataStruct = trial.NewDataStruct()
}
codeFile.ClassNodes = classNodes
codeFile.DataStructures = dataStructures
return codeFile
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册