aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/go-toolsmith/astp
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/go-toolsmith/astp')
-rw-r--r--vendor/github.com/go-toolsmith/astp/.gitignore4
-rw-r--r--vendor/github.com/go-toolsmith/astp/.travis.yml9
-rw-r--r--vendor/github.com/go-toolsmith/astp/LICENSE21
-rw-r--r--vendor/github.com/go-toolsmith/astp/README.md39
-rw-r--r--vendor/github.com/go-toolsmith/astp/decl.go39
-rw-r--r--vendor/github.com/go-toolsmith/astp/expr.go141
-rw-r--r--vendor/github.com/go-toolsmith/astp/go.mod6
-rw-r--r--vendor/github.com/go-toolsmith/astp/go.sum4
-rw-r--r--vendor/github.com/go-toolsmith/astp/stmt.go135
9 files changed, 398 insertions, 0 deletions
diff --git a/vendor/github.com/go-toolsmith/astp/.gitignore b/vendor/github.com/go-toolsmith/astp/.gitignore
new file mode 100644
index 000000000..1f6187ecd
--- /dev/null
+++ b/vendor/github.com/go-toolsmith/astp/.gitignore
@@ -0,0 +1,4 @@
+bin
+pkg
+src/main
+tmp \ No newline at end of file
diff --git a/vendor/github.com/go-toolsmith/astp/.travis.yml b/vendor/github.com/go-toolsmith/astp/.travis.yml
new file mode 100644
index 000000000..8994d395c
--- /dev/null
+++ b/vendor/github.com/go-toolsmith/astp/.travis.yml
@@ -0,0 +1,9 @@
+language: go
+go:
+ - 1.x
+install:
+ - # Prevent default install action "go get -t -v ./...".
+script:
+ - go get -t -v ./...
+ - go tool vet .
+ - go test -v -race ./... \ No newline at end of file
diff --git a/vendor/github.com/go-toolsmith/astp/LICENSE b/vendor/github.com/go-toolsmith/astp/LICENSE
new file mode 100644
index 000000000..eef17180f
--- /dev/null
+++ b/vendor/github.com/go-toolsmith/astp/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2018 go-toolsmith
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/go-toolsmith/astp/README.md b/vendor/github.com/go-toolsmith/astp/README.md
new file mode 100644
index 000000000..7313c6ab8
--- /dev/null
+++ b/vendor/github.com/go-toolsmith/astp/README.md
@@ -0,0 +1,39 @@
+[![Go Report Card](https://goreportcard.com/badge/github.com/go-toolsmith/astp)](https://goreportcard.com/report/github.com/go-toolsmith/astp)
+[![GoDoc](https://godoc.org/github.com/go-toolsmith/astp?status.svg)](https://godoc.org/github.com/go-toolsmith/astp)
+[![Build Status](https://travis-ci.org/go-toolsmith/astp.svg?branch=master)](https://travis-ci.org/go-toolsmith/astp)
+
+
+# astp
+
+Package astp provides AST predicates.
+
+## Installation:
+
+```bash
+go get github.com/go-toolsmith/astp
+```
+
+## Example
+
+```go
+package main
+
+import (
+ "fmt"
+
+ "github.com/go-toolsmith/astp"
+ "github.com/go-toolsmith/strparse"
+)
+
+func main() {
+ if astp.IsIdent(strparse.Expr(`x`)) {
+ fmt.Println("ident")
+ }
+ if astp.IsBlockStmt(strparse.Stmt(`{f()}`)) {
+ fmt.Println("block stmt")
+ }
+ if astp.IsGenDecl(strparse.Decl(`var x int = 10`)) {
+ fmt.Println("gen decl")
+ }
+}
+```
diff --git a/vendor/github.com/go-toolsmith/astp/decl.go b/vendor/github.com/go-toolsmith/astp/decl.go
new file mode 100644
index 000000000..4654ad95c
--- /dev/null
+++ b/vendor/github.com/go-toolsmith/astp/decl.go
@@ -0,0 +1,39 @@
+package astp
+
+import "go/ast"
+
+// IsDecl reports whether a node is a ast.Decl.
+func IsDecl(node ast.Node) bool {
+ _, ok := node.(ast.Decl)
+ return ok
+}
+
+// IsFuncDecl reports whether a given ast.Node is a function declaration (*ast.FuncDecl).
+func IsFuncDecl(node ast.Node) bool {
+ _, ok := node.(*ast.FuncDecl)
+ return ok
+}
+
+// IsGenDecl reports whether a given ast.Node is a generic declaration (*ast.GenDecl).
+func IsGenDecl(node ast.Node) bool {
+ _, ok := node.(*ast.GenDecl)
+ return ok
+}
+
+// IsImportSpec reports whether a given ast.Node is an import declaration (*ast.ImportSpec).
+func IsImportSpec(node ast.Node) bool {
+ _, ok := node.(*ast.ImportSpec)
+ return ok
+}
+
+// IsValueSpec reports whether a given ast.Node is a value declaration (*ast.ValueSpec).
+func IsValueSpec(node ast.Node) bool {
+ _, ok := node.(*ast.ValueSpec)
+ return ok
+}
+
+// IsTypeSpec reports whether a given ast.Node is a type declaration (*ast.TypeSpec).
+func IsTypeSpec(node ast.Node) bool {
+ _, ok := node.(*ast.TypeSpec)
+ return ok
+}
diff --git a/vendor/github.com/go-toolsmith/astp/expr.go b/vendor/github.com/go-toolsmith/astp/expr.go
new file mode 100644
index 000000000..adf9668ce
--- /dev/null
+++ b/vendor/github.com/go-toolsmith/astp/expr.go
@@ -0,0 +1,141 @@
+package astp
+
+import "go/ast"
+
+// IsExpr reports whether a given ast.Node is an expression(ast.Expr).
+func IsExpr(node ast.Node) bool {
+ _, ok := node.(ast.Expr)
+ return ok
+}
+
+// IsBadExpr reports whether a given ast.Node is a bad expression (*ast.IsBadExpr).
+func IsBadExpr(node ast.Node) bool {
+ _, ok := node.(*ast.BadExpr)
+ return ok
+}
+
+// IsIdent reports whether a given ast.Node is an identifier (*ast.IsIdent).
+func IsIdent(node ast.Node) bool {
+ _, ok := node.(*ast.Ident)
+ return ok
+}
+
+// IsEllipsis reports whether a given ast.Node is an `...` (ellipsis) (*ast.IsEllipsis).
+func IsEllipsis(node ast.Node) bool {
+ _, ok := node.(*ast.Ellipsis)
+ return ok
+}
+
+// IsBasicLit reports whether a given ast.Node is a literal of basic type (*ast.IsBasicLit).
+func IsBasicLit(node ast.Node) bool {
+ _, ok := node.(*ast.BasicLit)
+ return ok
+}
+
+// IsFuncLit reports whether a given ast.Node is a function literal (*ast.IsFuncLit).
+func IsFuncLit(node ast.Node) bool {
+ _, ok := node.(*ast.FuncLit)
+ return ok
+}
+
+// IsCompositeLit reports whether a given ast.Node is a composite literal (*ast.IsCompositeLit).
+func IsCompositeLit(node ast.Node) bool {
+ _, ok := node.(*ast.CompositeLit)
+ return ok
+}
+
+// IsParenExpr reports whether a given ast.Node is a parenthesized expression (*ast.IsParenExpr).
+func IsParenExpr(node ast.Node) bool {
+ _, ok := node.(*ast.ParenExpr)
+ return ok
+}
+
+// IsSelectorExpr reports whether a given ast.Node is a selector expression (*ast.IsSelectorExpr).
+func IsSelectorExpr(node ast.Node) bool {
+ _, ok := node.(*ast.SelectorExpr)
+ return ok
+}
+
+// IsIndexExpr reports whether a given ast.Node is an index expression (*ast.IsIndexExpr).
+func IsIndexExpr(node ast.Node) bool {
+ _, ok := node.(*ast.IndexExpr)
+ return ok
+}
+
+// IsSliceExpr reports whether a given ast.Node is a slice expression (*ast.IsSliceExpr).
+func IsSliceExpr(node ast.Node) bool {
+ _, ok := node.(*ast.SliceExpr)
+ return ok
+}
+
+// IsTypeAssertExpr reports whether a given ast.Node is a type assert expression (*ast.IsTypeAssertExpr).
+func IsTypeAssertExpr(node ast.Node) bool {
+ _, ok := node.(*ast.TypeAssertExpr)
+ return ok
+}
+
+// IsCallExpr reports whether a given ast.Node is an expression followed by an argument list (*ast.IsCallExpr).
+func IsCallExpr(node ast.Node) bool {
+ _, ok := node.(*ast.CallExpr)
+ return ok
+}
+
+// IsStarExpr reports whether a given ast.Node is a star expression(unary "*" or apointer) (*ast.IsStarExpr)
+func IsStarExpr(node ast.Node) bool {
+ _, ok := node.(*ast.StarExpr)
+ return ok
+}
+
+// IsUnaryExpr reports whether a given ast.Node is a unary expression (*ast.IsUnaryExpr).
+func IsUnaryExpr(node ast.Node) bool {
+ _, ok := node.(*ast.UnaryExpr)
+ return ok
+}
+
+// IsBinaryExpr reports whether a given ast.Node is a binary expression (*ast.IsBinaryExpr).
+func IsBinaryExpr(node ast.Node) bool {
+ _, ok := node.(*ast.BinaryExpr)
+ return ok
+}
+
+// IsKeyValueExpr reports whether a given ast.Node is a (key:value) pair (*ast.IsKeyValueExpr).
+func IsKeyValueExpr(node ast.Node) bool {
+ _, ok := node.(*ast.KeyValueExpr)
+ return ok
+}
+
+// IsArrayType reports whether a given ast.Node is an array or slice type (*ast.IsArrayType).
+func IsArrayType(node ast.Node) bool {
+ _, ok := node.(*ast.ArrayType)
+ return ok
+}
+
+// IsStructType reports whether a given ast.Node is a struct type (*ast.IsStructType).
+func IsStructType(node ast.Node) bool {
+ _, ok := node.(*ast.StructType)
+ return ok
+}
+
+// IsFuncType reports whether a given ast.Node is a function type (*ast.IsFuncType).
+func IsFuncType(node ast.Node) bool {
+ _, ok := node.(*ast.FuncType)
+ return ok
+}
+
+// IsInterfaceType reports whether a given ast.Node is an interface type (*ast.IsInterfaceType).
+func IsInterfaceType(node ast.Node) bool {
+ _, ok := node.(*ast.InterfaceType)
+ return ok
+}
+
+// IsMapType reports whether a given ast.Node is a map type (*ast.IsMapType).
+func IsMapType(node ast.Node) bool {
+ _, ok := node.(*ast.MapType)
+ return ok
+}
+
+// IsChanType reports whether a given ast.Node is a channel type (*ast.IsChanType).
+func IsChanType(node ast.Node) bool {
+ _, ok := node.(*ast.ChanType)
+ return ok
+}
diff --git a/vendor/github.com/go-toolsmith/astp/go.mod b/vendor/github.com/go-toolsmith/astp/go.mod
new file mode 100644
index 000000000..023a09392
--- /dev/null
+++ b/vendor/github.com/go-toolsmith/astp/go.mod
@@ -0,0 +1,6 @@
+module github.com/go-toolsmith/astp
+
+require (
+ github.com/go-toolsmith/astequal v1.0.0 // indirect
+ github.com/go-toolsmith/strparse v1.0.0
+)
diff --git a/vendor/github.com/go-toolsmith/astp/go.sum b/vendor/github.com/go-toolsmith/astp/go.sum
new file mode 100644
index 000000000..aa0857030
--- /dev/null
+++ b/vendor/github.com/go-toolsmith/astp/go.sum
@@ -0,0 +1,4 @@
+github.com/go-toolsmith/astequal v1.0.0 h1:4zxD8j3JRFNyLN46lodQuqz3xdKSrur7U/sr0SDS/gQ=
+github.com/go-toolsmith/astequal v1.0.0/go.mod h1:H+xSiq0+LtiDC11+h1G32h7Of5O3CYFJ99GVbS5lDKY=
+github.com/go-toolsmith/strparse v1.0.0 h1:Vcw78DnpCAKlM20kSbAyO4mPfJn/lyYA4BJUDxe2Jb4=
+github.com/go-toolsmith/strparse v1.0.0/go.mod h1:YI2nUKP9YGZnL/L1/DLFBfixrcjslWct4wyljWhSRy8=
diff --git a/vendor/github.com/go-toolsmith/astp/stmt.go b/vendor/github.com/go-toolsmith/astp/stmt.go
new file mode 100644
index 000000000..19645d212
--- /dev/null
+++ b/vendor/github.com/go-toolsmith/astp/stmt.go
@@ -0,0 +1,135 @@
+package astp
+
+import "go/ast"
+
+// IsStmt reports whether a given ast.Node is a statement(ast.Stmt).
+func IsStmt(node ast.Node) bool {
+ _, ok := node.(ast.Stmt)
+ return ok
+}
+
+// IsBadStmt reports whether a given ast.Node is a bad statement(*ast.BadStmt)
+func IsBadStmt(node ast.Node) bool {
+ _, ok := node.(*ast.BadStmt)
+ return ok
+}
+
+// IsDeclStmt reports whether a given ast.Node is a declaration statement(*ast.DeclStmt)
+func IsDeclStmt(node ast.Node) bool {
+ _, ok := node.(*ast.DeclStmt)
+ return ok
+}
+
+// IsEmptyStmt reports whether a given ast.Node is an empty statement(*ast.EmptyStmt)
+func IsEmptyStmt(node ast.Node) bool {
+ _, ok := node.(*ast.EmptyStmt)
+ return ok
+}
+
+// IsLabeledStmt reports whether a given ast.Node is a label statement(*ast.LabeledStmt)
+func IsLabeledStmt(node ast.Node) bool {
+ _, ok := node.(*ast.LabeledStmt)
+ return ok
+}
+
+// IsExprStmt reports whether a given ast.Node is an expression statement(*ast.ExprStmt)
+func IsExprStmt(node ast.Node) bool {
+ _, ok := node.(*ast.ExprStmt)
+ return ok
+}
+
+// IsSendStmt reports whether a given ast.Node is a send to chan statement(*ast.SendStmt)
+func IsSendStmt(node ast.Node) bool {
+ _, ok := node.(*ast.SendStmt)
+ return ok
+}
+
+// IsIncDecStmt reports whether a given ast.Node is a increment/decrement statement(*ast.IncDecStmt)
+func IsIncDecStmt(node ast.Node) bool {
+ _, ok := node.(*ast.IncDecStmt)
+ return ok
+}
+
+// IsAssignStmt reports whether a given ast.Node is an assignment statement(*ast.AssignStmt)
+func IsAssignStmt(node ast.Node) bool {
+ _, ok := node.(*ast.AssignStmt)
+ return ok
+}
+
+// IsGoStmt reports whether a given ast.Node is a go statement(*ast.GoStmt)
+func IsGoStmt(node ast.Node) bool {
+ _, ok := node.(*ast.GoStmt)
+ return ok
+}
+
+// IsDeferStmt reports whether a given ast.Node is a defer statement(*ast.DeferStmt)
+func IsDeferStmt(node ast.Node) bool {
+ _, ok := node.(*ast.DeferStmt)
+ return ok
+}
+
+// IsReturnStmt reports whether a given ast.Node is a return statement(*ast.ReturnStmt)
+func IsReturnStmt(node ast.Node) bool {
+ _, ok := node.(*ast.ReturnStmt)
+ return ok
+}
+
+// IsBranchStmt reports whether a given ast.Node is a branch(goto/continue/break/fallthrough)statement(*ast.BranchStmt)
+func IsBranchStmt(node ast.Node) bool {
+ _, ok := node.(*ast.BranchStmt)
+ return ok
+}
+
+// IsBlockStmt reports whether a given ast.Node is a block statement(*ast.BlockStmt)
+func IsBlockStmt(node ast.Node) bool {
+ _, ok := node.(*ast.BlockStmt)
+ return ok
+}
+
+// IsIfStmt reports whether a given ast.Node is an if statement(*ast.IfStmt)
+func IsIfStmt(node ast.Node) bool {
+ _, ok := node.(*ast.IfStmt)
+ return ok
+}
+
+// IsCaseClause reports whether a given ast.Node is a case statement(*ast.CaseClause)
+func IsCaseClause(node ast.Node) bool {
+ _, ok := node.(*ast.CaseClause)
+ return ok
+}
+
+// IsSwitchStmt reports whether a given ast.Node is a switch statement(*ast.SwitchStmt)
+func IsSwitchStmt(node ast.Node) bool {
+ _, ok := node.(*ast.SwitchStmt)
+ return ok
+}
+
+// IsTypeSwitchStmt reports whether a given ast.Node is a type switch statement(*ast.TypeSwitchStmt)
+func IsTypeSwitchStmt(node ast.Node) bool {
+ _, ok := node.(*ast.TypeSwitchStmt)
+ return ok
+}
+
+// IsCommClause reports whether a given ast.Node is a select statement(*ast.CommClause)
+func IsCommClause(node ast.Node) bool {
+ _, ok := node.(*ast.CommClause)
+ return ok
+}
+
+// IsSelectStmt reports whether a given ast.Node is a selection statement(*ast.SelectStmt)
+func IsSelectStmt(node ast.Node) bool {
+ _, ok := node.(*ast.SelectStmt)
+ return ok
+}
+
+// IsForStmt reports whether a given ast.Node is a for statement(*ast.ForStmt)
+func IsForStmt(node ast.Node) bool {
+ _, ok := node.(*ast.ForStmt)
+ return ok
+}
+
+// IsRangeStmt reports whether a given ast.Node is a range statement(*ast.RangeStmt)
+func IsRangeStmt(node ast.Node) bool {
+ _, ok := node.(*ast.RangeStmt)
+ return ok
+}