uast

package
v8.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2019 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConfigUASTEndpoint is the name of the configuration option (Extractor.Configure())
	// which sets the Babelfish server address.
	ConfigUASTEndpoint = "ConfigUASTEndpoint"
	// ConfigUASTTimeout is the name of the configuration option (Extractor.Configure())
	// which sets the maximum amount of time to wait for a Babelfish server response.
	ConfigUASTTimeout = "ConfigUASTTimeout"
	// ConfigUASTPoolSize is the name of the configuration option (Extractor.Configure())
	// which sets the number of goroutines to run for UAST parse queries.
	ConfigUASTPoolSize = "ConfigUASTPoolSize"
	// ConfigUASTFailOnErrors is the name of the configuration option (Extractor.Configure())
	// which enables early exit in case of any Babelfish UAST parsing errors.
	ConfigUASTFailOnErrors = "ConfigUASTFailOnErrors"
	// FeatureUast is the name of the Pipeline feature which activates all the items related to UAST.
	FeatureUast = "uast"
	// DependencyUasts is the name of the dependency provided by Extractor.
	DependencyUasts = "uasts"
)
View Source
const (
	// ConfigUASTChangesSaverOutputPath is the name of the configuration option
	// (ChangesSaver.Configure()) which sets the target directory where to save the files.
	ConfigUASTChangesSaverOutputPath = "ChangesSaver.OutputPath"
)
View Source
const (
	// DependencyUastChanges is the name of the dependency provided by Changes.
	DependencyUastChanges = "changed_uasts"
)

Variables

This section is empty.

Functions

func VisitEachNode

func VisitEachNode(root nodes.Node, payload func(nodes.Node))

VisitEachNode is a handy routine to execute a callback on every node in the subtree, including the root itself. Depth first tree traversal.

Types

type Change

type Change struct {
	Before nodes.Node
	After  nodes.Node
	Change *object.Change
}

Change is the type of the items in the list of changes which is provided by Changes.

type Changes

type Changes struct {
	core.NoopMerger
	// contains filtered or unexported fields
}

Changes is a structured analog of TreeDiff: it provides UASTs for every logical change in a commit. It is a PipelineItem.

func (*Changes) Configure

func (uc *Changes) Configure(facts map[string]interface{}) error

Configure sets the properties previously published by ListConfigurationOptions().

func (*Changes) Consume

func (uc *Changes) Consume(deps map[string]interface{}) (map[string]interface{}, error)

Consume runs this PipelineItem on the next commit data. `deps` contain all the results from upstream PipelineItem-s as requested by Requires(). Additionally, DependencyCommit is always present there and represents the analysed *object.Commit. This function returns the mapping with analysis results. The keys must be the same as in Provides(). If there was an error, nil is returned.

func (*Changes) Features

func (uc *Changes) Features() []string

Features which must be enabled for this PipelineItem to be automatically inserted into the DAG.

func (*Changes) Fork

func (uc *Changes) Fork(n int) []core.PipelineItem

Fork clones this PipelineItem.

func (*Changes) Initialize

func (uc *Changes) Initialize(repository *git.Repository) error

Initialize resets the temporary caches and prepares this PipelineItem for a series of Consume() calls. The repository which is going to be analysed is supplied as an argument.

func (*Changes) ListConfigurationOptions

func (uc *Changes) ListConfigurationOptions() []core.ConfigurationOption

ListConfigurationOptions returns the list of changeable public properties of this PipelineItem.

func (*Changes) Name

func (uc *Changes) Name() string

Name of this PipelineItem. Uniquely identifies the type, used for mapping keys, etc.

func (*Changes) Provides

func (uc *Changes) Provides() []string

Provides returns the list of names of entities which are produced by this PipelineItem. Each produced entity will be inserted into `deps` of dependent Consume()-s according to this list. Also used by core.Registry to build the global map of providers.

func (*Changes) Requires

func (uc *Changes) Requires() []string

Requires returns the list of names of entities which are needed by this PipelineItem. Each requested entity will be inserted into `deps` of Consume(). In turn, those entities are Provides() upstream.

type ChangesSaver

type ChangesSaver struct {
	core.NoopMerger
	core.OneShotMergeProcessor
	// OutputPath points to the target directory with UASTs
	OutputPath string
	// contains filtered or unexported fields
}

ChangesSaver dumps changed files and corresponding UASTs for every commit. it is a LeafPipelineItem.

func (*ChangesSaver) Configure

func (saver *ChangesSaver) Configure(facts map[string]interface{}) error

Configure sets the properties previously published by ListConfigurationOptions().

func (*ChangesSaver) Consume

func (saver *ChangesSaver) Consume(deps map[string]interface{}) (map[string]interface{}, error)

Consume runs this PipelineItem on the next commit data. `deps` contain all the results from upstream PipelineItem-s as requested by Requires(). Additionally, DependencyCommit is always present there and represents the analysed *object.Commit. This function returns the mapping with analysis results. The keys must be the same as in Provides(). If there was an error, nil is returned.

func (*ChangesSaver) Description

func (saver *ChangesSaver) Description() string

Description returns the text which explains what the analysis is doing.

func (*ChangesSaver) Features

func (saver *ChangesSaver) Features() []string

Features which must be enabled for this PipelineItem to be automatically inserted into the DAG.

func (*ChangesSaver) Finalize

func (saver *ChangesSaver) Finalize() interface{}

Finalize returns the result of the analysis. Further Consume() calls are not expected.

func (*ChangesSaver) Flag

func (saver *ChangesSaver) Flag() string

Flag for the command line switch which enables this analysis.

func (*ChangesSaver) Fork

func (saver *ChangesSaver) Fork(n int) []core.PipelineItem

Fork clones this PipelineItem.

func (*ChangesSaver) Initialize

func (saver *ChangesSaver) Initialize(repository *git.Repository) error

Initialize resets the temporary caches and prepares this PipelineItem for a series of Consume() calls. The repository which is going to be analysed is supplied as an argument.

func (*ChangesSaver) ListConfigurationOptions

func (saver *ChangesSaver) ListConfigurationOptions() []core.ConfigurationOption

ListConfigurationOptions returns the list of changeable public properties of this PipelineItem.

func (*ChangesSaver) Name

func (saver *ChangesSaver) Name() string

Name of this PipelineItem. Uniquely identifies the type, used for mapping keys, etc.

func (*ChangesSaver) Provides

func (saver *ChangesSaver) Provides() []string

Provides returns the list of names of entities which are produced by this PipelineItem. Each produced entity will be inserted into `deps` of dependent Consume()-s according to this list. Also used by core.Registry to build the global map of providers.

func (*ChangesSaver) Requires

func (saver *ChangesSaver) Requires() []string

Requires returns the list of names of entities which are needed by this PipelineItem. Each requested entity will be inserted into `deps` of Consume(). In turn, those entities are Provides() upstream.

func (*ChangesSaver) Serialize

func (saver *ChangesSaver) Serialize(result interface{}, binary bool, writer io.Writer) error

Serialize converts the analysis result as returned by Finalize() to text or bytes. The text format is YAML and the bytes format is Protocol Buffers.

type ChangesXPather

type ChangesXPather struct {
	XPath string
}

ChangesXPather extracts changed UAST nodes from files changed in the current commit.

func (ChangesXPather) Extract

func (xpather ChangesXPather) Extract(changes []Change) []nodes.Node

Extract returns the list of new or changed UAST nodes filtered by XPath.

type Extractor

type Extractor struct {
	core.NoopMerger
	Endpoint       string
	Context        func() (context.Context, context.CancelFunc)
	PoolSize       int
	FailOnErrors   bool
	ProcessedFiles map[string]int
	// contains filtered or unexported fields
}

Extractor retrieves UASTs from Babelfish server which correspond to changed files in a commit. It is a PipelineItem.

func (*Extractor) Configure

func (exr *Extractor) Configure(facts map[string]interface{}) error

Configure sets the properties previously published by ListConfigurationOptions().

func (*Extractor) Consume

func (exr *Extractor) Consume(deps map[string]interface{}) (map[string]interface{}, error)

Consume runs this PipelineItem on the next commit data. `deps` contain all the results from upstream PipelineItem-s as requested by Requires(). Additionally, DependencyCommit is always present there and represents the analysed *object.Commit. This function returns the mapping with analysis results. The keys must be the same as in Provides(). If there was an error, nil is returned.

func (*Extractor) Features

func (exr *Extractor) Features() []string

Features which must be enabled for this PipelineItem to be automatically inserted into the DAG.

func (*Extractor) Fork

func (exr *Extractor) Fork(n int) []core.PipelineItem

Fork clones this PipelineItem.

func (*Extractor) Initialize

func (exr *Extractor) Initialize(repository *git.Repository) error

Initialize resets the temporary caches and prepares this PipelineItem for a series of Consume() calls. The repository which is going to be analysed is supplied as an argument.

func (*Extractor) ListConfigurationOptions

func (exr *Extractor) ListConfigurationOptions() []core.ConfigurationOption

ListConfigurationOptions returns the list of changeable public properties of this PipelineItem.

func (*Extractor) Name

func (exr *Extractor) Name() string

Name of this PipelineItem. Uniquely identifies the type, used for mapping keys, etc.

func (*Extractor) Provides

func (exr *Extractor) Provides() []string

Provides returns the list of names of entities which are produced by this PipelineItem. Each produced entity will be inserted into `deps` of dependent Consume()-s according to this list. Also used by core.Registry to build the global map of providers.

func (*Extractor) Requires

func (exr *Extractor) Requires() []string

Requires returns the list of names of entities which are needed by this PipelineItem. Each requested entity will be inserted into `deps` of Consume(). In turn, those entities are Provides() upstream.

type FileDiffRefiner

type FileDiffRefiner struct {
	core.NoopMerger
}

FileDiffRefiner uses UASTs to improve the human interpretability of diffs. It is a PipelineItem. The idea behind this algorithm is simple: in case of multiple choices which are equally optimal, choose the one which touches less AST nodes.

func (*FileDiffRefiner) Configure

func (ref *FileDiffRefiner) Configure(facts map[string]interface{}) error

Configure sets the properties previously published by ListConfigurationOptions().

func (*FileDiffRefiner) Consume

func (ref *FileDiffRefiner) Consume(deps map[string]interface{}) (map[string]interface{}, error)

Consume runs this PipelineItem on the next commit data. `deps` contain all the results from upstream PipelineItem-s as requested by Requires(). Additionally, DependencyCommit is always present there and represents the analysed *object.Commit. This function returns the mapping with analysis results. The keys must be the same as in Provides(). If there was an error, nil is returned.

func (*FileDiffRefiner) Features

func (ref *FileDiffRefiner) Features() []string

Features which must be enabled for this PipelineItem to be automatically inserted into the DAG.

func (*FileDiffRefiner) Fork

func (ref *FileDiffRefiner) Fork(n int) []core.PipelineItem

Fork clones this PipelineItem.

func (*FileDiffRefiner) Initialize

func (ref *FileDiffRefiner) Initialize(repository *git.Repository) error

Initialize resets the temporary caches and prepares this PipelineItem for a series of Consume() calls. The repository which is going to be analysed is supplied as an argument.

func (*FileDiffRefiner) ListConfigurationOptions

func (ref *FileDiffRefiner) ListConfigurationOptions() []core.ConfigurationOption

ListConfigurationOptions returns the list of changeable public properties of this PipelineItem.

func (*FileDiffRefiner) Name

func (ref *FileDiffRefiner) Name() string

Name of this PipelineItem. Uniquely identifies the type, used for mapping keys, etc.

func (*FileDiffRefiner) Provides

func (ref *FileDiffRefiner) Provides() []string

Provides returns the list of names of entities which are produced by this PipelineItem. Each produced entity will be inserted into `deps` of dependent Consume()-s according to this list. Also used by core.Registry to build the global map of providers.

func (*FileDiffRefiner) Requires

func (ref *FileDiffRefiner) Requires() []string

Requires returns the list of names of entities which are needed by this PipelineItem. Each requested entity will be inserted into `deps` of Consume(). In turn, those entities are Provides() upstream.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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