prefixer

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const Slice = "[]"

Slice represents the token for a go slice prefix.

View Source
const Star = "*"

Star represents the pointer prefix.

Variables

This section is empty.

Functions

This section is empty.

Types

type Prefixer

type Prefixer interface {
	// Valid validates the prefixer and its subprefixers.
	//
	// An example would be a composition of a StarExpr with an ArrayType of an Ident.
	// In that case, all three prefixers computed from those ast.Expr will be validated with Valid.
	Valid() error

	// ToString transforms a Prefixer (ast.Expr) into its string representation.
	// It also returns a boolean indicating whether the type is exported.
	ToString(sourcePackage string, typeParams []string, prefixes ...string) (stringType string, exported bool)
}

Prefixer represents an interface to transform a specific ast.Expr into its string representation.

func NewPrefixer

func NewPrefixer(input ast.Expr) Prefixer

NewPrefixer transforms the input expression into it's corresponding Prefixer interface.

It returns an error if the input expression hasn't a Prefixer implementation.

func NewPrefixerEditor

func NewPrefixerEditor(prefixer Prefixer, editor editor) Prefixer

NewPrefixerEditor creates a Prefixer wrapping another Prefixer.

It can be used to alter the result of the wrapped Prefixer to add like a name, edit the exported bool result or even remove, replace, or change the resulted string type.

Jump to

Keyboard shortcuts

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