From dc1671870dae5539fd107d57bd1a0872f2da414b Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Fri, 17 Jan 2020 09:41:40 +0800 Subject: [PATCH] refactor: [one-bs] move jparam -> code param --- pkg/domain/bs_domain/bs_node.go | 7 +------ pkg/infrastructure/ast/bs/bad_smell_listener.go | 8 ++++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/pkg/domain/bs_domain/bs_node.go b/pkg/domain/bs_domain/bs_node.go index b0aa399..1d07b5b 100644 --- a/pkg/domain/bs_domain/bs_node.go +++ b/pkg/domain/bs_domain/bs_node.go @@ -30,7 +30,7 @@ type BsJMethod struct { Type string MethodBody string Modifier string - Parameters []JFullParameter + Parameters []core_domain.CodeProperty MethodBs MethodBadSmellInfo Position core_domain.CodePosition } @@ -66,11 +66,6 @@ type ClassBadSmellInfo struct { PublicVarSize int } -type JFullParameter struct { - Name string - Type string -} - func NewJFullClassNode() BsJClass { info := &ClassBadSmellInfo{0, 0} return BsJClass{ diff --git a/pkg/infrastructure/ast/bs/bad_smell_listener.go b/pkg/infrastructure/ast/bs/bad_smell_listener.go index 9ff5cad..d5a1549 100644 --- a/pkg/infrastructure/ast/bs/bad_smell_listener.go +++ b/pkg/infrastructure/ast/bs/bad_smell_listener.go @@ -115,7 +115,7 @@ func (s *BadSmellListener) EnterInterfaceMethodDeclaration(ctx *InterfaceMethodD typeType := ctx.TypeTypeOrVoid().GetText() - var methodParams []bs_domain.JFullParameter = nil + var methodParams []core_domain.CodeProperty = nil parameters := ctx.FormalParameters() if parameters != nil { if reflect.TypeOf(parameters.GetChild(1)).String() == "*parser.FormalParameterListContext" { @@ -125,7 +125,7 @@ func (s *BadSmellListener) EnterInterfaceMethodDeclaration(ctx *InterfaceMethodD paramContext := param.(*FormalParameterContext) paramType := paramContext.TypeType().GetText() paramValue := paramContext.VariableDeclaratorId().(*VariableDeclaratorIdContext).IDENTIFIER().GetText() - methodParams = append(methodParams, bs_domain.JFullParameter{Name: paramType, Type: paramValue}) + methodParams = append(methodParams, core_domain.CodeProperty{TypeValue: paramType, TypeType: paramValue}) } } } @@ -184,7 +184,7 @@ func (s *BadSmellListener) EnterMethodDeclaration(ctx *MethodDeclarationContext) typeType := ctx.TypeTypeOrVoid().GetText() methodBody := ctx.MethodBody().GetText() - var methodParams []bs_domain.JFullParameter = nil + var methodParams []core_domain.CodeProperty = nil parameters := ctx.FormalParameters() if parameters != nil { if reflect.TypeOf(parameters.GetChild(1)).String() == "*parser.FormalParameterListContext" { @@ -194,7 +194,7 @@ func (s *BadSmellListener) EnterMethodDeclaration(ctx *MethodDeclarationContext) paramContext := param.(*FormalParameterContext) paramType := paramContext.TypeType().GetText() paramValue := paramContext.VariableDeclaratorId().(*VariableDeclaratorIdContext).IDENTIFIER().GetText() - methodParams = append(methodParams, bs_domain.JFullParameter{Name: paramType, Type: paramValue}) + methodParams = append(methodParams, core_domain.CodeProperty{TypeValue: paramType, TypeType: paramValue}) localVars[paramValue] = paramType } -- GitLab