driver

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2017 License: GPL-3.0 Imports: 17 Imported by: 6

Documentation

Overview

Package driver contains all the logic to build a driver.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DriverBinary default location of the driver binary. Should not
	// override this variable unless you know what are you doing.
	DriverBinary = "/opt/driver/bin/driver"
	// NativeBinary default location of the native driver binary. Should not
	// override this variable unless you know what are you doing.
	NativeBinary = "/opt/driver/bin/native"
	// ManifestLocation location of the manifest file. Should not override
	// this variable unless you know what are you doing.
	ManifestLocation = "/opt/driver/etc/" + manifest.Filename
)
View Source
var (
	ErrUnsupportedLanguage = errors.NewKind("unsupported language got %q, expected %q")
	ErrNativeNotRunning    = errors.NewKind("native driver is not running")
)
View Source
var ErrInvalidLogger = errors.NewKind("invalid logger configuration")

Functions

This section is empty.

Types

type Driver

type Driver struct {
	NativeDriver
	// contains filtered or unexported fields
}

Driver implements a bblfsh driver, a driver is on charge of transforming a source code into an AST and a UAST. To transform the AST into a UAST, a `uast.ObjectToNode“ and a series of `tranformer.Transformer` are used.

The `Parse` and `NativeParse` requests block the driver until the request is done, since the communication with the native driver is a single-channel synchronous communication over stdin/stdout.

func NewDriver

func NewDriver(o *uast.ObjectToNode, t []transformer.Tranformer) (*Driver, error)

NewDriver returns a new Driver instance based on the given ObjectToNode and list of transformers.

func (*Driver) NativeParse

NativeParse sends a request to the native driver and returns its response.

func (*Driver) Parse

Parse process a protocol.ParseRequest, calling to the native driver. It a parser request is done to the internal native driver and the the returned native AST is transform to UAST.

func (*Driver) Version

Version handles a VersionRequest including information from the manifest.

type Encoding

type Encoding protocol.Encoding

func (Encoding) MarshalJSON

func (e Encoding) MarshalJSON() ([]byte, error)

func (*Encoding) UnmarshalJSON

func (e *Encoding) UnmarshalJSON(data []byte) error

type InternalParseRequest

type InternalParseRequest struct {
	Content  string   `json:"content"`
	Encoding Encoding `json:"encoding"`
}

InternalParseRequest is the request used to communicate the driver with the native driver via json.

type InternalParseResponse

type InternalParseResponse struct {
	Status Status      `json:"status"`
	Errors []string    `json:"errors"`
	AST    interface{} `json:"ast"`
}

InternalParseResponse is the reply to InternalParseRequest by the native parser.

type NativeDriver

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

NativeDriver is a wrapper of the native command. The operations with the driver are synchronous by design, this is controlled by a mutex. This means that only one parse request can attend at the same time.

func (*NativeDriver) Parse

Parse sends a request to the native driver and returns its response.

func (*NativeDriver) Start

func (d *NativeDriver) Start() error

Start executes the given native driver and prepares it to parse code.

func (*NativeDriver) Stop

func (d *NativeDriver) Stop() error

Stop stops the execution of the native driver.

type Server

type Server struct {
	server.Server
	// Logger a logger to be used by the server.
	Logger server.Logger
	// contains filtered or unexported fields
}

Server is a grpc server for the communication with the driver.

func NewServer

func NewServer(d *Driver) *Server

NewServer returns a new server for a given Driver.

func (*Server) Start

func (s *Server) Start() error

Start executes the binary driver and start to listen in the network and address defined by the args.

type Status

type Status protocol.Status

func (Status) MarshalJSON

func (s Status) MarshalJSON() ([]byte, error)

func (*Status) UnmarshalJSON

func (s *Status) UnmarshalJSON(data []byte) error

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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