lsproto

package
v2.0.0-...-7f6935a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2020 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JsonGetPath

func JsonGetPath(v interface{}, path string) (interface{}, error)

func PatchFileTextEdits

func PatchFileTextEdits(filename string, edits []*TextEdit) error

func PatchTextEdits

func PatchTextEdits(src []byte, edits []*TextEdit) ([]byte, error)

func PatchWorkspaceEditChanges

func PatchWorkspaceEditChanges(wecs []*WorkspaceEditChange) error

func RangeToOffsetLen

func RangeToOffsetLen(rd iorw.ReaderAt, rang *Range) (int, int, error)

func RegistrationExamples

func RegistrationExamples() string

func RegistrationString

func RegistrationString(reg *Registration) string

func Utf16Column

func Utf16Column(rd iorw.ReaderAt, lineStartOffset, utf8Col int) (int, error)

func Utf8Column

func Utf8Column(rd iorw.ReaderAt, lineStartOffset, utf16Col int) (int, error)

Input and result is zero based.

Types

type Client

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

func NewClientIO

func NewClientIO(ctx context.Context, rwc io.ReadWriteCloser, li *LangInstance) *Client

func NewClientTCP

func NewClientTCP(ctx context.Context, addr string, li *LangInstance) (*Client, error)

func (*Client) Call

func (cli *Client) Call(ctx context.Context, method string, args, reply interface{}) error

func (*Client) ExitNotification

func (cli *Client) ExitNotification() error

func (*Client) Initialize

func (cli *Client) Initialize(ctx context.Context) error

func (*Client) ShutdownRequest

func (cli *Client) ShutdownRequest() error

func (*Client) TextDocumentCompletion

func (cli *Client) TextDocumentCompletion(ctx context.Context, filename string, pos Position) (*CompletionList, error)

func (*Client) TextDocumentDefinition

func (cli *Client) TextDocumentDefinition(ctx context.Context, filename string, pos Position) (*Location, error)

func (*Client) TextDocumentDidChange

func (cli *Client) TextDocumentDidChange(ctx context.Context, filename, text string, version int) error

func (*Client) TextDocumentDidClose

func (cli *Client) TextDocumentDidClose(ctx context.Context, filename string) error

func (*Client) TextDocumentDidOpen

func (cli *Client) TextDocumentDidOpen(ctx context.Context, filename, text string, version int) error

func (*Client) TextDocumentDidOpenVersion

func (cli *Client) TextDocumentDidOpenVersion(ctx context.Context, filename string, b []byte) error

func (*Client) TextDocumentDidSave

func (cli *Client) TextDocumentDidSave(ctx context.Context, filename string, text []byte) error

func (*Client) TextDocumentRename

func (cli *Client) TextDocumentRename(ctx context.Context, filename string, pos Position, newName string) (*WorkspaceEdit, error)

func (*Client) UpdateWorkspaceFolder

func (cli *Client) UpdateWorkspaceFolder(ctx context.Context, dir string) error

func (*Client) Wait

func (cli *Client) Wait() error

func (*Client) WorkspaceDidChangeWorkspaceFolders

func (cli *Client) WorkspaceDidChangeWorkspaceFolders(ctx context.Context, added, removed []*WorkspaceFolder) error

type CompletionContext

type CompletionContext struct {
	TriggerKind      int    `json:"triggerKind"` // 1=invoked, 2=char, 3=re-trigger
	TriggerCharacter string `json:"triggerCharacter,omitempty"`
}

type CompletionItem

type CompletionItem struct {
	Label         string `json:"label"`
	Kind          int    `json:"kind,omitempty"`
	Detail        string `json:"detail,omitempty"`
	Documentation string `json:"documentation,omitempty"`
	Deprecated    bool   `json:"deprecated,omitempty"`
}

type CompletionList

type CompletionList struct {
	IsIncomplete bool              `json:"isIncomplete"`
	Items        []*CompletionItem `json:"items"`
}

type CompletionParams

type CompletionParams struct {
	TextDocumentPositionParams
	Context CompletionContext `json:"context"`
}

type DidChangeTextDocumentParams

type DidChangeTextDocumentParams struct {
	TextDocument   VersionedTextDocumentIdentifier   `json:"textDocument,omitempty"`
	ContentChanges []*TextDocumentContentChangeEvent `json:"contentChanges,omitempty"`
}

type DidChangeWorkspaceFoldersParams

type DidChangeWorkspaceFoldersParams struct {
	Event *WorkspaceFoldersChangeEvent `json:"event,omitempty"`
}

type DidCloseTextDocumentParams

type DidCloseTextDocumentParams struct {
	TextDocument TextDocumentIdentifier `json:"textDocument"`
}

type DidOpenTextDocumentParams

type DidOpenTextDocumentParams struct {
	TextDocument TextDocumentItem `json:"textDocument"`
}

type DidSaveTextDocumentParams

type DidSaveTextDocumentParams struct {
	TextDocument TextDocumentIdentifier `json:"textDocument"`
	Text         string                 `json:"text,omitempty"`
}

type DocumentUri

type DocumentUri string

type JsonCodec

type JsonCodec struct {
	OnNotificationMessage   func(*NotificationMessage)
	OnUnexpectedServerReply func(*Response)
	// contains filtered or unexported fields
}

Implements rpc.ClientCodec

func NewJsonCodec

func NewJsonCodec(rwc io.ReadWriteCloser) *JsonCodec

Needs a call to ReadLoop() to start reading.

func (*JsonCodec) Close

func (c *JsonCodec) Close() error

func (*JsonCodec) ReadLoop

func (c *JsonCodec) ReadLoop() error

func (*JsonCodec) ReadResponseBody

func (c *JsonCodec) ReadResponseBody(reply interface{}) error

func (*JsonCodec) ReadResponseHeader

func (c *JsonCodec) ReadResponseHeader(resp *rpc.Response) error

Sets response.Seq to have ReadResponseBody be called with the correct reply variable. i

func (*JsonCodec) WriteRequest

func (c *JsonCodec) WriteRequest(req *rpc.Request, data interface{}) error

type LangInstance

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

func NewLangInstance

func NewLangInstance(ctx context.Context, lang *LangManager) (*LangInstance, error)

func (*LangInstance) Wait

func (li *LangInstance) Wait() error

type LangManager

type LangManager struct {
	Reg *Registration // accessed from editor

	InstanceReqFilename string // the calling filename (used in startup)
	// contains filtered or unexported fields
}

func NewLangManager

func NewLangManager(man *Manager, reg *Registration) *LangManager

func (*LangManager) Close

func (lang *LangManager) Close() (error, bool)

returns true if the instance was running

func (*LangManager) PrintWrapError

func (lang *LangManager) PrintWrapError(err error)

func (*LangManager) WrapError

func (lang *LangManager) WrapError(err error) error

func (*LangManager) WrapMsg

func (lang *LangManager) WrapMsg(s string) string

type Location

type Location struct {
	Uri   DocumentUri `json:"uri,omitempty"`
	Range *Range      `json:"range,omitempty"`
}

type Manager

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

Notes: - Manager manages LangManagers - LangManager has a Registration and handles a LangInstance - Client handles client connection to the lsp server - ServerWrap, if used, runs the lsp server process

func NewManager

func NewManager(msgFn func(string)) *Manager

func (*Manager) Close

func (man *Manager) Close() error

func (*Manager) Error

func (man *Manager) Error(err error)

func (*Manager) LangManager

func (man *Manager) LangManager(filename string) (*LangManager, error)

func (*Manager) Message

func (man *Manager) Message(s string)

func (*Manager) Register

func (man *Manager) Register(reg *Registration) error

func (*Manager) TextDocumentCompletion

func (man *Manager) TextDocumentCompletion(ctx context.Context, filename string, rd iorw.ReaderAt, offset int) (*CompletionList, error)

func (*Manager) TextDocumentCompletionDetailStrings

func (man *Manager) TextDocumentCompletionDetailStrings(ctx context.Context, filename string, rd iorw.ReaderAt, offset int) ([]string, error)

func (*Manager) TextDocumentDefinition

func (man *Manager) TextDocumentDefinition(ctx context.Context, filename string, rd iorw.ReaderAt, offset int) (string, *Range, error)

func (*Manager) TextDocumentRename

func (man *Manager) TextDocumentRename(ctx context.Context, filename string, rd iorw.ReaderAt, offset int, newName string) (*WorkspaceEdit, error)

type NotificationMessage

type NotificationMessage struct {
	Method string      `json:"method,omitempty"`
	Params interface{} `json:"params,omitempty"`
}

type Position

type Position struct {
	Line      int `json:"line"`      // zero based
	Character int `json:"character"` // zero based
}

func OffsetToPosition

func OffsetToPosition(rd iorw.ReaderAt, offset int) (Position, error)

type Range

type Range struct {
	Start Position `json:"start"`
	End   Position `json:"end"`
}

type Registration

type Registration struct {
	Language string
	Exts     []string
	Cmd      string
	Network  string   // {stdio, tcp(runs text/template on cmd)}
	Optional []string // optional extra fields
}

func NewRegistration

func NewRegistration(s string) (*Registration, error)

func (*Registration) HasOptional

func (reg *Registration) HasOptional(s string) bool

type RenameParams

type RenameParams struct {
	TextDocumentPositionParams
	NewName string `json:"newName"`
}

type RequestMessage

type RequestMessage struct {
	JsonRpc string      `json:"jsonrpc"`
	Id      int         `json:"id"`
	Method  string      `json:"method"`
	Params  interface{} `json:"params,omitempty"`
}

type Response

type Response struct {
	ResponseMessage
	NotificationMessage
}

type ResponseError

type ResponseError struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

func (*ResponseError) Error

func (e *ResponseError) Error() string

type ResponseMessage

type ResponseMessage struct {
	Id     int             `json:"id,omitempty"` // id can be zero on first msg
	Error  *ResponseError  `json:"error,omitempty"`
	Result json.RawMessage `json:"result,omitempty"`
}

type ServerWrap

type ServerWrap struct {
	Cmd *osutil.Cmd
	// contains filtered or unexported fields
}

func StartServerWrapIO

func StartServerWrapIO(ctx context.Context, cmd string, stderr io.Writer, li *LangInstance) (*ServerWrap, io.ReadWriteCloser, error)

func StartServerWrapTCP

func StartServerWrapTCP(ctx context.Context, cmdTmpl string, w io.Writer) (*ServerWrap, string, error)

func (*ServerWrap) Wait

func (sw *ServerWrap) Wait() error

type TextDocumentContentChangeEvent

type TextDocumentContentChangeEvent struct {
	Range       Range  `json:"range,omitempty"`
	RangeLength int    `json:"rangeLength,omitempty"`
	Text        string `json:"text,omitempty"`
}

type TextDocumentEdit

type TextDocumentEdit struct {
	TextDocument VersionedTextDocumentIdentifier `json:"textDocument"`
	Edits        []*TextEdit                     `json:"edits"`
}

type TextDocumentIdentifier

type TextDocumentIdentifier struct {
	Uri DocumentUri `json:"uri"`
}

type TextDocumentItem

type TextDocumentItem struct {
	Uri        DocumentUri `json:"uri"`
	LanguageId string      `json:"languageId,omitempty"`
	Version    int         `json:"version"`
	Text       string      `json:"text"`
}

type TextDocumentPositionParams

type TextDocumentPositionParams struct {
	TextDocument TextDocumentIdentifier `json:"textDocument"`
	Position     Position               `json:"position"`
}

type TextEdit

type TextEdit struct {
	Range   Range  `json:"range"`
	NewText string `json:"newText"`
}

type VersionedTextDocumentIdentifier

type VersionedTextDocumentIdentifier struct {
	TextDocumentIdentifier
	Version *int `json:"version"`
}

type WorkspaceEdit

type WorkspaceEdit struct {
	Changes         map[DocumentUri][]*TextEdit `json:"changes,omitempty"`
	DocumentChanges []*TextDocumentEdit         `json:"documentChanges,omitempty"`
}

type WorkspaceEditChange

type WorkspaceEditChange struct {
	Filename string
	Edits    []*TextEdit
}

func WorkspaceEditChanges

func WorkspaceEditChanges(we *WorkspaceEdit) ([]*WorkspaceEditChange, error)

type WorkspaceFolder

type WorkspaceFolder struct {
	Uri  DocumentUri `json:"uri"`
	Name string      `json:"name"`
}

type WorkspaceFoldersChangeEvent

type WorkspaceFoldersChangeEvent struct {
	Added   []*WorkspaceFolder `json:"added"`
	Removed []*WorkspaceFolder `json:"removed"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL