names

package
Version: v0.0.0-...-8433dcb Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2020 License: BSD-3-Clause Imports: 8 Imported by: 1

Documentation

Overview

Package names provides functions to analyze the usage names (functions, types, variables, etc.) across multiple files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindConflict

func FindConflict(obj types.Object, name string) types.Object

FindConflict determines if there already exists an identifier with the given newName such that the given ident cannot be renamed to name. It returns one such conflicting declaration, if possible, and nil if there are none.

func FindDeclarationsAcrossInterfaces

func FindDeclarationsAcrossInterfaces(obj types.Object, program *loader.Program) map[types.Object]bool

FindDeclarationsAcrossInterfaces finds all objects that might need to be renamed if the given identifier is renamed. In the case of a method, there may be indirect relationships such as the following:

 Interface1  Interface2
    /  \      /  \
   /  implements  \
  /      \   /     \
Type1    Type2    Type3

where renaming a method in Type1 could force a method with the same signature to be renamed in Interface1, Interface2, Type2, and Type3. This method returns a set containing the reflexive, transitive closure of objects that must be renamed if the given identifier is renamed.

func FindEmbeddedTypes

func FindEmbeddedTypes(obj types.Object, program *loader.Program) map[types.Object]bool

FindEmbeddedTypes finds each use of the given Object's type as an embedded type and returns a set consisting of the given Object and all uses in embedded types.

func FindInComments

func FindInComments(name string, f *ast.File, scope *types.Scope, fset *token.FileSet) []*text.Extent

FindInComments searches the comments of the given packages' source files for occurrences of the given name (as a word, not a subword) and returns their source locations. Position information is obtained from the given FileSet.

func FindOccurrences

func FindOccurrences(obj types.Object, prog *loader.Program) map[*ast.Ident]bool

FindOccurrences receives an Object and returns the set of all identifiers that refer to that Object.

Note that this method cannot be used to find occurrences of package names or variables defined by type switch statements; those must be handled using different methods in this package.

func FindTypeSwitchVarOccurrences

func FindTypeSwitchVarOccurrences(typeSwitch *ast.TypeSwitchStmt, pkgInfo *loader.PackageInfo, program *loader.Program) map[*ast.Ident]bool

FindTypeSwitchVarOccurrences returns the set of all identifiers that refer to the variable defined in the type switch statement.

Types

This section is empty.

Jump to

Keyboard shortcuts

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