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
- type Client
- type ErrPartialParsedeprecated
- type FatalError
- type Mode
- type NativeParseRequest
- func (r *NativeParseRequest) Content(content string) *NativeParseRequest
- func (r *NativeParseRequest) Do() (*protocol1.NativeParseResponse, error)
- func (r *NativeParseRequest) DoWithContext(ctx context.Context) (*protocol1.NativeParseResponse, error)
- func (r *NativeParseRequest) Encoding(encoding protocol1.Encoding) *NativeParseRequest
- func (r *NativeParseRequest) Filename(filename string) *NativeParseRequest
- func (r *NativeParseRequest) Language(language string) *NativeParseRequest
- func (r *NativeParseRequest) ReadFile(fp string) *NativeParseRequest
- type ParseRequest
- func (r *ParseRequest) Content(content string) *ParseRequest
- func (r *ParseRequest) Do() (*protocol1.ParseResponse, error)
- func (r *ParseRequest) DoWithContext(ctx context.Context) (*protocol1.ParseResponse, error)
- func (r *ParseRequest) Encoding(encoding protocol1.Encoding) *ParseRequest
- 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() (nodes.Node, string, error)
- func (r *ParseRequest) UASTContext(ctx context.Context) (nodes.Node, string, error)
- type ParseRequestV2
- func (r *ParseRequestV2) Content(content string) *ParseRequestV2
- func (r *ParseRequestV2) Do() (*protocol2.ParseResponse, error)
- func (r *ParseRequestV2) DoContext(ctx context.Context) (*protocol2.ParseResponse, error)
- func (r *ParseRequestV2) Filename(filename string) *ParseRequestV2
- func (r *ParseRequestV2) Language(language string) *ParseRequestV2
- func (r *ParseRequestV2) Mode(mode Mode) *ParseRequestV2
- func (r *ParseRequestV2) ReadFile(fp string) *ParseRequestV2
- func (r *ParseRequestV2) UAST() (nodes.Node, string, error)
- func (r *ParseRequestV2) UASTContext(ctx context.Context) (nodes.Node, string, error)
- type SupportedLanguagesRequest
- type VersionRequest
Constants ¶
const ( Native = protocol2.Mode_Native Annotated = protocol2.Mode_Annotated Semantic = protocol2.Mode_Semantic )
Variables ¶
This section is empty.
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 NewClient ¶
NewClient is the same as NewClientContext, but assumes a default timeout for the connection.
func NewClientContext ¶ added in v2.7.0
NewClientContext returns a new bblfsh client given a bblfshd endpoint.
func NewClientWithConnection ¶ added in v2.2.1
func NewClientWithConnection(conn *grpc.ClientConn) (*Client, error)
NewClientWithConnection returns a new bblfsh client given a grpc connection.
func (*Client) NewNativeParseRequest ¶
func (c *Client) NewNativeParseRequest() *NativeParseRequest
NewNativeParseRequest is a parsing request to get the AST.
func (*Client) NewParseRequest ¶
func (c *Client) NewParseRequest() *ParseRequest
NewParseRequest is a parsing request to get the UAST.
func (*Client) NewParseRequestV2 ¶ added in v2.7.0
func (c *Client) NewParseRequestV2() *ParseRequestV2
NewParseRequestV2 is a parsing request to get the UAST.
func (*Client) NewSupportedLanguagesRequest ¶ added in v2.5.0
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 ErrPartialParse
deprecated
added in
v2.7.0
type ErrPartialParse struct{}
ErrPartialParse is returned when driver was not able to parse the whole source file.
Deprecated: this type is unused
func (ErrPartialParse) Error ¶ added in v2.8.9
func (ErrPartialParse) Error() string
type FatalError ¶ added in v2.6.0
type FatalError []string
FatalError is returned when response is returned with Fatal status code.
func (FatalError) Error ¶ added in v2.6.0
func (e FatalError) Error() string
type NativeParseRequest ¶
type NativeParseRequest struct {
// contains filtered or unexported fields
}
NativeParseRequest is a parsing request to get the AST.
func (*NativeParseRequest) Content ¶
func (r *NativeParseRequest) Content(content string) *NativeParseRequest
Content sets the content of the parse request. It should be the source code that wants to be parsed.
func (*NativeParseRequest) Do ¶
func (r *NativeParseRequest) Do() (*protocol1.NativeParseResponse, error)
Do performs the actual parsing by serializing the request, sending it to bblfsd and waiting for the response.
func (*NativeParseRequest) DoWithContext ¶
func (r *NativeParseRequest) DoWithContext(ctx context.Context) (*protocol1.NativeParseResponse, error)
DoWithContext does the same as Do(), but sopporting cancellation by the use of Go contexts.
func (*NativeParseRequest) Encoding ¶
func (r *NativeParseRequest) Encoding(encoding protocol1.Encoding) *NativeParseRequest
Encoding sets the text encoding of the content.
func (*NativeParseRequest) Filename ¶
func (r *NativeParseRequest) Filename(filename string) *NativeParseRequest
Filename sets the filename of the content.
func (*NativeParseRequest) Language ¶
func (r *NativeParseRequest) Language(language string) *NativeParseRequest
Language sets the language of the given source file to parse. if missing will be guess from the filename and the content.
func (*NativeParseRequest) ReadFile ¶
func (r *NativeParseRequest) ReadFile(fp string) *NativeParseRequest
ReadFile loads a file given a local path and sets the content and the filename of the request.
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) Do ¶
func (r *ParseRequest) Do() (*protocol1.ParseResponse, error)
Do performs the actual parsing by serializing the request, sending it to bblfshd and waiting for the response.
func (*ParseRequest) DoWithContext ¶
func (r *ParseRequest) DoWithContext(ctx context.Context) (*protocol1.ParseResponse, error)
DoWithContext does the same as Do(), but sopporting cancellation by the use of Go contexts.
func (*ParseRequest) Encoding ¶
func (r *ParseRequest) Encoding(encoding protocol1.Encoding) *ParseRequest
Encoding sets the text encoding of the content.
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 ¶ added in v2.8.4
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 ¶ added in v2.8.4
func (r *ParseRequest) UAST() (nodes.Node, string, error)
UAST is the same as UASTContext, but uses context.Background as a context.
func (*ParseRequest) UASTContext ¶ added in v2.8.4
UASTContext send the request and returns decoded UAST and the language. If a file contains syntax error, the ErrPartialParse is returned and will contain a partial AST.
type ParseRequestV2 ¶ added in v2.7.0
type ParseRequestV2 struct {
// contains filtered or unexported fields
}
ParseRequestV2 is a parsing request to get the UAST.
func (*ParseRequestV2) Content ¶ added in v2.7.0
func (r *ParseRequestV2) Content(content string) *ParseRequestV2
Content sets the content of the parse request. It should be the source code that wants to be parsed.
func (*ParseRequestV2) Do ¶ added in v2.7.0
func (r *ParseRequestV2) Do() (*protocol2.ParseResponse, error)
Do performs the actual parsing by serializing the request, sending it to bblfshd and waiting for the response.
func (*ParseRequestV2) DoContext ¶ added in v2.7.0
func (r *ParseRequestV2) DoContext(ctx context.Context) (*protocol2.ParseResponse, error)
DoContext does the same as Do(), but supports cancellation by the use of Go contexts.
func (*ParseRequestV2) Filename ¶ added in v2.7.0
func (r *ParseRequestV2) Filename(filename string) *ParseRequestV2
Filename sets the filename of the content.
func (*ParseRequestV2) Language ¶ added in v2.7.0
func (r *ParseRequestV2) Language(language string) *ParseRequestV2
Language sets the language of the given source file to parse. if missing will be guess from the filename and the content.
func (*ParseRequestV2) Mode ¶ added in v2.8.1
func (r *ParseRequestV2) Mode(mode Mode) *ParseRequestV2
Mode controls the level of transformation applied to UAST.
func (*ParseRequestV2) ReadFile ¶ added in v2.7.0
func (r *ParseRequestV2) ReadFile(fp string) *ParseRequestV2
ReadFile loads a file given a local path and sets the content and the filename of the request.
func (*ParseRequestV2) UAST ¶ added in v2.7.0
func (r *ParseRequestV2) UAST() (nodes.Node, string, error)
UAST is the same as UASTContext, but uses context.Background as a context.
func (*ParseRequestV2) UASTContext ¶ added in v2.7.0
UASTContext send the request and returns decoded UAST and the language. If a file contains syntax error, the ErrPartialParse is returned and will contain a partial AST.
type SupportedLanguagesRequest ¶ added in v2.5.0
type SupportedLanguagesRequest struct {
// contains filtered or unexported fields
}
SupportedLanguagesRequest is a request to retrieve the supported languages.
func (*SupportedLanguagesRequest) Do ¶ added in v2.5.0
func (r *SupportedLanguagesRequest) Do() (*protocol1.SupportedLanguagesResponse, error)
Do performs the actual parsing by serializing the request, sending it to bblfsd and waiting for the response.
func (*SupportedLanguagesRequest) DoWithContext ¶ added in v2.5.0
func (r *SupportedLanguagesRequest) DoWithContext(ctx context.Context) (*protocol1.SupportedLanguagesResponse, error)
DoWithContext does the same as Do(), but sopporting cancellation by the use of Go contexts.
type VersionRequest ¶
type VersionRequest struct {
// contains filtered or unexported fields
}
VersionRequest is a request to retrieve the version of the server.
func (*VersionRequest) Do ¶
func (r *VersionRequest) Do() (*protocol1.VersionResponse, error)
Do performs the actual parsing by serializing the request, sending it to bblfsd and waiting for the response.
func (*VersionRequest) DoWithContext ¶
func (r *VersionRequest) DoWithContext(ctx context.Context) (*protocol1.VersionResponse, error)
DoWithContext does the same as Do(), but sopporting cancellation by the use of Go contexts.