Documentation
¶
Index ¶
- Variables
- type Evaluator
- type Inspector
- type NodeNavigator
- func (n *NodeNavigator) Copy() xpath.NodeNavigator
- func (n *NodeNavigator) LocalName() string
- func (n *NodeNavigator) MoveTo(to xpath.NodeNavigator) bool
- func (n *NodeNavigator) MoveToChild() bool
- func (n *NodeNavigator) MoveToFirst() bool
- func (n *NodeNavigator) MoveToNext() bool
- func (n *NodeNavigator) MoveToNextAttribute() bool
- func (n *NodeNavigator) MoveToParent() bool
- func (n *NodeNavigator) MoveToPrevious() bool
- func (n *NodeNavigator) MoveToRoot()
- func (n *NodeNavigator) Node() ast.Node
- func (n *NodeNavigator) NodeType() xpath.NodeType
- func (n *NodeNavigator) Prefix() string
- func (n *NodeNavigator) Value() string
Constants ¶
This section is empty.
Variables ¶
View Source
var Analyzer = &analysis.Analyzer{ Name: "astquery", Doc: "search nodes by xpath", Run: new(analyzer).run, Requires: []*analysis.Analyzer{ inspect.Analyzer, }, ResultType: reflect.TypeOf(new(Evaluator)), }
Analyzer provides *astquery.Evaluator as a result.
Example:
func run(pass *analysis.Pass) (interface{}, error) { e := pass.ResultOf[astquery.Analyzer].(*astquery.Evaluator) ns, err := e.Select("//*[@type='CallExpr']/Fun[@type='Ident' and @Name='panic']") if err != nil { return nil, err } for _, n := range ns { pass.Reportf(n.Pos(), "don't panic") } return nil, nil }
Functions ¶
This section is empty.
Types ¶
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
Evaluator evals and selects AST's nodes by XPath.
func (*Evaluator) Eval ¶
Eval returns the result of the expression. The result type of the expression is one of the follow: bool,float64,string,[]ast.Node.
type Inspector ¶
Inspector is wrapper of *golang.org/x/go/ast/inspector.Inspector.
func NewInspector ¶
NewInspector creates an Inspector.
type NodeNavigator ¶
type NodeNavigator struct {
// contains filtered or unexported fields
}
NodeNavigator implements xpath.NodeNavigator.
func NewNodeNavigator ¶
func NewNodeNavigator(fset *token.FileSet, files []*ast.File, in *inspector.Inspector) *NodeNavigator
NewNodeNavigator creates a NodeNavigator. If in is not nil NodeNavigator use the given inspector.
func (*NodeNavigator) Copy ¶
func (n *NodeNavigator) Copy() xpath.NodeNavigator
func (*NodeNavigator) LocalName ¶
func (n *NodeNavigator) LocalName() string
func (*NodeNavigator) MoveTo ¶
func (n *NodeNavigator) MoveTo(to xpath.NodeNavigator) bool
func (*NodeNavigator) MoveToChild ¶
func (n *NodeNavigator) MoveToChild() bool
func (*NodeNavigator) MoveToFirst ¶
func (n *NodeNavigator) MoveToFirst() bool
func (*NodeNavigator) MoveToNext ¶
func (n *NodeNavigator) MoveToNext() bool
func (*NodeNavigator) MoveToNextAttribute ¶
func (n *NodeNavigator) MoveToNextAttribute() bool
func (*NodeNavigator) MoveToParent ¶
func (n *NodeNavigator) MoveToParent() bool
func (*NodeNavigator) MoveToPrevious ¶
func (n *NodeNavigator) MoveToPrevious() bool
func (*NodeNavigator) MoveToRoot ¶
func (n *NodeNavigator) MoveToRoot()
func (*NodeNavigator) Node ¶
func (n *NodeNavigator) Node() ast.Node
func (*NodeNavigator) NodeType ¶
func (n *NodeNavigator) NodeType() xpath.NodeType
func (*NodeNavigator) Prefix ¶
func (n *NodeNavigator) Prefix() string
func (*NodeNavigator) Value ¶
func (n *NodeNavigator) Value() string
Click to show internal directories.
Click to hide internal directories.