plugin

package
v0.0.0-...-9f81d63 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryTypeAst   QueryType = "ast"
	QueryTypeRegex           = "regex"
	QueryTypeJson            = "json"
	QueryTypeYaml            = "yaml"
	QueryTypeRaw             = "raw"
)
View Source
const DeclareTargetsContextDefaultGroup = "default"

Variables

This section is empty.

Functions

func TargetExportComparator

func TargetExportComparator(a, b interface{}) int

func TargetImportComparator

func TargetImportComparator(a, b interface{}) int

Types

type AddTargetAction

type AddTargetAction struct {
	TargetAction
	TargetDeclaration
}

type AnalyzeContext

type AnalyzeContext struct {
	PrepareContext
	Source *TargetSource
	// contains filtered or unexported fields
}

func NewAnalyzeContext

func NewAnalyzeContext(prep PrepareContext, source *TargetSource, database *Database) AnalyzeContext

func (AnalyzeContext) AddSymbol

func (a AnalyzeContext) AddSymbol(label Label, symbol Symbol)

func (AnalyzeContext) Attr

func (a AnalyzeContext) Attr(name string) (starlark.Value, error)

func (AnalyzeContext) AttrNames

func (a AnalyzeContext) AttrNames() []string

func (AnalyzeContext) Freeze

func (a AnalyzeContext) Freeze()

func (AnalyzeContext) Hash

func (a AnalyzeContext) Hash() (uint32, error)

func (AnalyzeContext) String

func (a AnalyzeContext) String() string

func (AnalyzeContext) Truth

func (a AnalyzeContext) Truth() starlark.Bool

func (AnalyzeContext) Type

func (a AnalyzeContext) Type() string

type AstQueryParams

type AstQueryParams struct {
	Grammar string
	Query   string
}

type Database

type Database struct {
	Symbols []TargetSymbol
	// contains filtered or unexported fields
}

func (*Database) AddSymbol

func (d *Database) AddSymbol(label Label, symbol Symbol)

type DeclareTargetActions

type DeclareTargetActions interface {
	Add(target TargetDeclaration)
	Remove(name, kind string)
	Actions() []TargetAction
}

func NewDeclareTargetActions

func NewDeclareTargetActions() DeclareTargetActions

type DeclareTargetsContext

type DeclareTargetsContext struct {
	PrepareContext
	Sources TargetSources
	Targets DeclareTargetActions
	// contains filtered or unexported fields
}

The context for an extension to generate targets.

Queries results are mapped by file extension, each containing a map of query name to result.

func NewDeclareTargetsContext

func NewDeclareTargetsContext(prep PrepareContext, sources TargetSources, targets DeclareTargetActions, database *Database) DeclareTargetsContext

func (DeclareTargetsContext) AddSymbol

func (d DeclareTargetsContext) AddSymbol(label Label, symbol Symbol)

func (DeclareTargetsContext) Attr

func (ctx DeclareTargetsContext) Attr(name string) (starlark.Value, error)

func (DeclareTargetsContext) AttrNames

func (ctx DeclareTargetsContext) AttrNames() []string

func (DeclareTargetsContext) String

func (ctx DeclareTargetsContext) String() string

func (DeclareTargetsContext) Type

func (ctx DeclareTargetsContext) Type() string

type DeclareTargetsResult

type DeclareTargetsResult struct {
	Actions []TargetAction
}

The result of declaring targets

type JsonQueryParams

type JsonQueryParams = string

type KindInfo

type KindInfo struct {
	// MatchAny is true if a rule of this kind may be matched with any rule
	// of the same kind, regardless of attributes, if exactly one rule is
	// present a build file.
	MatchAny bool

	// MatchAttrs is a list of attributes used in matching. For example,
	// for go_library, this list contains "importpath". Attributes are matched
	// in order.
	MatchAttrs []string

	// NonEmptyAttrs is a set of attributes that, if present, disqualify a rule
	// from being deleted after merge.
	NonEmptyAttrs []string

	// MergeableAttrs is a set of attributes that should be merged before
	// dependency resolution. For example "srcs" are often merged before resolution
	// to compute the full set of sources for a target before resolving dependencies.
	MergeableAttrs []string

	// ResolveAttrs is a set of attributes that should be merged after
	// dependency resolution. For example "deps" are often merged after resolution.
	ResolveAttrs []string
}

Subset of the bazel-gazelle rule.KindInfo. See bazel-gazelle for details.

type Label

type Label struct {
	Repo, Pkg, Name string
}

func (Label) Attr

func (l Label) Attr(name string) (starlark.Value, error)

func (Label) AttrNames

func (l Label) AttrNames() []string

func (Label) Freeze

func (l Label) Freeze()

func (Label) Hash

func (l Label) Hash() (uint32, error)

func (Label) String

func (l Label) String() string

func (Label) Truth

func (l Label) Truth() starlark.Bool

func (Label) Type

func (l Label) Type() string

type NamedQueries

type NamedQueries map[string]QueryDefinition

A set of queries keyed by name.

func (NamedQueries) Freeze

func (nq NamedQueries) Freeze()

func (NamedQueries) Get

func (nq NamedQueries) Get(k starlark.Value) (v starlark.Value, found bool, err error)

func (NamedQueries) Hash

func (nq NamedQueries) Hash() (uint32, error)

func (NamedQueries) String

func (nq NamedQueries) String() string

func (NamedQueries) Truth

func (nq NamedQueries) Truth() starlark.Bool

func (NamedQueries) Type

func (nq NamedQueries) Type() string

type Plugin

type Plugin interface {
	// Static plugin metadata
	Name() PluginId
	Properties() map[string]Property

	// Prepare for generating targets
	Prepare(ctx PrepareContext) PrepareResult
	Analyze(ctx AnalyzeContext) error
	DeclareTargets(ctx DeclareTargetsContext) DeclareTargetsResult
}

TODO: change the interface into a factory method (at least in starzelle)

type PluginHost

type PluginHost interface {
	AddKind(k RuleKind)
	AddPlugin(plugin Plugin)
}

type PluginId

type PluginId = string

type PrepareContext

type PrepareContext struct {
	RepoName   string
	Rel        string
	Properties PropertyValues
}

The context for an extension to prepare for generating targets.

func (PrepareContext) Attr

func (ctx PrepareContext) Attr(name string) (starlark.Value, error)

func (PrepareContext) AttrNames

func (ctx PrepareContext) AttrNames() []string

func (PrepareContext) Freeze

func (ctx PrepareContext) Freeze()

func (PrepareContext) Hash

func (ctx PrepareContext) Hash() (uint32, error)

func (PrepareContext) String

func (ctx PrepareContext) String() string

func (PrepareContext) Truth

func (ctx PrepareContext) Truth() starlark.Bool

func (PrepareContext) Type

func (ctx PrepareContext) Type() string

type PrepareResult

type PrepareResult struct {
	Sources map[string][]SourceFilter
	Queries NamedQueries
}

The result of an extension preparing for generating targets.

Queries are mapped by file extension and will be executed against all matching extensions.

Example:

 PrepareResult {
		Extensions: [".java"],
		Queries: {
			"imports": {
				"Type": "string|strings|exists",
				"Extensions": ["*.java"],
				"Query": "(import_list)",
			},
		},
 }

func (PrepareResult) Attr

func (r PrepareResult) Attr(name string) (starlark.Value, error)

func (PrepareResult) AttrNames

func (r PrepareResult) AttrNames() []string

func (PrepareResult) Freeze

func (r PrepareResult) Freeze()

func (PrepareResult) Hash

func (r PrepareResult) Hash() (uint32, error)

func (PrepareResult) String

func (r PrepareResult) String() string

func (PrepareResult) Truth

func (r PrepareResult) Truth() starlark.Bool

func (PrepareResult) Type

func (r PrepareResult) Type() string

type Property

type Property struct {
	Name         string // TODO: drop because it's always specified in a map[Name]?
	PropertyType PropertyType
	Default      interface{}
}

Properties an extension can be configured

func (Property) Attr

func (p Property) Attr(name string) (starlark.Value, error)

func (Property) AttrNames

func (p Property) AttrNames() []string

func (Property) Freeze

func (p Property) Freeze()

func (Property) Hash

func (p Property) Hash() (uint32, error)

func (Property) String

func (p Property) String() string

func (Property) Truth

func (p Property) Truth() starlark.Bool

func (Property) Type

func (p Property) Type() string

type PropertyType

type PropertyType = string
const (
	PropertyType_String  PropertyType = "string"
	PropertyType_Strings PropertyType = "[]string"
	PropertyType_Bool    PropertyType = "bool"
	PropertyType_Number  PropertyType = "number"
)

type PropertyValues

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

func NewPropertyValues

func NewPropertyValues() PropertyValues

func (PropertyValues) Add

func (pv PropertyValues) Add(name string, value interface{})

func (PropertyValues) Freeze

func (p PropertyValues) Freeze()

func (PropertyValues) Get

func (p PropertyValues) Get(k starlark.Value) (v starlark.Value, found bool, err error)

func (PropertyValues) Hash

func (p PropertyValues) Hash() (uint32, error)

func (PropertyValues) String

func (p PropertyValues) String() string

func (PropertyValues) Truth

func (p PropertyValues) Truth() starlark.Bool

func (PropertyValues) Type

func (p PropertyValues) Type() string

type QueryCapture

type QueryCapture map[string]string

The captures of a single query match

func (*QueryCapture) Freeze

func (q *QueryCapture) Freeze()

func (*QueryCapture) Get

func (q *QueryCapture) Get(k starlark.Value) (v starlark.Value, found bool, err error)

func (*QueryCapture) Hash

func (q *QueryCapture) Hash() (uint32, error)

func (*QueryCapture) String

func (q *QueryCapture) String() string

func (*QueryCapture) Truth

func (q *QueryCapture) Truth() starlark.Bool

func (*QueryCapture) Type

func (q *QueryCapture) Type() string

type QueryDefinition

type QueryDefinition struct {
	Filter    []string
	QueryType QueryType
	Params    interface{}
}

A query to run on source files

func (QueryDefinition) Attr

func (qd QueryDefinition) Attr(name string) (starlark.Value, error)

func (QueryDefinition) AttrNames

func (qd QueryDefinition) AttrNames() []string

func (QueryDefinition) Freeze

func (qd QueryDefinition) Freeze()

func (QueryDefinition) Hash

func (qd QueryDefinition) Hash() (uint32, error)

func (QueryDefinition) Match

func (q QueryDefinition) Match(f string) bool

func (QueryDefinition) String

func (qd QueryDefinition) String() string

func (QueryDefinition) Truth

func (qd QueryDefinition) Truth() starlark.Bool

func (QueryDefinition) Type

func (qd QueryDefinition) Type() string

type QueryMatch

type QueryMatch struct {
	Result   interface{}
	Captures QueryCapture
}

A single match.

func NewQueryMatch

func NewQueryMatch(captures QueryCapture, result interface{}) QueryMatch

func (*QueryMatch) Attr

func (q *QueryMatch) Attr(name string) (starlark.Value, error)

func (*QueryMatch) AttrNames

func (q *QueryMatch) AttrNames() []string

func (*QueryMatch) Freeze

func (q *QueryMatch) Freeze()

func (*QueryMatch) Hash

func (q *QueryMatch) Hash() (uint32, error)

func (*QueryMatch) String

func (q *QueryMatch) String() string

func (*QueryMatch) Truth

func (q *QueryMatch) Truth() starlark.Bool

func (*QueryMatch) Type

func (q *QueryMatch) Type() string

type QueryMatches

type QueryMatches []QueryMatch

Multiple matches

func (QueryMatches) Freeze

func (q QueryMatches) Freeze()

func (QueryMatches) Hash

func (q QueryMatches) Hash() (uint32, error)

func (QueryMatches) Index

func (q QueryMatches) Index(i int) starlark.Value

func (QueryMatches) Iterate

func (q QueryMatches) Iterate() starlark.Iterator

func (QueryMatches) Len

func (q QueryMatches) Len() int

func (QueryMatches) String

func (q QueryMatches) String() string

func (QueryMatches) Truth

func (q QueryMatches) Truth() starlark.Bool

func (QueryMatches) Type

func (q QueryMatches) Type() string

type QueryProcessorResult

type QueryProcessorResult struct {
	Result interface{}
	Key    string
}

Intermediate object to hold a query key+result in a single struct.

type QueryResults

type QueryResults map[string]interface{}

TODO: better naming? QueryMapping?

func (QueryResults) Freeze

func (qr QueryResults) Freeze()

func (QueryResults) Get

func (qr QueryResults) Get(k starlark.Value) (v starlark.Value, found bool, err error)

func (QueryResults) Hash

func (qr QueryResults) Hash() (uint32, error)

func (QueryResults) String

func (qr QueryResults) String() string

func (QueryResults) Truth

func (qr QueryResults) Truth() starlark.Bool

func (QueryResults) Type

func (qr QueryResults) Type() string

type QueryType

type QueryType = string

type RegexQueryParams

type RegexQueryParams = string

type RemoveTargetAction

type RemoveTargetAction struct {
	TargetAction
	Name string
	Kind string
}

type RuleKind

type RuleKind struct {
	KindInfo
	Name string
	From string
}

type SourceExtensionsFilter

type SourceExtensionsFilter struct {
	Extensions []string
}

func (SourceExtensionsFilter) Attr

func (SourceExtensionsFilter) AttrNames

func (r SourceExtensionsFilter) AttrNames() []string

func (SourceExtensionsFilter) Freeze

func (r SourceExtensionsFilter) Freeze()

func (SourceExtensionsFilter) Hash

func (r SourceExtensionsFilter) Hash() (uint32, error)

func (SourceExtensionsFilter) Match

func (f SourceExtensionsFilter) Match(p string) bool

func (SourceExtensionsFilter) String

func (r SourceExtensionsFilter) String() string

func (SourceExtensionsFilter) Truth

func (SourceExtensionsFilter) Type

func (r SourceExtensionsFilter) Type() string

type SourceFileFilter

type SourceFileFilter struct {
	Files []string
}

func (SourceFileFilter) Attr

func (r SourceFileFilter) Attr(name string) (starlark.Value, error)

func (SourceFileFilter) AttrNames

func (r SourceFileFilter) AttrNames() []string

func (SourceFileFilter) Freeze

func (r SourceFileFilter) Freeze()

func (SourceFileFilter) Hash

func (r SourceFileFilter) Hash() (uint32, error)

func (SourceFileFilter) Match

func (sf SourceFileFilter) Match(p string) bool

func (SourceFileFilter) String

func (r SourceFileFilter) String() string

func (SourceFileFilter) Truth

func (r SourceFileFilter) Truth() starlark.Bool

func (SourceFileFilter) Type

func (r SourceFileFilter) Type() string

type SourceFilter

type SourceFilter interface {
	Match(p string) bool
}

type SourceGlobFilter

type SourceGlobFilter struct {
	Globs []string
}

func (SourceGlobFilter) Attr

func (r SourceGlobFilter) Attr(name string) (starlark.Value, error)

func (SourceGlobFilter) AttrNames

func (r SourceGlobFilter) AttrNames() []string

func (SourceGlobFilter) Freeze

func (r SourceGlobFilter) Freeze()

func (SourceGlobFilter) Hash

func (r SourceGlobFilter) Hash() (uint32, error)

func (SourceGlobFilter) Match

func (f SourceGlobFilter) Match(p string) bool

func (SourceGlobFilter) String

func (r SourceGlobFilter) String() string

func (SourceGlobFilter) Truth

func (r SourceGlobFilter) Truth() starlark.Bool

func (SourceGlobFilter) Type

func (r SourceGlobFilter) Type() string

type Symbol

type Symbol struct {
	Id       string // The unique id of the symbol
	Provider string // The provider type of the symbol
}

func (Symbol) Attr

func (s Symbol) Attr(name string) (starlark.Value, error)

func (Symbol) AttrNames

func (s Symbol) AttrNames() []string

func (Symbol) Freeze

func (s Symbol) Freeze()

func (Symbol) Hash

func (s Symbol) Hash() (uint32, error)

func (Symbol) String

func (s Symbol) String() string

func (Symbol) Truth

func (s Symbol) Truth() starlark.Bool

func (Symbol) Type

func (s Symbol) Type() string

type TargetAction

type TargetAction interface{}

type TargetDeclaration

type TargetDeclaration struct {
	Name  string
	Kind  string
	Attrs map[string]interface{}

	// Names (possibly as paths) exported from this target
	Symbols []Symbol
}

*

  • A bazel target declaration describing the target name/type/attributes as
  • well as symbols representing imports and exports of the target.

type TargetImport

type TargetImport struct {
	Symbol

	// Optional imports will not be treated as resolution errors when not found.
	Optional bool

	// Where the import is from such as file path, for debugging
	From string
}

func (TargetImport) Attr

func (ti TargetImport) Attr(name string) (starlark.Value, error)

func (TargetImport) AttrNames

func (ti TargetImport) AttrNames() []string

func (TargetImport) Freeze

func (ti TargetImport) Freeze()

func (TargetImport) Hash

func (ti TargetImport) Hash() (uint32, error)

func (TargetImport) String

func (ti TargetImport) String() string

func (TargetImport) Truth

func (ti TargetImport) Truth() starlark.Bool

func (TargetImport) Type

func (ti TargetImport) Type() string

type TargetSource

type TargetSource struct {
	Path         string
	QueryResults QueryResults
}

func (TargetSource) Attr

func (ctx TargetSource) Attr(name string) (starlark.Value, error)

func (TargetSource) AttrNames

func (ctx TargetSource) AttrNames() []string

func (TargetSource) Freeze

func (TargetSource) Freeze()

func (TargetSource) Hash

func (ts TargetSource) Hash() (uint32, error)

func (TargetSource) String

func (ts TargetSource) String() string

func (TargetSource) Truth

func (TargetSource) Truth() starlark.Bool

func (TargetSource) Type

func (TargetSource) Type() string

type TargetSourceList

type TargetSourceList []TargetSource

func (TargetSourceList) Freeze

func (t TargetSourceList) Freeze()

func (TargetSourceList) Hash

func (t TargetSourceList) Hash() (uint32, error)

func (TargetSourceList) Index

func (t TargetSourceList) Index(i int) starlark.Value

func (TargetSourceList) Iterate

func (t TargetSourceList) Iterate() starlark.Iterator

func (TargetSourceList) Len

func (t TargetSourceList) Len() int

func (TargetSourceList) String

func (t TargetSourceList) String() string

func (TargetSourceList) Truth

func (t TargetSourceList) Truth() starlark.Bool

func (TargetSourceList) Type

func (t TargetSourceList) Type() string

type TargetSources

type TargetSources map[string]TargetSourceList

func (TargetSources) Attr

func (c TargetSources) Attr(name string) (starlark.Value, error)

func (TargetSources) AttrNames

func (c TargetSources) AttrNames() []string

func (TargetSources) Freeze

func (c TargetSources) Freeze()

func (TargetSources) Hash

func (c TargetSources) Hash() (uint32, error)

func (TargetSources) Index

func (ts TargetSources) Index(i int) starlark.Value

func (TargetSources) Iterate

func (ts TargetSources) Iterate() starlark.Iterator

func (TargetSources) Len

func (ts TargetSources) Len() int

func (TargetSources) String

func (c TargetSources) String() string

func (TargetSources) Truth

func (c TargetSources) Truth() starlark.Bool

func (TargetSources) Type

func (c TargetSources) Type() string

type TargetSymbol

type TargetSymbol struct {
	Symbol

	// The label producing the symbol
	Label Label
}

func (TargetSymbol) Attr

func (te TargetSymbol) Attr(name string) (starlark.Value, error)

func (TargetSymbol) AttrNames

func (te TargetSymbol) AttrNames() []string

func (TargetSymbol) Freeze

func (te TargetSymbol) Freeze()

func (TargetSymbol) Hash

func (te TargetSymbol) Hash() (uint32, error)

func (TargetSymbol) String

func (te TargetSymbol) String() string

func (TargetSymbol) Truth

func (te TargetSymbol) Truth() starlark.Bool

func (TargetSymbol) Type

func (te TargetSymbol) Type() string

type YamlQueryParams

type YamlQueryParams = string

Jump to

Keyboard shortcuts

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