query

package
v0.0.0-...-47ce07a Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2022 License: BSD-3-Clause Imports: 3 Imported by: 5

Documentation

Overview

Package query implements CSS/jQuery-esque selectors over a PHP AST

Currently, the only supported selectors are:

"node", where node is the type name of an AST node (e.g. EchoStmt)

"parent child", where the descendance may skip levels.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	Node   ast.Node
	Parent *Node
}

Node is a node

type NodeRule

type NodeRule struct {
	// Type is the node type represented as a string, without the package name. For example: ReturnStmt.
	Type string
}

NodeRule is a node rule

func (NodeRule) Pass

func (r NodeRule) Pass(n Node) bool

type Q

type Q []Node

Q is a node queue

func Select

func Select(nodes []ast.Node) Q

Select flattens a node list to a queue

func (Q) Select

func (q Q) Select(s string) (Q, error)

type Rule

type Rule interface {
	Pass(n Node) bool
}

Rule is a rule

type Selector

type Selector struct {
	// contains filtered or unexported fields
}

Selector is a selector

func ParseSelector

func ParseSelector(s string) (*Selector, error)

ParseSelector parses a string to a selector

func (Selector) Pass

func (s Selector) Pass(n Node, local bool) bool

Directories

Path Synopsis
cmd
query command
Command query implements a simple CLI for querying a PHP AST.
Command query implements a simple CLI for querying a PHP AST.

Jump to

Keyboard shortcuts

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