...

Package parse

import "golang.org/x/tools/gopls/integration/parse"
Overview
Index

Overview ▾

Package parse provides functions to parse LSP logs. Fully processed logs are returned by ToRLog().

func FromClient

func FromClient(msg string) bool

FromClient says if the message is from the client

func FromServer

func FromServer(msg string) bool

FromServer says if the message is from the server

func IsNotify

func IsNotify(msg string) bool

IsNotify says if the message is a notification

func Notifs

func Notifs(m string) interface{}

Notifs returns a pointer to a type suitable for Unmarshal

func Requests

func Requests(m string) interface{}

Requests returns a pointer to a type suitable for Unmarshal

func Responses

func Responses(m string) []interface{}

Responses returns a slice of types, one of which should be suitable for Unmarshal

type Direction

Direction is the type of message,

type Direction int
const (
    // Clrequest from client to server has method and id
    Clrequest Direction = iota
    // Clresponse from server to client
    Clresponse
    // Svrequest from server to client, has method and id
    Svrequest
    // Svresponse from client to server
    Svresponse
    // Toserver notification has method, but no id
    Toserver
    // Toclient notification
    Toclient
    // Reporterr is an error message
    Reporterr // errors have method and id
)

func (Direction) String

func (d Direction) String() string

String returns a user-useful versin of a Direction

type LogHist

LogHist gets ints, and puts them into buckets: <=10, <=30, 100, 300, 1000, ... It produces a historgram of elapsed times in milliseconds

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

func (*LogHist) String

func (l *LogHist) String() string

String returns a string describing a histogram

type Logmsg

Logmsg is the type of a parsed log entry

type Logmsg struct {
    Dir     Direction
    Method  string
    ID      string      // for requests/responses. Client and server request ids overlap
    Elapsed string      // for responses
    Hdr     string      // header. do we need to keep all these strings?
    Rest    string      // the unparsed result, with newlines or not
    Body    interface{} // the parsed result
}

func ReadLogs

func ReadLogs(fname string) ([]*Logmsg, error)

ReadLogs from a file. Most users should use TRlog().

type Msgtype

Msgtype given method names. Note that mSrv|mCl is possible

type Msgtype int
const (
    // Mnot for notifications
    Mnot Msgtype = 1
    // Mreq for requests
    Mreq Msgtype = 2
    // Msrv for messages from the server
    Msrv Msgtype = 4
    // Mcl for messages from the client
    Mcl Msgtype = 8
)

type Rlog

Rlog contains the processed logs

type Rlog struct {
    Logs         []*Logmsg          // In the order in the log file
    ServerCall   map[string]*Logmsg // ID->Request, client->server
    ServerReply  map[string]*Logmsg // ID->Response, server->client (includes Errors)
    ClientCall   map[string]*Logmsg
    ClientReply  map[string]*Logmsg
    ClientNotifs []*Logmsg
    ServerNotifs []*Logmsg
    Histogram    *LogHist
}

func ToRlog

func ToRlog(fname string) (*Rlog, error)

ToRlog reads a log file and returns a *Rlog

func (*Rlog) Counts

func (r *Rlog) Counts() string

Counts returns a one-line summary of an Rlog