parsermodel

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

  • Copyright 2022 ByteDance Inc. *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

This file may have been modified by Bytedance Ltd. and/or its affiliates (“Bytedance's Modifications”). All Bytedance's Modifications are Copyright (2022) Bytedance Ltd. and/or its affiliates.

This file may have been modified by Bytedance Ltd. and/or its affiliates (“Bytedance's Modifications”). All Bytedance's Modifications are Copyright (2022) Bytedance Ltd. and/or its affiliates.

  • Copyright 2022 ByteDance Inc. *

  • Licensed under the Apache License, Version 2.0 (the "License");

  • you may not use this file except in compliance with the License.

  • You may obtain a copy of the License at *

  • http://www.apache.org/licenses/LICENSE-2.0 *

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an "AS IS" BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  • See the License for the specific language governing permissions and

  • limitations under the License.

  • Copyright 2022 ByteDance Inc. *

  • Licensed under the Apache License, Version 2.0 (the "License");

  • you may not use this file except in compliance with the License.

  • You may obtain a copy of the License at *

  • http://www.apache.org/licenses/LICENSE-2.0 *

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an "AS IS" BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  • See the License for the specific language governing permissions and

  • limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRandValueByType

func GetRandValueByType(typeValue string, isStars ...bool) string

func MakeTimeStampMs

func MakeTimeStampMs(t time.Time) int64

time 2 10位时间戳

func RandChoice

func RandChoice(choices ...string) string

func RandomString

func RandomString(n int, allowedChars ...[]rune) string

func ToStr

func ToStr(i interface{}) string

Types

type CallGraph

type CallGraph struct {
	RootFunc          *FuncDesc
	CallerRelationMap map[string]*CallerRelation
}

type CalledRelation

type CalledRelation struct {
	Callees []FuncDesc
	CanFix  bool //该调用关系能反向找到gin.Context即可以自动修复
}

描述关键函数的一条反向调用关系

type CallerRelation

type CallerRelation struct {
	Caller  FuncDesc
	Callees []FuncDesc
}

描述一个函数调用N个函数的一对多关系

type Expression

type Expression struct {
	Value         string //没有[]以及*的类型
	PkgPath       string // 如果map结构,那么PkgPath表示的是key的包路径
	PkgName       string
	IsStar        bool //是否指针
	IsStruct      bool
	IsVariadic    bool //是否...模拟数组的形式
	IsWriter      bool
	Underlying    string //golang类型
	ExtraPkgPaths []string
	IsSignature   bool
}

func (*Expression) String

func (e *Expression) String() string

func (*Expression) ToString

func (e *Expression) ToString(rootPath string) string

type Field

type Field struct {
	Name   string
	Type   *Expression
	Index  int
	Fields []*Field
}

func (*Field) GetImports

func (f *Field) GetImports(importsMap map[string]string)

func (*Field) GetRandValue

func (f *Field) GetRandValue(rootPath string) (res string)

func (*Field) GetStructFieldRandValue

func (f *Field) GetStructFieldRandValue(rootPath string) (res string)

func (*Field) InitiateReceiver

func (f *Field) InitiateReceiver() string

func (*Field) InitiateReceiverForMock

func (f *Field) InitiateReceiverForMock() string

func (*Field) InitiateStruct

func (f *Field) InitiateStruct() string

func (*Field) InitiateVariable

func (f *Field) InitiateVariable() string

InitiateVariable used for gotype dynamic transformation

func (*Field) IsBasicType

func (f *Field) IsBasicType() bool

func (*Field) IsInterface

func (f *Field) IsInterface() bool

func (*Field) IsList

func (f *Field) IsList() bool

func (*Field) IsMap

func (f *Field) IsMap() bool

func (*Field) IsNamed

func (f *Field) IsNamed() bool

func (*Field) IsStar

func (f *Field) IsStar() bool

func (*Field) IsStruct

func (f *Field) IsStruct() bool

func (*Field) IsWriter

func (f *Field) IsWriter() bool

func (*Field) ShortName

func (f *Field) ShortName() string

func (*Field) ToString

func (f *Field) ToString(rootPath string) string

func (*Field) ToStringForInitialVariable

func (f *Field) ToStringForInitialVariable() string

ToStringForInitialVariable only used for the signature

func (*Field) ToStringForStruct

func (f *Field) ToStringForStruct() string

type FuncDesc

type FuncDesc struct {
	File    string //文件路径
	Path    string //文件路径
	Package string //package名
	Name    string //函数名,格式为Package.Func
}

函数定义

type Function

type Function struct {
	RootFunc     *Function
	PkgPath      string
	PkgName      string
	Name         string
	IsExported   bool
	Receiver     *Field
	Parameters   []*Field
	Results      []*Field
	ReturnsError bool
	NeedRandCase bool
	// contains filtered or unexported fields
}

func (*Function) GetImports

func (f *Function) GetImports() []string

func (*Function) GetReceiverString

func (f *Function) GetReceiverString() string

func (*Function) GetResult

func (f *Function) GetResult(sb *util.StringBuilder)

func (*Function) IsNaked

func (f *Function) IsNaked() bool

func (*Function) MethodName

func (f *Function) MethodName() string

func (*Function) MockFunc

func (f *Function) MockFunc() string

TODO: 这里要改掉.

func (*Function) OnlyReturnsError

func (f *Function) OnlyReturnsError() bool

func (*Function) OnlyReturnsOneValue

func (f *Function) OnlyReturnsOneValue() bool

func (*Function) ReturnsMultiple

func (f *Function) ReturnsMultiple() bool

func (*Function) RootPath

func (f *Function) RootPath() string

type Imethod

type Imethod struct {
	I  *types.Interface
	Id string
}

type MWTNode

type MWTNode struct {
	Key      string
	Value    FuncDesc
	N        int
	Children []*MWTNode
}

type Options

type Options struct {
	OnlyFuncs  string
	GraphLevel int
}

type ProjectFunction

type ProjectFunction struct {
	ModuleName string

	Function *ssa.Function
	Program  *ProjectProgram

	CalleeFunctionsForTargetFunction map[string]*ssa.Function
	PackageConstants                 []types.Object
}

type ProjectProgram

type ProjectProgram struct {
	PkgPath       string
	PkgName       string
	Prog          *ssa.Program
	Pkgs          []*ssa.Package
	AllFuncs      map[*ssa.Function]bool
	MethodsByName map[string][]*ssa.Function
	MethodsMemo   map[Imethod][]*ssa.Function
}

func (*ProjectProgram) LookupMethods

func (prog *ProjectProgram) LookupMethods(I *types.Interface, m *types.Func) []*ssa.Function

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL