Documentation ¶
Overview ¶
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 ¶
- Constants
- Variables
- type Client
- func NewClient(endpoint string) (*Client, error)deprecated
- func NewClientContext(ctx context.Context, endpoint string) (*Client, error)
- func NewClientWithConnection(conn *grpc.ClientConn) (*Client, error)
- func NewClientWithConnectionContext(ctx context.Context, conn *grpc.ClientConn) (*Client, error)
- type DriverManifestdeprecated
- type DriverManifestV2
- type Mode
- type Node
- type ParseRequest
- func (r *ParseRequest) Content(content string) *ParseRequest
- func (r *ParseRequest) Context(ctx context.Context) *ParseRequest
- func (r *ParseRequest) Do() (*protocol2.ParseResponse, error)deprecated
- func (r *ParseRequest) Filename(filename string) *ParseRequest
- func (r *ParseRequest) Language(language string) *ParseRequest
- func (r *ParseRequest) Mode(mode Mode) *ParseRequest
- func (r *ParseRequest) ReadFile(fp string) *ParseRequest
- func (r *ParseRequest) UAST() (Node, string, error)
- type SupportedLanguagesRequest
- type VersionRequest
- type VersionResponse
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 )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { *grpc.ClientConn // contains filtered or unexported fields }
Client holds the public client API to interact with the bblfsh daemon.
func NewClientContext ¶
NewClientContext returns a new bblfsh client given a bblfshd endpoint.
func NewClientWithConnection ¶
func NewClientWithConnection(conn *grpc.ClientConn) (*Client, error)
NewClientWithConnection returns a new bblfsh client given a grpc connection.
func NewClientWithConnectionContext ¶ added in v4.1.0
NewClientWithConnectionContext returns a new bblfsh client given a grpc connection.
func (*Client) NewParseRequest ¶
func (c *Client) NewParseRequest() *ParseRequest
NewParseRequest is a parsing request to get the UAST.
func (*Client) NewSupportedLanguagesRequest ¶
func (c *Client) NewSupportedLanguagesRequest() *SupportedLanguagesRequest
NewSupportedLanguagesRequest is a parsing request to get the supported languages.
func (*Client) NewVersionRequest ¶
func (c *Client) NewVersionRequest() *VersionRequest
NewVersionRequest is a parsing request to get the version of the server.
type DriverManifest
deprecated
type DriverManifest = protocol1.DriverManifest
DriverManifest contains an information about a single Babelfish driver.
Deprecated: see DoV2.
type DriverManifestV2 ¶ added in v4.1.0
DriverManifestV2 contains an information about a single Babelfish driver.
type ParseRequest ¶
type ParseRequest struct {
// contains filtered or unexported fields
}
ParseRequest is a parsing request to get the UAST.
func (*ParseRequest) Content ¶
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 ¶
func (r *ParseRequest) Context(ctx context.Context) *ParseRequest
Context sets a cancellation context for this request.
func (*ParseRequest) Do
deprecated
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 ¶
func (r *ParseRequest) Filename(filename string) *ParseRequest
Filename sets the filename of the content.
func (*ParseRequest) Language ¶
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 ¶
func (r *ParseRequest) Mode(mode Mode) *ParseRequest
Mode controls the level of transformation applied to UAST.
func (*ParseRequest) ReadFile ¶
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 ¶
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 ¶
type SupportedLanguagesRequest struct {
// contains filtered or unexported fields
}
SupportedLanguagesRequest is a request to retrieve the supported languages.
func (*SupportedLanguagesRequest) Context ¶
func (r *SupportedLanguagesRequest) Context(ctx context.Context) *SupportedLanguagesRequest
Context sets a cancellation context for this request.
func (*SupportedLanguagesRequest) Do
deprecated
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 ¶ added in v4.1.0
func (r *SupportedLanguagesRequest) DoV2() ([]DriverManifestV2, error)
DoV2 performs the supported languages request and return information about available drivers.
type VersionRequest ¶
type VersionRequest struct {
// contains filtered or unexported fields
}
VersionRequest is a request to retrieve the version of the server.
func (*VersionRequest) Context ¶
func (r *VersionRequest) Context(ctx context.Context) *VersionRequest
Context sets a cancellation context for this request.
func (*VersionRequest) Do ¶
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 ¶
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.