go-ruleguard: github.com/quasilyte/go-ruleguard/dsl/fluent Index | Files

package fluent

import "github.com/quasilyte/go-ruleguard/dsl/fluent"


Package Files

dsl.go internal.go

type ExprType Uses

type ExprType struct {
    // Size represents expression type size in bytes.
    Size int

ExprType describes a type of a matcher expr.

func (ExprType) AssignableTo Uses

func (ExprType) AssignableTo(typ string) bool

AssignableTo reports whether a type is assign-compatible with a given type. See https://golang.org/pkg/go/types/#AssignableTo.

func (ExprType) ConvertibleTo Uses

func (ExprType) ConvertibleTo(typ string) bool

ConvertibleTo reports whether a type is conversible to a given type. See https://golang.org/pkg/go/types/#ConvertibleTo.

func (ExprType) Implements Uses

func (ExprType) Implements(typ string) bool

Implements reports whether a type implements a given interface. See https://golang.org/pkg/go/types/#Implements.

func (ExprType) Is Uses

func (ExprType) Is(typ string) bool

Is reports whether a type is identical to a given type.

type MatchedText Uses

type MatchedText string

MatchedText represents a source text associated with a matched node.

func (MatchedText) Matches Uses

func (MatchedText) Matches(pattern string) bool

Matches reports whether the text matches the given regexp pattern.

type Matcher Uses

type Matcher map[string]Var

Matcher is a main API group-level entry point. It's used to define and configure the group rules. It also represents a map of all rule-local variables.

func (Matcher) At Uses

func (m Matcher) At(v Var) Matcher

At binds the reported node to a named submatch. If no explicit location is given, the outermost node ($$) is used.

func (Matcher) Import Uses

func (m Matcher) Import(pkgPath string)

Import loads given package path into a rule group imports table.

That table is used during the rules compilation.

The table has the following effect on the rules:

* For type expressions, it's used to resolve the
  full package paths of qualified types, like `foo.Bar`.
  If Import(`a/b/foo`) is called, `foo.Bar` will match
  `a/b/foo.Bar` type during the pattern execution.

func (Matcher) Match Uses

func (m Matcher) Match(pattern string, alternatives ...string) Matcher

Match specifies a set of patterns that match a rule being defined. Pattern matching succeeds if at least 1 pattern matches.

If none of the given patterns matched, rule execution stops.

func (Matcher) Report Uses

func (m Matcher) Report(message string) Matcher

Report prints a message if associated rule match is successful.

A message is a string that can contain interpolated expressions. For every matched variable it's possible to interpolate their printed representation into the message text with $<name>. An entire match can be addressed with $$.

func (Matcher) Suggest Uses

func (m Matcher) Suggest(suggestion string) Matcher

Suggest assigns a quickfix suggestion for the matched code.

func (Matcher) Where Uses

func (m Matcher) Where(cond bool) Matcher

Where applies additional constraint to a match. If a given cond is not satisfied, a match is rejected and rule execution stops.

type Var Uses

type Var struct {
    // Pure reports whether expr matched by var is side-effect-free.
    Pure bool

    // Const reports whether expr matched by var is a constant value.
    Const bool

    // Addressable reports whether the corresponding expression is addressable.
    // See https://golang.org/ref/spec#Address_operators.
    Addressable bool

    // Type is a type of a matched expr.
    Type ExprType

    // Text is a captured node text as in the source code.
    Text MatchedText

Var is a pattern variable that describes a named submatch.

Package fluent is imported by 1 packages. Updated 2020-07-13. Refresh now. Tools for package owners.