Documentation
¶
Overview ¶
Babelfish (https://doc.bblf.sh) Go client library provides functionality to both connect to the Babelfish server to parse code (obtaining an UAST as a result) and to analyse UASTs with the functionality provided by libuast.
Index ¶
- func Filter(node *uast.Node, xpath string) ([]*uast.Node, error)
- type BblfshClient
- type ParseRequest
- func (req *ParseRequest) Content(content string) *ParseRequest
- func (req *ParseRequest) Do() (*protocol.ParseResponse, error)
- func (req *ParseRequest) DoWithContext(ctx context.Context) (*protocol.ParseResponse, error)
- func (req *ParseRequest) Encoding(encoding protocol.Encoding) *ParseRequest
- func (req *ParseRequest) Filename(filename string) *ParseRequest
- func (req *ParseRequest) Language(lan string) *ParseRequest
- func (req *ParseRequest) ReadFile(filepath string) *ParseRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BblfshClient ¶
type BblfshClient struct {
// contains filtered or unexported fields
}
BblfshClient holds the public client API to interact with the babelfish server.
func NewBblfshClient ¶
func NewBblfshClient(endpoint string) (*BblfshClient, error)
NewBblfshClient returns a new babelfish client given a server endpoint
func (*BblfshClient) NewParseRequest ¶
func (c *BblfshClient) NewParseRequest() *ParseRequest
type ParseRequest ¶
type ParseRequest struct {
// contains filtered or unexported fields
}
ParseRequest is a placeholder for the parse requests performed by the library
func (*ParseRequest) Content ¶
func (req *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 (req *ParseRequest) Do() (*protocol.ParseResponse, error)
Do performs the actual parsing by serializaing the request, sending it to the babelfish and waiting for the response (UAST tree).
func (*ParseRequest) DoWithContext ¶
func (req *ParseRequest) DoWithContext(ctx context.Context) (*protocol.ParseResponse, error)
DoWithContext does the same as Do(), but sopporting cancellation by the use of Go contexts.
func (*ParseRequest) Encoding ¶
func (req *ParseRequest) Encoding(encoding protocol.Encoding) *ParseRequest
Encoding sets the text encoding of the content.
func (*ParseRequest) Filename ¶
func (req *ParseRequest) Filename(filename string) *ParseRequest
Filename sets the filename of the content.
func (*ParseRequest) Language ¶
func (req *ParseRequest) Language(lan string) *ParseRequest
Language sets the language of the given source file to parse.
func (*ParseRequest) ReadFile ¶
func (req *ParseRequest) ReadFile(filepath string) *ParseRequest
ReadFile loads a file given a local path and sets the content and the filename of the request.