feat: [ts] add fields for parameters

上级 d13ac41f
......@@ -191,5 +191,5 @@ func Test_ShouldGetClassFields(t *testing.T) {
results := app.Analysis(string(code))
g.Expect(len(results[1].Fields)).To(Equal(0))
g.Expect(len(results[1].Fields)).To(Equal(5))
}
......@@ -147,12 +147,25 @@ func handleClassBodyElements(classTailContext *parser.ClassTailContext) {
func handlePropertyMember(elementChild antlr.Tree) {
propertyMemberCtx := elementChild.(*parser.PropertyMemberDeclarationContext)
callSignaturePos := 3
if propertyMemberCtx.PropertyName() != nil {
field := domain.JAppField{
Type: "",
Value: "",
}
field.Value = propertyMemberCtx.PropertyName().GetText()
if propertyMemberCtx.TypeAnnotation() != nil {
field.Type = BuildTypeAnnotation(propertyMemberCtx.TypeAnnotation().(*parser.TypeAnnotationContext))
}
currentNode.Fields = append(currentNode.Fields, field)
}
if propertyMemberCtx.GetChildCount() >= callSignaturePos {
if reflect.TypeOf(propertyMemberCtx.GetChild(2)).String() == "*parser.CallSignatureContext" {
method := BuildMemberMethod(propertyMemberCtx)
currentNode.Methods = append(currentNode.Methods, method)
}
}
}
func (s *TypeScriptIdentListener) ExitClassDeclaration(ctx *parser.ClassDeclarationContext) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册