gimps

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SetStd      = "std"
	SetProject  = "project"
	SetExternal = "external"
)

Variables

This section is empty.

Functions

func Execute

func Execute(config *Config, filePath string, aliaser *Aliaser) ([]byte, bool, error)

Execute is for revise imports and format the code

Types

type AliasRule added in v0.4.0

type AliasRule struct {
	Name       string `yaml:"name"`
	Expression string `yaml:"expr"`

	Alias string `yaml:"alias"`
	// contains filtered or unexported fields
}

type Aliaser added in v0.4.0

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

func NewAliaser added in v0.4.0

func NewAliaser(projectName string, rules []AliasRule) (*Aliaser, error)

func (*Aliaser) RewriteFile added in v0.4.0

func (a *Aliaser) RewriteFile(file *ast.File, filePath string, imports map[string]*importMetadata) error

type Classifier added in v0.4.0

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

func NewClassifier added in v0.4.0

func NewClassifier(projectName string, sets []Set) *Classifier

func (*Classifier) ClassifyImport added in v0.4.0

func (c *Classifier) ClassifyImport(pkg string) string

func (*Classifier) IsProjectImport added in v0.4.0

func (c *Classifier) IsProjectImport(pkg string) bool

type Config

type Config struct {
	ProjectName string      `yaml:"projectName"`
	ImportOrder []string    `yaml:"importOrder"`
	Sets        []Set       `yaml:"sets"`
	AliasRules  []AliasRule `yaml:"aliasRules"`
}

type DependencyCache added in v0.4.0

type DependencyCache map[string]astutil.PackageImports

DependencyCache holds a list of package names per build tags (i.e. the key is the build tags string, like "windows prod").

func NewDependencyCache added in v0.4.0

func NewDependencyCache() DependencyCache

func (DependencyCache) GetPackageName added in v0.4.0

func (c DependencyCache) GetPackageName(filePath string, buildTags string, packagePath string) (string, error)

type GimpsString added in v0.4.0

type GimpsString string

type Set

type Set struct {
	Name     string   `yaml:"name"`
	Patterns []string `yaml:"patterns"`
}

Jump to

Keyboard shortcuts

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