Documentation
¶
Index ¶
- func EndsWithReturn(stmts []ast.Stmt) bool
- func FindLoopStmt(stack []ast.Node, branch *ast.BranchStmt, typeInfo *types.Info) ast.Stmt
- func FuncKey(d *ast.FuncDecl) string
- func FuncReceiverKey(d *ast.FuncDecl) string
- func HasDirectivePrefix(file *ast.File, prefix string) bool
- func ImportName(spec *ast.ImportSpec) string
- func ImportsUnsafe(file *ast.File) bool
- func IsTypeExpr(expr ast.Expr, info *types.Info) bool
- func KeepOriginal(d *ast.FuncDecl) bool
- func NewIdent(name string, t types.Type, info *types.Info, pkg *types.Package) *ast.Ident
- func OverrideSignature(d *ast.FuncDecl) bool
- func Purge(d ast.Node) bool
- func RemoveParens(e ast.Expr) ast.Expr
- func SetType(info *types.Info, t types.Type, e ast.Expr) ast.Expr
- func Squeeze[E ast.Node, S ~[]E](s S) S
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EndsWithReturn ¶ added in v1.17.2
EndsWithReturn returns true if the last effective statement is a "return".
func FindLoopStmt ¶ added in v1.17.2
FindLoopStmt tries to find the loop statement among the AST nodes in the |stack| that corresponds to the break/continue statement represented by branch.
This function is label-aware and assumes the code was successfully type-checked.
func FuncKey ¶ added in v1.17.2
FuncKey returns a string, which uniquely identifies a top-level function or method in a package.
func FuncReceiverKey ¶
FuncReceiverKey returns a string that uniquely identifies the receiver struct of the function or an empty string if there is no receiver. This name will match the name of the struct in the struct's type spec.
func HasDirectivePrefix ¶
HasDirectivePrefix determines if any line in the given file has the given directive prefix in it.
func ImportName ¶
func ImportName(spec *ast.ImportSpec) string
ImportName tries to determine the package name for an import.
If the package name isn't specified then this will make a best make a best guess using the import path. If the import name is dot (`.`), blank (`_`), or there was an issue determining the package name then empty is returned.
func ImportsUnsafe ¶ added in v1.17.2
func KeepOriginal ¶
KeepOriginal returns true if gopherjs:keep-original directive is present before a function decl.
`//gopherjs:keep-original` is a GopherJS-specific directive, which can be applied to functions in native overlays and will instruct the augmentation logic to expose the original function such that it can be called. For a function in the original called `foo`, it will be accessible by the name `_gopherjs_original_foo`.
func OverrideSignature ¶
OverrideSignature returns true if gopherjs:override-signature directive is present on a function.
`//gopherjs:override-signature` is a GopherJS-specific directive, which can be applied in native overlays and will instruct the augmentation logic to replace the original function signature which has the same FuncKey with the signature defined in the native overlays. This directive can be used to remove generics from a function signature or to replace a receiver of a function with another one. The given native overlay function will be removed, so no method body is needed in the overlay.
The new signature may not contain types which require a new import since the imports will not be automatically added when needed, only removed. Use a type alias in the overlay to deal manage imports.
func Purge ¶
Purge returns true if gopherjs:purge directive is present on a struct, interface, type, variable, constant, or function.
`//gopherjs:purge` is a GopherJS-specific directive, which can be applied in native overlays and will instruct the augmentation logic to delete part of the standard library without a replacement. This directive can be used to remove code that would be invalid in GopherJS, such as code using unsupported features (e.g. generic interfaces before generics were fully supported). It should be used with caution since it may remove needed dependencies. If a type is purged, all methods using that type as a receiver will also be purged.
Types ¶
This section is empty.