go-client: github.com/bblfsh/go-client Index | Files | Directories

package bblfsh

import "github.com/bblfsh/go-client"

Babelfish (https://doc.bblf.sh) Go client library provides functionality to both connect to the bblfsh daemon to parse code (obtaining an UAST as a result) and to analyse UASTs with the functionality provided by libuast.

Index

Package Files

client.go doc.go request.go

Constants

const (
    Native    = protocol2.Mode_Native
    Annotated = protocol2.Mode_Annotated
    Semantic  = protocol2.Mode_Semantic
)

Variables

var (
    // ErrDriverFailure is returned when the driver is malfunctioning.
    ErrDriverFailure = derrors.ErrDriverFailure

    // ErrSyntax is returned when driver cannot parse the source file.
    // Can be omitted for native driver implementations.
    ErrSyntax = derrors.ErrSyntax
)

type Client Uses

type Client struct {
    *grpc.ClientConn
    // contains filtered or unexported fields
}

Client holds the public client API to interact with the bblfsh daemon.

func NewClient Uses

func NewClient(endpoint string, options ...grpc.DialOption) (*Client, error)

NewClient is the same as NewClientContext, but assumes a default timeout for the connection.

Deprecated: use NewClientContext instead

func NewClientContext Uses

func NewClientContext(ctx context.Context, endpoint string, options ...grpc.DialOption) (*Client, error)

NewClientContext returns a new bblfsh client given a bblfshd endpoint.

func NewClientWithConnection Uses

func NewClientWithConnection(conn *grpc.ClientConn) (*Client, error)

NewClientWithConnection returns a new bblfsh client given a grpc connection.

func NewClientWithConnectionContext Uses

func NewClientWithConnectionContext(ctx context.Context, conn *grpc.ClientConn) (*Client, error)

NewClientWithConnectionContext returns a new bblfsh client given a grpc connection.

func (*Client) NewParseRequest Uses

func (c *Client) NewParseRequest() *ParseRequest

NewParseRequest is a parsing request to get the UAST.

func (*Client) NewSupportedLanguagesRequest Uses

func (c *Client) NewSupportedLanguagesRequest() *SupportedLanguagesRequest

NewSupportedLanguagesRequest is a parsing request to get the supported languages.

func (*Client) NewVersionRequest Uses

func (c *Client) NewVersionRequest() *VersionRequest

NewVersionRequest is a parsing request to get the version of the server.

type DriverManifest Uses

type DriverManifest = protocol1.DriverManifest

DriverManifest contains an information about a single Babelfish driver.

Deprecated: see DoV2.

type DriverManifestV2 Uses

type DriverManifestV2 = manifest.Manifest

DriverManifestV2 contains an information about a single Babelfish driver.

type Mode Uses

type Mode = protocol2.Mode

Mode controls the level of transformation applied to UAST.

func ParseMode Uses

func ParseMode(mode string) (Mode, error)

Parse mode parses a UAST mode string to an enum value.

type Node Uses

type Node = nodes.Node

Node is a generic UAST node.

type ParseRequest Uses

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

ParseRequest is a parsing request to get the UAST.

func (*ParseRequest) Content Uses

func (r *ParseRequest) Content(content string) *ParseRequest

Content sets the content of the parse request. It should be the source code that wants to be parsed.

func (*ParseRequest) Context Uses

func (r *ParseRequest) Context(ctx context.Context) *ParseRequest

Context sets a cancellation context for this request.

func (*ParseRequest) Do Uses

func (r *ParseRequest) Do() (*protocol2.ParseResponse, error)

Do performs the actual parsing by serializing the request, sending it to bblfshd and waiting for the response.

It's the caller's responsibility to interpret errors properly.

Deprecated: use UAST() instead

func (*ParseRequest) Filename Uses

func (r *ParseRequest) Filename(filename string) *ParseRequest

Filename sets the filename of the content.

func (*ParseRequest) Language Uses

func (r *ParseRequest) Language(language string) *ParseRequest

Language sets the language of the given source file to parse. if missing will be guess from the filename and the content.

func (*ParseRequest) Mode Uses

func (r *ParseRequest) Mode(mode Mode) *ParseRequest

Mode controls the level of transformation applied to UAST.

func (*ParseRequest) ReadFile Uses

func (r *ParseRequest) ReadFile(fp string) *ParseRequest

ReadFile loads a file given a local path and sets the content and the filename of the request.

func (*ParseRequest) UAST Uses

func (r *ParseRequest) UAST() (Node, string, error)

UAST send the request and returns decoded UAST and the language.

If a file contains syntax error, the ErrSyntax is returned and the UAST may be nil or partial in this case.

ErrDriverFailure is returned if the native driver is malfunctioning.

type SupportedLanguagesRequest Uses

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

SupportedLanguagesRequest is a request to retrieve the supported languages.

func (*SupportedLanguagesRequest) Context Uses

func (r *SupportedLanguagesRequest) Context(ctx context.Context) *SupportedLanguagesRequest

Context sets a cancellation context for this request.

func (*SupportedLanguagesRequest) Do Uses

func (r *SupportedLanguagesRequest) Do() ([]DriverManifest, error)

Do performs the supported languages request and return information about available drivers.

Deprecated: use DoV2 instead.

func (*SupportedLanguagesRequest) DoV2 Uses

func (r *SupportedLanguagesRequest) DoV2() ([]DriverManifestV2, error)

DoV2 performs the supported languages request and return information about available drivers.

type VersionRequest Uses

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

VersionRequest is a request to retrieve the version of the server.

func (*VersionRequest) Context Uses

func (r *VersionRequest) Context(ctx context.Context) *VersionRequest

Context sets a cancellation context for this request.

func (*VersionRequest) Do Uses

func (r *VersionRequest) Do() (*VersionResponse, error)

Do performs the actual parsing by serializing the request, sending it to bblfsd and waiting for the response.

type VersionResponse Uses

type VersionResponse struct {
    // Version is the server version. If is a local compilation the version
    // follows the pattern dev-<short-commit>[-dirty], dirty means that was
    // compile from a repository with un-committed changes.
    Version string `json:"version"`
    // Build contains the timestamp at the time of the build.
    Build time.Time `json:"build"`
}

VersionResponse contains information about Babelfish version.

Directories

PathSynopsis
tools

Package bblfsh imports 15 packages (graph). Updated 2019-07-11. Refresh now. Tools for package owners.