ident

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2019 License: MIT Imports: 6 Imported by: 4

README

ident Go Documentation Travis Go Report Card codecov

ident maps types.Object to *ast.Ident.

Usage

analyzer := &analysis.Analyzer{
	Requires: []*analysis.Analyzer{
		ident.Analyzer,
	},
	Run: func(pass *analysis.Pass) (interface{}, error) {
		m := pass.ResultOf[ident.Analyzer].(ident.Map)
		for o, idents := range m {
			sort.Slice(idents, func(i, j int) bool {
				return idents[i].Pos() < idents[j].Pos()
			})
			lines := make([]string, len(idents))
			for i := range idents {
				pos := pass.Fset.Position(idents[i].Pos())
				lines[i] = fmt.Sprintf("%s:%d", filepath.Base(pos.Filename), pos.Line)
			}
			pass.Reportf(o.Pos(), "%s", strings.Join(lines, " "))
		}
		return nil, nil
	},
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: "ident",
	Doc:  doc,
	Run:  run,
	Requires: []*analysis.Analyzer{
		inspect.Analyzer,
	},
	ResultType: reflect.TypeOf(Map{}),
}

Analyzer maps types.Object to *ast.Ident.

Functions

This section is empty.

Types

type Map

type Map map[types.Object][]*ast.Ident

Map maps types.Object to *ast.Ident.

Jump to

Keyboard shortcuts

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