From 3f9b15d62a2b04bb643c566fe408062bd2c41525 Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Fri, 10 Jan 2020 17:33:13 +0800 Subject: [PATCH] refactor: change param to node --- trial/pkg/ast/typescript_ident_listener.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/trial/pkg/ast/typescript_ident_listener.go b/trial/pkg/ast/typescript_ident_listener.go index 6743b62..36d648a 100644 --- a/trial/pkg/ast/typescript_ident_listener.go +++ b/trial/pkg/ast/typescript_ident_listener.go @@ -139,31 +139,27 @@ func handleClassBodyElements(classTailContext *parser.ClassTailContext) { constructorDeclCtx := elementChild.(*parser.ConstructorDeclarationContext) currentNode.Methods = append(currentNode.Methods, BuildConstructorMethod(constructorDeclCtx)) case "*parser.PropertyMemberDeclarationContext": - handlePropertyMember(elementChild) + HandlePropertyMember(elementChild.(*parser.PropertyMemberDeclarationContext), currentNode) } } } -func handlePropertyMember(elementChild antlr.Tree) { - propertyMemberCtx := elementChild.(*parser.PropertyMemberDeclarationContext) +func HandlePropertyMember(propertyMemberCtx *parser.PropertyMemberDeclarationContext, node *domain.JClassNode) { callSignaturePos := 3 if propertyMemberCtx.PropertyName() != nil { - field := domain.JField{ - Type: "", - Value: "", - } + field := domain.JField{} field.Value = propertyMemberCtx.PropertyName().GetText() field.Modifier = propertyMemberCtx.PropertyMemberBase().GetText() if propertyMemberCtx.TypeAnnotation() != nil { field.Type = BuildTypeAnnotation(propertyMemberCtx.TypeAnnotation().(*parser.TypeAnnotationContext)) } - currentNode.Fields = append(currentNode.Fields, field) + node.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) + node.Methods = append(currentNode.Methods, method) } } -- GitLab