refactor: remove jparameter

上级 c593b191
......@@ -24,24 +24,24 @@
"StopLinePosition": 40,
"Parameters": [
{
"Name": "String",
"Type": "firstname"
"TypeType": "String",
"TypeName": "firstname"
},
{
"Name": "String",
"Type": "lastname"
"TypeType": "String",
"TypeName": "lastname"
},
{
"Name": "String",
"Type": "address"
"TypeType": "String",
"TypeName": "address"
},
{
"Name": "String",
"Type": "age"
"TypeType": "String",
"TypeName": "age"
},
{
"Name": "String",
"Type": "id"
"TypeType": "String",
"TypeName": "id"
}
],
"MethodCalls": [],
......@@ -50,7 +50,6 @@
}
],
"MethodCalls": [
],
"Extend": "",
"Implements": [
......@@ -82,24 +81,24 @@
"StopLinePosition": 40,
"Parameters": [
{
"Name": "String",
"Type": "name"
"TypeType": "String",
"TypeName": "name"
},
{
"Name": "String",
"Type": "firstname"
"TypeType": "String",
"TypeName": "firstname"
},
{
"Name": "String",
"Type": "lastname"
"TypeType": "String",
"TypeName": "lastname"
},
{
"Name": "String",
"Type": "address"
"TypeType": "String",
"TypeName": "address"
},
{
"Name": "String",
"Type": "age"
"TypeType": "String",
"TypeName": "age"
}
],
"MethodCalls": [],
......@@ -136,7 +135,7 @@
"StopLinePosition": 40,
"Parameters": [
{
"Name": "String",
"TypeType": "String",
"Type": "age"
}
],
......
......@@ -24,17 +24,17 @@ func (s Service) EvaluateList(evaluateModel *EvaluateModel, nodes []jdomain.JCla
}
evaluateModel.ServiceSummary.ReturnTypeMap = returnTypeMap
findRelatedMethodParameter(evaluateModel, longParameterList)
findRelatedMethodParameters(evaluateModel, longParameterList)
}
func findRelatedMethodParameter(model *EvaluateModel, list []jdomain.JMethod) {
func findRelatedMethodParameters(model *EvaluateModel, list []jdomain.JMethod) {
var dataset [][]string
for _, method := range list {
var methodlist []string
var paramTypeList []string
for _, param := range method.Parameters {
methodlist = append(methodlist, param.Type)
paramTypeList = append(paramTypeList, param.TypeName)
}
dataset = append(dataset, methodlist)
dataset = append(dataset, paramTypeList)
}
var newOptions = apriori.NewOptions(0.8, 0.8, 0, 0)
......
......@@ -8,3 +8,11 @@ type CodeProperty struct {
ReturnTypes []CodeProperty
Parameters []CodeProperty
}
func NewCodeParameter(typeName string, typeType string) CodeProperty {
return CodeProperty{
TypeName: typeName,
TypeType: typeType,
}
}
package jdomain
import (
"github.com/phodal/coca/pkg/domain/core_domain"
"github.com/phodal/coca/pkg/infrastructure/string_helper"
"strings"
)
......@@ -12,7 +13,7 @@ type JMethod struct {
StartLinePosition int
StopLine int
StopLinePosition int
Parameters []JParameter
Parameters []core_domain.CodeProperty
MethodCalls []JMethodCall
Override bool
Annotations []Annotation
......@@ -29,7 +30,7 @@ func NewJMethod() JMethod {
type JMethodInfo struct {
Name string
Type string
Parameters []JParameter
Parameters []core_domain.CodeProperty
Length string
}
......
package jdomain
type JParameter struct {
Name string
Type string
}
......@@ -2,12 +2,13 @@ package full
import (
"github.com/phodal/coca/languages/java"
"github.com/phodal/coca/pkg/domain/core_domain"
"github.com/phodal/coca/pkg/domain/jdomain"
"strings"
)
func BuildMethodParameters(parameters parser.IFormalParametersContext) []jdomain.JParameter {
var methodParams []jdomain.JParameter = nil
func BuildMethodParameters(parameters parser.IFormalParametersContext) []core_domain.CodeProperty {
var methodParams []core_domain.CodeProperty = nil
parameterList := parameters.GetChild(1).(*parser.FormalParameterListContext)
formalParameter := parameterList.AllFormalParameter()
for _, param := range formalParameter {
......@@ -16,7 +17,8 @@ func BuildMethodParameters(parameters parser.IFormalParametersContext) []jdomain
paramValue := paramContext.VariableDeclaratorId().(*parser.VariableDeclaratorIdContext).IDENTIFIER().GetText()
localVars[paramValue] = paramType
methodParams = append(methodParams, jdomain.JParameter{Name: paramValue, Type: paramType})
parameter := core_domain.NewCodeParameter(paramValue, paramType)
methodParams = append(methodParams, parameter)
}
return methodParams
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册