hercules.v9: gopkg.in/src-d/hercules.v9/internal/plumbing/uast Index | Files | Directories

package uast

import "gopkg.in/src-d/hercules.v9/internal/plumbing/uast"

Index

Package Files

changes_xpather.go diff_refiner.go uast.go

Constants

const (
    // ConfigUASTEndpoint is the name of the configuration option (Extractor.Configure())
    // which sets the Babelfish server address.
    ConfigUASTEndpoint = "UAST.Endpoint"
    // 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 = "UAST.Timeout"
    // ConfigUASTPoolSize is the name of the configuration option (Extractor.Configure())
    // which sets the number of goroutines to run for UAST parse queries.
    ConfigUASTPoolSize = "UAST.PoolSize"
    // ConfigUASTFailOnErrors is the name of the configuration option (Extractor.Configure())
    // which enables early exit in case of any Babelfish UAST parsing errors.
    ConfigUASTFailOnErrors = "UAST.FailOnErrors"
    // ConfigUASTIgnoreMissingDrivers is the name of the configuration option (Extractor.Configure())
    // which sets the ignored missing driver names.
    ConfigUASTIgnoreMissingDrivers = "UAST.IgnoreMissingDrivers"
    // DefaultBabelfishEndpoint is the default address of the Babelfish parsing server.
    DefaultBabelfishEndpoint = "0.0.0.0:9432"
    // DefaultBabelfishTimeout is the default value of the RPC timeout in seconds.
    DefaultBabelfishTimeout = 20
    // 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"
)
const (
    // ConfigUASTChangesSaverOutputPath is the name of the configuration option
    // (ChangesSaver.Configure()) which sets the target directory where to save the files.
    ConfigUASTChangesSaverOutputPath = "ChangesSaver.OutputPath"
)
const (
    // DependencyUastChanges is the name of the dependency provided by Changes.
    DependencyUastChanges = "changed_uasts"
)

Variables

var (
    // DefaultBabelfishWorkers is the default number of parsing RPC goroutines.
    DefaultBabelfishWorkers = runtime.NumCPU() * 2
    // DefaultIgnoredMissingDrivers is the languages which are ignored if the Babelfish driver is missing.
    DefaultIgnoredMissingDrivers = []string{"markdown", "text", "yaml", "json"}
)

func VisitEachNode Uses

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.

type Change Uses

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 Uses

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 Uses

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

Configure sets the properties previously published by ListConfigurationOptions().

func (*Changes) Consume Uses

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) Fork Uses

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

Fork clones this PipelineItem.

func (*Changes) Initialize Uses

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 Uses

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

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

func (*Changes) Name Uses

func (uc *Changes) Name() string

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

func (*Changes) Provides Uses

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 Uses

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 Uses

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 Uses

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

Configure sets the properties previously published by ListConfigurationOptions().

func (*ChangesSaver) Consume Uses

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 Uses

func (saver *ChangesSaver) Description() string

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

func (*ChangesSaver) Finalize Uses

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

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

func (*ChangesSaver) Flag Uses

func (saver *ChangesSaver) Flag() string

Flag for the command line switch which enables this analysis.

func (*ChangesSaver) Fork Uses

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

Fork clones this PipelineItem.

func (*ChangesSaver) Initialize Uses

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 Uses

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

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

func (*ChangesSaver) Name Uses

func (saver *ChangesSaver) Name() string

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

func (*ChangesSaver) Provides Uses

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 Uses

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 Uses

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 Uses

type ChangesXPather struct {
    XPath string
}

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

func (ChangesXPather) Extract Uses

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

Extract returns the list of (inserted, removed) UAST nodes filtered by XPath.

type Extractor Uses

type Extractor struct {
    core.NoopMerger
    Endpoint              string
    Context               func() (context.Context, context.CancelFunc)
    PoolSize              int
    FailOnErrors          bool
    ProcessedFiles        map[string]int
    IgnoredMissingDrivers map[string]bool
    // 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 Uses

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

Configure sets the properties previously published by ListConfigurationOptions().

func (*Extractor) Consume Uses

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 Uses

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

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

func (*Extractor) Fork Uses

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

Fork clones this PipelineItem.

func (*Extractor) Initialize Uses

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 Uses

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

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

func (*Extractor) Name Uses

func (exr *Extractor) Name() string

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

func (*Extractor) Provides Uses

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 Uses

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 Uses

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 Uses

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

Configure sets the properties previously published by ListConfigurationOptions().

func (*FileDiffRefiner) Consume Uses

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 Uses

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

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

func (*FileDiffRefiner) Fork Uses

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

Fork clones this PipelineItem.

func (*FileDiffRefiner) Initialize Uses

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 Uses

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

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

func (*FileDiffRefiner) Name Uses

func (ref *FileDiffRefiner) Name() string

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

func (*FileDiffRefiner) Provides Uses

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 Uses

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

PathSynopsis
test

Package uast imports 31 packages (graph) and is imported by 3 packages. Updated 2019-04-26. Refresh now. Tools for package owners.