packages

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Overview

Package packages provides utility functions to statically analyze Gno MemPackages

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileImport

type FileImport struct {
	PkgPath string
	Spec    *ast.ImportSpec
}

FileImport represents an import

func FileImports

func FileImports(filename string, src string, fset *token.FileSet) ([]FileImport, error)

FileImports returns the list of gno imports in the given file src. The given filename is only used when recording position information.

type FileKind

type FileKind uint

FileKind represent the category a gno source file falls in, can be one of:

- FileKindPackageSource -> A *.gno file that will be included in the gnovm package

- FileKindTest -> A *_test.gno file that will be used for testing

- FileKindXTest -> A *_test.gno file with a package name ending in _test that will be used for blackbox testing

- FileKindFiletest -> A *_filetest.gno file that will be used for snapshot testing

const (
	FileKindUnknown FileKind = iota
	FileKindPackageSource
	FileKindTest
	FileKindXTest
	FileKindFiletest
)

func GetFileKind

func GetFileKind(filename string, body string, fset *token.FileSet) (FileKind, error)

GetFileKind analyzes a file's name and body to get it's FileKind, fset is optional

type ImportsMap

type ImportsMap map[FileKind][]FileImport

func Imports

func Imports(pkg *gnovm.MemPackage, fset *token.FileSet) (ImportsMap, error)

Imports returns the list of gno imports from a gnovm.MemPackage. fset is optional.

func (ImportsMap) Merge

func (imap ImportsMap) Merge(kinds ...FileKind) []FileImport

Merge merges imports, it removes duplicates and sorts the result

Jump to

Keyboard shortcuts

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