Documentation
¶
Index ¶
- func CompleteForText(path string, text string, pos protocol.Position, projects *ProjectCache) (protocol.CompletionList, *protocol.ResponseError)
- func DefinitionForText(path string, text string, pos protocol.Position, projects *ProjectCache) ([]protocol.Location, *protocol.ResponseError)
- func DiagnosticsForError(text string, err error) []protocol.Diagnostic
- func DiagnosticsForText(path string, text string) []protocol.Diagnostic
- func DiagnosticsForTextWithProjects(path string, text string, projects *ProjectCache) []protocol.Diagnostic
- func DocumentSymbolsForText(path string, text string) ([]protocol.DocumentSymbol, *protocol.ResponseError)
- func FileURIToPath(rawURI string) (string, error)
- func FormatText(path string, text string) ([]protocol.TextEdit, *protocol.ResponseError)
- func HoverForText(path string, text string, pos protocol.Position, projects *ProjectCache) (*protocol.Hover, *protocol.ResponseError)
- func LSPToOffset(text string, pos protocol.Position) (int, bool)
- func OffsetToLSP(text string, offset int) protocol.Position
- func PathToFileURI(path string) string
- func Serve(ctx context.Context, in io.Reader, out io.Writer, version string) error
- func ServeWithOptions(ctx context.Context, in io.Reader, out io.Writer, options Options) error
- type Document
- type DocumentStore
- type ImportResolver
- type LineInfo
- type Options
- type Project
- type ProjectCache
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompleteForText ¶
func CompleteForText( path string, text string, pos protocol.Position, projects *ProjectCache, ) (protocol.CompletionList, *protocol.ResponseError)
CompleteForText resolves a completion request.
func DefinitionForText ¶
func DefinitionForText( path string, text string, pos protocol.Position, projects *ProjectCache, ) ([]protocol.Location, *protocol.ResponseError)
DefinitionForText resolves a go-to-definition request.
func DiagnosticsForError ¶
func DiagnosticsForError(text string, err error) []protocol.Diagnostic
DiagnosticsForError converts UB parser and syntax errors to LSP diagnostics.
func DiagnosticsForText ¶
func DiagnosticsForText(path string, text string) []protocol.Diagnostic
DiagnosticsForText parses and validates UB source text into LSP diagnostics.
func DiagnosticsForTextWithProjects ¶
func DiagnosticsForTextWithProjects( path string, text string, projects *ProjectCache, ) []protocol.Diagnostic
DiagnosticsForTextWithProjects adds no-fetch semantic checks when project data is available.
func DocumentSymbolsForText ¶
func DocumentSymbolsForText( path string, text string, ) ([]protocol.DocumentSymbol, *protocol.ResponseError)
DocumentSymbolsForText parses UB text and returns document symbols.
func FileURIToPath ¶
FileURIToPath converts a file URI to a local path.
func FormatText ¶
FormatText formats one UB document and returns LSP text edits.
func HoverForText ¶
func HoverForText( path string, text string, pos protocol.Position, projects *ProjectCache, ) (*protocol.Hover, *protocol.ResponseError)
HoverForText resolves a hover request.
func LSPToOffset ¶
LSPToOffset converts a zero-based UTF-16 LSP position to a byte offset.
func OffsetToLSP ¶
OffsetToLSP converts a byte offset to a zero-based UTF-16 LSP position.
func PathToFileURI ¶
PathToFileURI converts a local path to a file URI.
Types ¶
type DocumentStore ¶
type DocumentStore struct {
// contains filtered or unexported fields
}
DocumentStore tracks open documents by URI.
func NewDocumentStore ¶
func NewDocumentStore() *DocumentStore
NewDocumentStore returns an empty document store.
func (*DocumentStore) Close ¶
func (s *DocumentStore) Close(uri string)
Close removes an open document snapshot.
type ImportResolver ¶
type ImportResolver struct {
// contains filtered or unexported fields
}
ImportResolver resolves LSP imports without network access.
func NewImportResolver ¶
func NewImportResolver( root string, project *deps.Project, lock *deps.ProjectLock, remote cachedRemoteSource, ) *ImportResolver
NewImportResolver returns an import resolver for one project root.
func (*ImportResolver) Resolve ¶
Resolve resolves ref or returns an error when no cached source exists.
func (*ImportResolver) ResolveNoFetch ¶
ResolveNoFetch resolves ref from local files or cached remote data only.
type Project ¶
type Project struct {
Root string
Marker projectmarker.Marker
DepsProject *deps.Project
ProjectLock *deps.ProjectLock
Resolver *ImportResolver
GoSchemas *compile.SchemaCache
GoIndex *goschema.SourceIndexCache
GoModuleRoots []goschema.ModuleRoot
}
Project holds cached LSP data for one project marker root.
func (*Project) EnsureGoModuleRoot ¶
EnsureGoModuleRoot adds the Go module root for source when it can be found.
type ProjectCache ¶
type ProjectCache struct {
// contains filtered or unexported fields
}
ProjectCache stores project data by marker root.
func NewProjectCache ¶
func NewProjectCache(workspaceRoot string) *ProjectCache
NewProjectCache returns an empty project cache.
func (*ProjectCache) InvalidatePath ¶
func (c *ProjectCache) InvalidatePath(path string)
InvalidatePath removes cached project data affected by a saved path.
func (*ProjectCache) ProjectForPath ¶
func (c *ProjectCache) ProjectForPath(path string) (*Project, error)
ProjectForPath returns cached project data for path's nearest marker root.
func (*ProjectCache) SetWorkspaceRoots ¶
func (c *ProjectCache) SetWorkspaceRoots(roots []string)
SetWorkspaceRoots sets weak roots used for loose files without project markers.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session owns the state for one LSP client connection.
func (*Session) HandleRequest ¶
func (s *Session) HandleRequest( ctx context.Context, req *protocol.RequestMessage, ) (any, *protocol.ResponseError)
HandleRequest dispatches one JSON-RPC request to the session.
func (*Session) StopRequested ¶
StopRequested reports whether the protocol server should stop serving.