Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools@v0.0.0-20201105173854-bc9fc8d8c4bc / go / analysis / passes / inspect / inspect.go
1 // Copyright 2018 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // Package inspect defines an Analyzer that provides an AST inspector
6 // (golang.org/x/tools/go/ast/inspect.Inspect) for the syntax trees of a
7 // package. It is only a building block for other analyzers.
8 //
9 // Example of use in another analysis:
10 //
11 //      import (
12 //              "golang.org/x/tools/go/analysis"
13 //              "golang.org/x/tools/go/analysis/passes/inspect"
14 //              "golang.org/x/tools/go/ast/inspector"
15 //      )
16 //
17 //      var Analyzer = &analysis.Analyzer{
18 //              ...
19 //              Requires:       []*analysis.Analyzer{inspect.Analyzer},
20 //      }
21 //
22 //      func run(pass *analysis.Pass) (interface{}, error) {
23 //              inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
24 //              inspect.Preorder(nil, func(n ast.Node) {
25 //                      ...
26 //              })
27 //              return nil
28 //      }
29 //
30 package inspect
31
32 import (
33         "reflect"
34
35         "golang.org/x/tools/go/analysis"
36         "golang.org/x/tools/go/ast/inspector"
37 )
38
39 var Analyzer = &analysis.Analyzer{
40         Name:             "inspect",
41         Doc:              "optimize AST traversal for later passes",
42         Run:              run,
43         RunDespiteErrors: true,
44         ResultType:       reflect.TypeOf(new(inspector.Inspector)),
45 }
46
47 func run(pass *analysis.Pass) (interface{}, error) {
48         return inspector.New(pass.Files), nil
49 }