Documentation ¶
Index ¶
- type ReferenceKind
- type ReferenceMap
- func (r *ReferenceMap) AddImport(file *dst.File, path string, alias string) bool
- func (r *ReferenceMap) AddLink(file *dst.File, path string) bool
- func (r *ReferenceMap) AddSyntheticImports(file *dst.File) bool
- func (r *ReferenceMap) Count() int
- func (r *ReferenceMap) Map() map[string]ReferenceKind
- func (r *ReferenceMap) Merge(other ReferenceMap)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ReferenceKind ¶
type ReferenceKind bool
ReferenceKind denotes the style of a reference, which influences compilation and linking requirements.
const ( // ImportStatement references must be made available to the compiler via the provided `importcfg`. ImportStatement ReferenceKind = true // RelocationTarget references must be made available to the linker, and must be referenced (directly or not) by the main package. RelocationTarget ReferenceKind = false )
func (ReferenceKind) String ¶
func (k ReferenceKind) String() string
type ReferenceMap ¶
type ReferenceMap struct {
// contains filtered or unexported fields
}
ReferenceMap associates import paths to ReferenceKind values.
func (*ReferenceMap) AddImport ¶
AddImport determines whether a new import declaration needs to be added to make the provided path available within the specified file. Returns true if that is the case. False if the import path is already available within the file.
func (*ReferenceMap) AddLink ¶
func (r *ReferenceMap) AddLink(file *dst.File, path string) bool
AddLink registers the provided path as a relocation target resolution source. If this path is already registered as an import, this method does nothing and returns false.
func (*ReferenceMap) AddSyntheticImports ¶
func (r *ReferenceMap) AddSyntheticImports(file *dst.File) bool
AddSyntheticImports adds the registered imports to the provided *dst.File. This is not safe to call during an AST traversal by dstutil.Apply, as this may offset the declaration list by 1 in case a new import declaration needs to be added, which would result in re-traversing current declaration when the cursor moves forward. Instead, it is advise to call this method after dstutil.Apply has returned.
func (*ReferenceMap) Count ¶
func (r *ReferenceMap) Count() int
func (*ReferenceMap) Map ¶
func (r *ReferenceMap) Map() map[string]ReferenceKind
func (*ReferenceMap) Merge ¶
func (r *ReferenceMap) Merge(other ReferenceMap)