godoctor: github.com/godoctor/godoctor/analysis/names Index | Files

package names

import "github.com/godoctor/godoctor/analysis/names"

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

Index

Package Files

comments.go conflict.go embeddedtypes.go methods.go objects.go typeswitch.go

func FindConflict Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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.

Package names imports 8 packages (graph) and is imported by 1 packages. Updated 2018-04-22. Refresh now. Tools for package owners.