Documentation ¶
Overview ¶
imports defines an import manager that manages ident-to-imports relation. It is supposed to be used to add imports to existent files while keeping their existent imports.
Index ¶
- type Import
- type ImportMap
- func (im ImportMap) AddMissingImports(df *dst.File)
- func (im ImportMap) AstExpr(ty TargetType) *ast.SelectorExpr
- func (im ImportMap) DstExpr(ty TargetType) *dst.SelectorExpr
- func (im *ImportMap) Ident(path string) (string, bool)
- func (im ImportMap) MissingImports() iter.Seq2[string, string]
- func (im ImportMap) Qualifier(currentPkgPath string) types.Qualifier
- type ImportParser
- type TargetImport
- type TargetImports
- type TargetType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ImportMap ¶
type ImportMap struct {
// contains filtered or unexported fields
}
func (ImportMap) AddMissingImports ¶
AddMissingImports adds missing imports from imports to df, both *dst.File.Imports and the first import decl in *dst.File.Decls.
func (ImportMap) AstExpr ¶
func (im ImportMap) AstExpr(ty TargetType) *ast.SelectorExpr
func (ImportMap) DstExpr ¶
func (im ImportMap) DstExpr(ty TargetType) *dst.SelectorExpr
type ImportParser ¶
type ImportParser struct {
// contains filtered or unexported fields
}
func NewParser ¶
func NewParser(pkg *types.Package) *ImportParser
func NewParserPackages ¶
func NewParserPackages(pkgs []*packages.Package) *ImportParser
func (*ImportParser) AppendExtra ¶
func (p *ImportParser) AppendExtra(imports ...TargetImport)
func (*ImportParser) Parse ¶
func (p *ImportParser) Parse(importSpecs []*ast.ImportSpec) (ImportMap, error)
type TargetImport ¶
type TargetImports ¶
type TargetImports map[string]TargetImport
func (TargetImports) Append ¶
func (ti TargetImports) Append(imports ...TargetImport)
type TargetType ¶
Click to show internal directories.
Click to hide internal directories.