params

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UniqueName

func UniqueName(originalName string, ls ...interface{ Names() []string }) string

UniqueName returns originalName modified in such a way that it is different from all the names in the provided parameter lists.

Types

type ConstructorParam

type ConstructorParam struct {
	FunctionParam
	// contains filtered or unexported fields
}

ConstructorParam represents a parameter in a constructor of a message.

func (ConstructorParam) Field

func (p ConstructorParam) Field() *types.Field

Field returns the field associated with the constructor parameter.

type ConstructorParamList

type ConstructorParamList struct {
	// contains filtered or unexported fields
}

ConstructorParamList represents a list of parameters of a constructor function of a message.

func (ConstructorParamList) Adapt

func (l ConstructorParamList) Adapt(others ...interface{ Names() []string }) ConstructorParamList

Adapt returns a new list that has no name collisions with any of the parameter in any of the provided lists.

func (ConstructorParamList) Append

Append adds a parameter to the list, making sure that all parameters have unique names.

func (ConstructorParamList) AppendAll

AppendAll adds all parameters to the list, making sure that all parameters have unique names.

func (ConstructorParamList) FindParamByField

func (l ConstructorParamList) FindParamByField(field *types.Field) (ConstructorParam, bool)

FindParamByField returns the parameter corresponding to the given field.

func (ConstructorParamList) FunctionParamList

func (l ConstructorParamList) FunctionParamList() FunctionParamList

FunctionParamList transforms ConstructorParamList to FunctionParamList.

func (ConstructorParamList) IDs

func (l ConstructorParamList) IDs() []jen.Code

IDs returns the slice of the names of the parameters as jen.Code.

func (ConstructorParamList) IndexOf

func (l ConstructorParamList) IndexOf(param ConstructorParam) int

IndexOf returns the index of the parameter with the given name. If the parameter is not in the list, it returns -1.

func (ConstructorParamList) IndexOfField

func (l ConstructorParamList) IndexOfField(field *types.Field) int

IndexOfField returns the index of the parameter with the given field. If there is no such parameter in the list, it returns -1.

func (ConstructorParamList) MirCode

func (l ConstructorParamList) MirCode() []jen.Code

MirCode returns the slice of function parameters as a jen.Code list to be used in a function declaration.

func (ConstructorParamList) Names

func (l ConstructorParamList) Names() []string

Names returns the slice of the names of the parameters as string.

func (ConstructorParamList) Remove

Remove returns a new ConstructorParamList without the parameter with the given index. The names of the other parameters are not changed.

func (ConstructorParamList) RemoveParam

func (l ConstructorParamList) RemoveParam(param ConstructorParam) (res ConstructorParamList, found bool)

RemoveParam returns a new ConstructorParamList with the given parameter removed. The names of the other parameters are not changed. If the parameter is not in the list, it returns the original list. The second return value is true if the parameter was in the list.

func (ConstructorParamList) Slice

Slice returns the underlying slice corresponding to the list.

func (ConstructorParamList) Sublist

func (l ConstructorParamList) Sublist(first, afterLast int) ConstructorParamList

Sublist returns a ConstructorParamList corresponding to a slice of the original list.

func (ConstructorParamList) UncheckedAppend

func (l ConstructorParamList) UncheckedAppend(originalName, uniqueName string, field *types.Field) ConstructorParamList

UncheckedAppend returns a new FunctionParamList with an item appended to it. uniqueName must be different from all the parameters already in the list.

func (ConstructorParamList) UncheckedAppendAll

UncheckedAppendAll adds all parameters to the list. It is assumed that the names of the parameters being added are different from each other and all the parameters already in the list.

type FunctionParam

type FunctionParam struct {
	// contains filtered or unexported fields
}

FunctionParam represents a parameter of a function.

func (FunctionParam) MirCode

func (p FunctionParam) MirCode() jen.Code

MirCode returns the code for the parameter that can be used in a function declaration using Mir-generated

func (FunctionParam) Name

func (p FunctionParam) Name() string

Name returns the name of the function parameter after it has been made unique.

func (FunctionParam) OriginalName

func (p FunctionParam) OriginalName() string

OriginalName return the original name of the function parameter.

func (FunctionParam) Type

func (p FunctionParam) Type() types.Type

Type returns the type of the function parameter.

type FunctionParamList

type FunctionParamList struct {
	// contains filtered or unexported fields
}

FunctionParamList represents a list of parameters of a function.

func FunctionParamListOf

func FunctionParamListOf(params ...FunctionParam) FunctionParamList

FunctionParamListOf returns a FunctionParamList containing the given parameters.

func (FunctionParamList) Adapt

func (l FunctionParamList) Adapt(others ...interface{ Names() []string }) FunctionParamList

Adapt returns a new list that has no name collisions with any of the parameter in any of the provided lists.

func (FunctionParamList) Append

Append returns a new FunctionParamList with an item appended to it. If a parameter with the same name is already in the list, it will change the name to make it unique.

func (FunctionParamList) AppendAll

AppendAll adds all parameters to the list, making sure that all parameters have unique names.

func (FunctionParamList) IDs

func (l FunctionParamList) IDs() []jen.Code

IDs returns the slice of the names of the parameters as jen.Code.

func (FunctionParamList) IndexOf

func (l FunctionParamList) IndexOf(param FunctionParam) int

IndexOf returns the index of the parameter with the given name. If the parameter is not in the list, it returns -1.

func (FunctionParamList) MirCode

func (l FunctionParamList) MirCode() []jen.Code

MirCode returns the slice of function parameters as a jen.Code list to be used in a function declaration.

func (FunctionParamList) Names

func (l FunctionParamList) Names() []string

Names returns the slice of the names of the parameters as string.

func (FunctionParamList) Remove

func (l FunctionParamList) Remove(idx int) FunctionParamList

Remove returns a new FunctionParamList without the parameter with the given index. The names of the other parameters are not changed.

func (FunctionParamList) RemoveParam

func (l FunctionParamList) RemoveParam(param FunctionParam) (res FunctionParamList, found bool)

RemoveParam returns a new ConstructorParamList with the given parameter removed. The names of the other parameters are not changed. If the parameter is not in the list, it returns the original list. The second return value is true if the parameter was in the list.

func (FunctionParamList) Slice

func (l FunctionParamList) Slice() []FunctionParam

Slice returns the underlying slice corresponding to the list.

func (FunctionParamList) Sublist

func (l FunctionParamList) Sublist(first, afterLast int) FunctionParamList

Sublist returns a FunctionParamList corresponding to a slice of the original list.

func (FunctionParamList) UncheckedAppend

func (l FunctionParamList) UncheckedAppend(originalName, uniqueName string, tp types.Type) FunctionParamList

UncheckedAppend returns a new FunctionParamList with an item appended to it. uniqueName must be different from all the parameters already in the list.

func (FunctionParamList) UncheckedAppendAll

func (l FunctionParamList) UncheckedAppendAll(other FunctionParamList) FunctionParamList

UncheckedAppendAll adds all parameters to the list. It is assumed that the names of the parameters being added are different from each other and all the parameters already in the list.

Jump to

Keyboard shortcuts

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