codeintel

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package codeintel provides local code-intelligence helpers for symbols, diagnostics, notebooks, and language-server queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EditNotebookCell

func EditNotebookCell(path string, index int, cellType string, source string) error

EditNotebookCell replaces one notebook cell with source and type.

func InferLanguageID

func InferLanguageID(path string) string

InferLanguageID returns an LSP language identifier for a file path.

func LSPActionRequiresDocument

func LSPActionRequiresDocument(action string) (bool, error)

LSPActionRequiresDocument reports whether an action must open a document.

func ModulePath

func ModulePath(workspace string) (string, error)

ModulePath returns the module path from go.mod, or a stable workspace label when the workspace is not a Go module.

func NormalizeLSPAction

func NormalizeLSPAction(action string) (string, error)

NormalizeLSPAction returns the canonical name for an LSP action alias.

func NormalizeNotebookCellType

func NormalizeNotebookCellType(cellType string) (string, error)

NormalizeNotebookCellType returns the canonical notebook cell type.

func NormalizeNotebookEditMode

func NormalizeNotebookEditMode(mode string) (string, error)

NormalizeNotebookEditMode returns the canonical notebook edit mode.

func ResolveNotebookEditIndex

func ResolveNotebookEditIndex(path string, cellIndex *int, cellID string, mode string) (int, error)

ResolveNotebookEditIndex resolves an index for a notebook edit request.

Types

type CallHierarchyCall

type CallHierarchyCall struct {
	From       CallHierarchyItem `json:"from,omitempty"`
	To         CallHierarchyItem `json:"to,omitempty"`
	FromRanges []LSPRange        `json:"fromRanges"`
}

CallHierarchyCall describes a static relationship between two call hierarchy nodes.

func IncomingCalls

func IncomingCalls(workspace string, symbol string, limit int) ([]CallHierarchyCall, error)

IncomingCalls returns static callers for a function.

func OutgoingCalls

func OutgoingCalls(workspace string, symbol string, limit int) ([]CallHierarchyCall, error)

OutgoingCalls returns static callees from a function.

type CallHierarchyItem

type CallHierarchyItem struct {
	Name           string   `json:"name"`
	Kind           string   `json:"kind"`
	Path           string   `json:"path"`
	Range          LSPRange `json:"range"`
	SelectionRange LSPRange `json:"selectionRange"`
}

CallHierarchyItem describes a static call hierarchy node.

func PrepareCallHierarchy

func PrepareCallHierarchy(workspace string, symbol string, relPath string, line int, character int) ([]CallHierarchyItem, error)

PrepareCallHierarchy returns the static call hierarchy item for a symbol or document position.

type CodeLens

type CodeLens struct {
	Path    string          `json:"path"`
	Range   LSPRange        `json:"range"`
	Symbol  string          `json:"symbol"`
	Kind    string          `json:"kind,omitempty"`
	Command CodeLensCommand `json:"command"`
	Data    map[string]any  `json:"data,omitempty"`
}

CodeLens describes a static editor action attached to a declaration.

func CodeLensAtPosition

func CodeLensAtPosition(workspace string, relPath string, line int, character int) (CodeLens, bool, error)

CodeLensAtPosition resolves a static code lens at a document position.

func CodeLenses

func CodeLenses(workspace string, relPath string, limit int) ([]CodeLens, error)

CodeLenses returns static declaration lenses for one source document.

type CodeLensCommand

type CodeLensCommand struct {
	Title     string `json:"title"`
	Command   string `json:"command"`
	Arguments []any  `json:"arguments,omitempty"`
}

CodeLensCommand describes the command exposed by a code lens.

type ColorPresentation

type ColorPresentation struct {
	Label string        `json:"label"`
	Color DocumentColor `json:"color"`
}

ColorPresentation describes a textual rendering of a document color.

func ColorPresentations

func ColorPresentations(workspace string, relPath string, line int, character int) ([]ColorPresentation, bool, error)

ColorPresentations returns static textual renderings for the color under a document position.

type Completion

type Completion struct {
	Label  string `json:"label"`
	Kind   string `json:"kind"`
	Path   string `json:"path,omitempty"`
	Line   int    `json:"line,omitempty"`
	Detail string `json:"detail,omitempty"`
}

Completion describes a static completion candidate.

func Completions

func Completions(workspace string, prefix string, limit int) ([]Completion, error)

Completions returns static Go symbol and keyword completions for a prefix.

type Diagnostic

type Diagnostic struct {
	Path    string `json:"path,omitempty"`
	Line    int    `json:"line,omitempty"`
	Column  int    `json:"column,omitempty"`
	Package string `json:"package,omitempty"`
	Test    string `json:"test,omitempty"`
	Action  string `json:"action,omitempty"`
	Message string `json:"message"`
}

Diagnostic describes a build, test, or parser issue in a source file.

func GoDiagnostics

func GoDiagnostics(ctx context.Context, workspace string, patterns []string) ([]Diagnostic, error)

GoDiagnostics returns diagnostics from `go test -json` for the workspace.

func ParseGoTestJSON

func ParseGoTestJSON(workspace string, data []byte) ([]Diagnostic, error)

ParseGoTestJSON converts `go test -json` output into diagnostics.

type DocumentColor

type DocumentColor struct {
	Path  string   `json:"path"`
	Text  string   `json:"text"`
	Range LSPRange `json:"range"`
	Color LSPColor `json:"color"`
}

DocumentColor describes one color literal discovered in a source document.

func DocumentColors

func DocumentColors(workspace string, relPath string, limit int) ([]DocumentColor, error)

DocumentColors returns static hex color literals discovered in one source document.

type DocumentHighlight

type DocumentHighlight struct {
	Path  string   `json:"path"`
	Range LSPRange `json:"range"`
	Kind  int      `json:"kind,omitempty"`
	Text  string   `json:"text,omitempty"`
}

DocumentHighlight describes one static symbol occurrence in a source file.

func DocumentHighlights

func DocumentHighlights(workspace string, symbol string, relPath string, limit int) ([]DocumentHighlight, error)

DocumentHighlights returns static ranges for textual symbol occurrences.

type DocumentLink struct {
	Path    string   `json:"path"`
	Target  string   `json:"target"`
	Range   LSPRange `json:"range"`
	Tooltip string   `json:"tooltip,omitempty"`
}

DocumentLink describes a URL range discovered in a source document.

func DocumentLinkAtPosition

func DocumentLinkAtPosition(workspace string, relPath string, line int, character int) (DocumentLink, bool, error)

DocumentLinkAtPosition returns the static URL link containing a document position.

func DocumentLinks(workspace string, relPath string, limit int) ([]DocumentLink, error)

DocumentLinks returns static URL links discovered in one source document.

type FixAllResult

type FixAllResult struct {
	Kind            string                 `json:"kind"`
	Path            string                 `json:"path"`
	Changed         bool                   `json:"changed"`
	Bytes           int                    `json:"bytes"`
	Content         string                 `json:"content,omitempty"`
	Actions         []string               `json:"actions"`
	OrganizeImports *OrganizeImportsResult `json:"organize_imports,omitempty"`
}

FixAllResult reports the preview for static source.fixAll behavior.

func FixAllGoFile

func FixAllGoFile(workspace string, requested string, write bool) (FixAllResult, error)

FixAllGoFile previews or applies static source.fixAll behavior for a Go file.

type FoldingRange

type FoldingRange struct {
	Path      string `json:"path"`
	StartLine int    `json:"startLine"`
	EndLine   int    `json:"endLine"`
	Kind      string `json:"kind,omitempty"`
}

FoldingRange describes one static foldable range in a source file.

func FoldingRanges

func FoldingRanges(workspace string, relPath string, limit int) ([]FoldingRange, error)

FoldingRanges returns static foldable ranges for Go source files.

type FormatResult

type FormatResult struct {
	Kind    string `json:"kind"`
	Path    string `json:"path"`
	Changed bool   `json:"changed"`
	Bytes   int    `json:"bytes"`
	Content string `json:"content,omitempty"`
}

FormatResult reports the result of formatting a source file.

func FormatGoFile

func FormatGoFile(workspace string, requested string, write bool) (FormatResult, error)

FormatGoFile formats a Go file and optionally writes the formatted content.

type Hover

type Hover struct {
	Symbol  string   `json:"symbol"`
	Found   bool     `json:"found"`
	Kind    string   `json:"kind,omitempty"`
	Path    string   `json:"path,omitempty"`
	Line    int      `json:"line,omitempty"`
	Snippet []string `json:"snippet,omitempty"`
}

Hover contains static hover context for a discovered symbol.

func HoverInfo

func HoverInfo(workspace string, symbol string, contextLines int) (Hover, error)

HoverInfo returns static hover context around a symbol definition.

type InlayHint

type InlayHint struct {
	Path         string      `json:"path"`
	Position     LSPPosition `json:"position"`
	Label        string      `json:"label"`
	Kind         string      `json:"kind,omitempty"`
	Tooltip      string      `json:"tooltip,omitempty"`
	PaddingRight bool        `json:"paddingRight,omitempty"`
}

InlayHint describes a static editor hint for a document position.

func InlayHintAtPosition

func InlayHintAtPosition(workspace string, relPath string, line int, character int) (InlayHint, bool, error)

InlayHintAtPosition resolves a static inlay hint at a document position.

func InlayHints

func InlayHints(workspace string, relPath string, limit int) ([]InlayHint, error)

InlayHints returns static parameter hints for calls to Go functions declared in the workspace.

type InlineValue

type InlineValue struct {
	Path  string   `json:"path"`
	Name  string   `json:"name"`
	Value string   `json:"value"`
	Text  string   `json:"text"`
	Kind  string   `json:"kind,omitempty"`
	Range LSPRange `json:"range"`
}

InlineValue describes a statically known value that can be shown inline in a source document.

func InlineValues

func InlineValues(workspace string, relPath string, line int, character int, limit int) ([]InlineValue, error)

InlineValues returns simple statically known values from one Go source file.

type LSPActionInfo

type LSPActionInfo struct {
	Name             string   `json:"name"`
	Method           string   `json:"method,omitempty"`
	Aliases          []string `json:"aliases,omitempty"`
	RequiresDocument bool     `json:"requires_document"`
	RequiresPosition bool     `json:"requires_position"`
	Description      string   `json:"description,omitempty"`
}

LSPActionInfo describes a supported high-level language-server action.

func SupportedLSPActions

func SupportedLSPActions() []LSPActionInfo

SupportedLSPActions returns supported LSP actions and aliases.

type LSPCandidate

type LSPCandidate struct {
	Language    string   `json:"language"`
	Command     string   `json:"command"`
	Args        []string `json:"args,omitempty"`
	Installed   bool     `json:"installed"`
	Path        string   `json:"path,omitempty"`
	Description string   `json:"description,omitempty"`
}

LSPCandidate describes a language-server command Codog can discover.

func DefaultLSPCandidates

func DefaultLSPCandidates() []LSPCandidate

DefaultLSPCandidates returns common language-server commands and install state.

type LSPCodeDescription

type LSPCodeDescription struct {
	Href string `json:"href"`
}

LSPCodeDescription links a diagnostic code to external documentation.

type LSPColor

type LSPColor struct {
	Red   float64 `json:"red"`
	Green float64 `json:"green"`
	Blue  float64 `json:"blue"`
	Alpha float64 `json:"alpha"`
}

LSPColor is the language-server color representation.

type LSPDiagnostic

type LSPDiagnostic struct {
	Range              LSPRange                          `json:"range"`
	Severity           int                               `json:"severity,omitempty"`
	Code               any                               `json:"code,omitempty"`
	CodeDescription    *LSPCodeDescription               `json:"codeDescription,omitempty"`
	Source             string                            `json:"source,omitempty"`
	Message            string                            `json:"message"`
	Tags               []int                             `json:"tags,omitempty"`
	RelatedInformation []LSPDiagnosticRelatedInformation `json:"relatedInformation,omitempty"`
	Data               any                               `json:"data,omitempty"`
}

LSPDiagnostic describes a language-server diagnostic entry.

type LSPDiagnosticRelatedInformation

type LSPDiagnosticRelatedInformation struct {
	Location LSPLocation `json:"location"`
	Message  string      `json:"message"`
}

LSPDiagnosticRelatedInformation explains another location related to a diagnostic.

type LSPFileEdit

type LSPFileEdit struct {
	Path        string `json:"path"`
	AbsPath     string `json:"-"`
	ActionTitle string `json:"action_title,omitempty"`
	ActionKind  string `json:"action_kind,omitempty"`
	TextEdits   int    `json:"text_edits"`
	Changed     bool   `json:"changed"`
	Content     string `json:"content,omitempty"`
}

LSPFileEdit previews the text edits a language server returned for one file.

type LSPLocation

type LSPLocation struct {
	URI   string   `json:"uri"`
	Range LSPRange `json:"range"`
}

LSPLocation describes a range within a language-server document URI.

type LSPNotification

type LSPNotification struct {
	Method string `json:"method"`
	Params any    `json:"params,omitempty"`
}

LSPNotification records a language-server notification emitted while a query was running.

type LSPPosition

type LSPPosition struct {
	Line      int `json:"line"`
	Character int `json:"character"`
}

LSPPosition is a zero-based language-server document position.

type LSPQueryRequest

type LSPQueryRequest struct {
	Action          string `json:"action"`
	Path            string `json:"path"`
	Query           string `json:"query,omitempty"`
	Arguments       []any  `json:"arguments,omitempty"`
	Line            int    `json:"line,omitempty"`
	Character       int    `json:"character,omitempty"`
	NewName         string `json:"new_name,omitempty"`
	CodeActionTitle string `json:"code_action_title,omitempty"`
	Apply           bool   `json:"apply,omitempty"`
}

LSPQueryRequest describes one language-server query against a document.

type LSPQueryResult

type LSPQueryResult struct {
	Kind          string            `json:"kind"`
	Language      string            `json:"language"`
	Action        string            `json:"action"`
	Method        string            `json:"method"`
	Path          string            `json:"path"`
	Result        any               `json:"result,omitempty"`
	Notifications []LSPNotification `json:"notifications,omitempty"`
	Diagnostics   []LSPDiagnostic   `json:"diagnostics,omitempty"`
	TextEdits     int               `json:"text_edits,omitempty"`
	FileEdits     int               `json:"file_edits,omitempty"`
	Edits         []LSPFileEdit     `json:"edits,omitempty"`
	Changed       bool              `json:"changed,omitempty"`
	Applied       bool              `json:"applied,omitempty"`
	Content       string            `json:"content,omitempty"`
}

LSPQueryResult is the normalized result of an LSP JSON-RPC request.

type LSPRange

type LSPRange struct {
	Start LSPPosition `json:"start"`
	End   LSPPosition `json:"end"`
}

LSPRange is a zero-based language-server document range.

type LSPServer

type LSPServer struct {
	Language  string    `json:"language"`
	Command   string    `json:"command"`
	TaskID    string    `json:"task_id"`
	Workspace string    `json:"workspace"`
	StartedAt time.Time `json:"started_at"`
}

LSPServer records a configured background language-server process.

type LSPServerStatus

type LSPServerStatus struct {
	LSPServer
	Task background.Task `json:"task"`
}

LSPServerStatus combines persisted server metadata with task state.

type LSPStore

type LSPStore struct {
	ConfigHome string
	Workspace  string
}

LSPStore persists language-server metadata under the Codog config home.

func NewLSPStore

func NewLSPStore(configHome, workspace string) LSPStore

NewLSPStore returns a store for workspace language-server metadata.

func (LSPStore) List

func (s LSPStore) List() ([]LSPServerStatus, error)

List returns all persisted language-server statuses.

func (LSPStore) Query

func (s LSPStore) Query(ctx context.Context, language string, request LSPQueryRequest) (LSPQueryResult, error)

Query starts a configured stdio LSP command and runs one document query.

func (LSPStore) Start

func (s LSPStore) Start(language string, commandArgs []string) (LSPServerStatus, error)

Start launches and records a background language server for a language.

func (LSPStore) Status

func (s LSPStore) Status(language string) (LSPServerStatus, error)

Status returns persisted metadata and task state for a language server.

func (LSPStore) Stop

func (s LSPStore) Stop(language string) (LSPServerStatus, error)

Stop stops the background language server for a language.

type LinkedEditingRange

type LinkedEditingRange struct {
	Path        string     `json:"path"`
	Ranges      []LSPRange `json:"ranges"`
	WordPattern string     `json:"wordPattern,omitempty"`
}

LinkedEditingRange describes ranges that should be edited together.

func LinkedEditingRanges

func LinkedEditingRanges(workspace string, symbol string, relPath string, limit int) (LinkedEditingRange, error)

LinkedEditingRanges returns same-document symbol ranges that can be edited together.

type MapEntry

type MapEntry struct {
	Path  string `json:"path"`
	Type  string `json:"type"`
	Depth int    `json:"depth"`
}

MapEntry describes one file or directory in a workspace code map.

func CodeMap

func CodeMap(workspace string, depthLimit int, limit int) ([]MapEntry, error)

CodeMap returns a bounded map of files and directories in the workspace.

type Moniker

type Moniker struct {
	Scheme     string `json:"scheme"`
	Identifier string `json:"identifier"`
	Kind       string `json:"kind,omitempty"`
	Unique     string `json:"unique,omitempty"`
}

Moniker identifies a symbol across files and tools.

func Monikers

func Monikers(workspace string, symbol string) ([]Moniker, error)

Monikers returns stable static identifiers for a discovered Go symbol.

type Notebook

type Notebook struct {
	Cells []NotebookCell `json:"cells"`
}

Notebook contains the cells from a Jupyter notebook document.

type NotebookCell

type NotebookCell struct {
	CellType string   `json:"cell_type"`
	Source   []string `json:"source"`
}

NotebookCell contains the source for one notebook cell.

type NotebookEditOptions

type NotebookEditOptions struct {
	Index    int
	CellType string
	Source   string
	Mode     string
}

NotebookEditOptions describes a notebook cell edit operation.

type NotebookEditResult

type NotebookEditResult struct {
	Kind        string `json:"kind"`
	Path        string `json:"path"`
	Mode        string `json:"mode"`
	Index       int    `json:"index"`
	CellID      string `json:"cell_id,omitempty"`
	CellType    string `json:"cell_type,omitempty"`
	Language    string `json:"language,omitempty"`
	CellCount   int    `json:"cell_count"`
	SourceLines int    `json:"source_lines,omitempty"`
}

NotebookEditResult reports the applied notebook cell edit.

func EditNotebook

func EditNotebook(path string, options NotebookEditOptions) (NotebookEditResult, error)

EditNotebook applies a replace, insert, or delete operation to a notebook.

type NotebookReadCell

type NotebookReadCell struct {
	Index          int    `json:"index"`
	CellID         string `json:"cell_id,omitempty"`
	CellType       string `json:"cell_type"`
	Source         string `json:"source"`
	ExecutionCount any    `json:"execution_count,omitempty"`
	OutputCount    int    `json:"output_count,omitempty"`
	Outputs        any    `json:"outputs,omitempty"`
}

NotebookReadCell is a JSON-safe view of one notebook cell.

type NotebookReadOptions

type NotebookReadOptions struct {
	CellIndex      *int
	Limit          int
	IncludeOutputs bool
}

NotebookReadOptions controls notebook read filtering and output expansion.

type NotebookReadResult

type NotebookReadResult struct {
	Kind      string             `json:"kind"`
	Path      string             `json:"path"`
	Language  string             `json:"language,omitempty"`
	CellCount int                `json:"cell_count"`
	Cells     []NotebookReadCell `json:"cells"`
	Truncated bool               `json:"truncated"`
}

NotebookReadResult reports notebook metadata and selected cells.

func ReadNotebook

func ReadNotebook(path string, options NotebookReadOptions) (NotebookReadResult, error)

ReadNotebook reads selected cells from a Jupyter notebook file.

type OrganizeImportsResult

type OrganizeImportsResult struct {
	FormatResult
	ImportCount                int      `json:"import_count"`
	RemovedImports             []string `json:"removed_imports,omitempty"`
	DuplicateImports           []string `json:"duplicate_imports,omitempty"`
	MissingImportInference     bool     `json:"missing_import_inference"`
	MissingImportInferenceNote string   `json:"missing_import_inference_note,omitempty"`
}

OrganizeImportsResult reports the result of static Go import organization.

func OrganizeGoImports

func OrganizeGoImports(workspace string, requested string, write bool) (OrganizeImportsResult, error)

OrganizeGoImports removes unused and duplicate Go imports, sorts import declarations, formats the file, and optionally writes the organized content.

type Reference

type Reference struct {
	Symbol string `json:"symbol"`
	Path   string `json:"path"`
	Line   int    `json:"line"`
	Text   string `json:"text"`
}

Reference describes one textual symbol reference in a Go source file.

func References

func References(workspace string, symbol string, limit int) ([]Reference, error)

References returns textual Go references for a symbol.

type RenameFileEdit

type RenameFileEdit struct {
	Path      string           `json:"path"`
	TextEdits int              `json:"textEdits"`
	Changed   bool             `json:"changed"`
	Content   string           `json:"content,omitempty"`
	Edits     []RenameTextEdit `json:"edits,omitempty"`
}

RenameFileEdit previews all rename edits for one file.

type RenamePrepareResult

type RenamePrepareResult struct {
	Path        string   `json:"path,omitempty"`
	Symbol      string   `json:"symbol,omitempty"`
	Found       bool     `json:"found"`
	CurrentName string   `json:"current_name,omitempty"`
	Placeholder string   `json:"placeholder,omitempty"`
	Range       LSPRange `json:"range,omitempty"`
}

RenamePrepareResult describes whether a symbol can be renamed.

func PrepareRenameAtPosition

func PrepareRenameAtPosition(workspace string, relPath string, line int, character int) (RenamePrepareResult, error)

PrepareRenameAtPosition returns the rename range for a symbol at a document position.

type RenameResult

type RenameResult struct {
	Symbol    string           `json:"symbol"`
	NewName   string           `json:"newName"`
	Found     bool             `json:"found"`
	TextEdits int              `json:"textEdits"`
	FileEdits int              `json:"fileEdits"`
	Edits     []RenameFileEdit `json:"edits,omitempty"`
}

RenameResult previews a static workspace rename.

func RenameSymbol

func RenameSymbol(workspace string, symbol string, newName string, limit int) (RenameResult, error)

RenameSymbol returns a static workspace rename preview for a Go identifier.

type RenameTextEdit

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

RenameTextEdit describes one static rename text edit.

type ResolvedSymbol

type ResolvedSymbol struct {
	Symbol Symbol `json:"symbol"`
	Hover  Hover  `json:"hover,omitempty"`
}

ResolvedSymbol combines a workspace symbol match with hover context.

func ResolveWorkspaceSymbol

func ResolveWorkspaceSymbol(workspace string, query string) (ResolvedSymbol, bool, error)

ResolveWorkspaceSymbol returns the best static match for a workspace symbol query and includes nearby source context.

type SelectionRange

type SelectionRange struct {
	Path  string   `json:"path"`
	Range LSPRange `json:"range"`
	Kind  string   `json:"kind,omitempty"`
}

SelectionRange describes one static AST range containing a document position.

func SelectionRanges

func SelectionRanges(workspace string, relPath string, line int, character int, limit int) ([]SelectionRange, error)

SelectionRanges returns nested static AST ranges containing a document position.

type SemanticToken

type SemanticToken struct {
	Path      string   `json:"path"`
	Range     LSPRange `json:"range"`
	Text      string   `json:"text"`
	Type      string   `json:"type"`
	TokenType int      `json:"tokenType"`
}

SemanticToken describes one decoded semantic token.

type SemanticTokens

type SemanticTokens struct {
	Path     string          `json:"path"`
	ResultID string          `json:"resultId,omitempty"`
	Legend   []string        `json:"legend"`
	Data     []int           `json:"data"`
	Tokens   []SemanticToken `json:"tokens"`
}

SemanticTokens describes static semantic tokens for a document.

func SemanticTokensForDocument

func SemanticTokensForDocument(workspace string, relPath string, limit int) (SemanticTokens, error)

SemanticTokensForDocument returns static semantic tokens for one source document.

func SemanticTokensForLine

func SemanticTokensForLine(workspace string, relPath string, line int, limit int) (SemanticTokens, error)

SemanticTokensForLine returns static semantic tokens for one document line.

type SemanticTokensDelta

type SemanticTokensDelta struct {
	Path             string         `json:"path"`
	PreviousResultID string         `json:"previousResultId,omitempty"`
	ResultID         string         `json:"resultId"`
	Edits            []any          `json:"edits"`
	Tokens           SemanticTokens `json:"tokens"`
}

SemanticTokensDelta describes a static semantic tokens delta response.

func SemanticTokensDeltaForDocument

func SemanticTokensDeltaForDocument(workspace string, relPath string, previousResultID string, limit int) (SemanticTokensDelta, error)

SemanticTokensDeltaForDocument returns a deterministic static delta response.

type Signature

type Signature struct {
	Label         string              `json:"label"`
	Documentation string              `json:"documentation,omitempty"`
	Parameters    []SignatureArgument `json:"parameters,omitempty"`
}

Signature describes one static function signature.

type SignatureArgument

type SignatureArgument struct {
	Label string `json:"label"`
	Name  string `json:"name,omitempty"`
	Type  string `json:"type,omitempty"`
}

SignatureArgument describes one function parameter.

type SignatureHelp

type SignatureHelp struct {
	Path            string              `json:"path"`
	Function        string              `json:"function"`
	Found           bool                `json:"found"`
	Signatures      []Signature         `json:"signatures,omitempty"`
	ActiveSignature int                 `json:"activeSignature"`
	ActiveParameter int                 `json:"activeParameter"`
	CallRange       LSPRange            `json:"callRange,omitempty"`
	Parameters      []SignatureArgument `json:"parameters,omitempty"`
}

SignatureHelp describes static function call signature context.

func SignatureHelpAtPosition

func SignatureHelpAtPosition(workspace string, relPath string, line int, character int) (SignatureHelp, error)

SignatureHelpAtPosition returns static signature help for the function call containing a document position.

type Symbol

type Symbol struct {
	Name string `json:"name"`
	Kind string `json:"kind"`
	Path string `json:"path"`
	Line int    `json:"line"`
}

Symbol describes a Go declaration discovered in the workspace.

func Definition

func Definition(workspace string, symbol string) (Symbol, bool, error)

Definition returns the first discovered definition for a Go symbol.

func GoSymbols

func GoSymbols(workspace string) ([]Symbol, error)

GoSymbols returns function and type declarations found in Go files.

func WorkspaceSymbols

func WorkspaceSymbols(workspace string, query string, limit int) ([]Symbol, error)

WorkspaceSymbols returns symbols matching a workspace-wide query.

type TypeHierarchyItem

type TypeHierarchyItem struct {
	Name           string   `json:"name"`
	Kind           string   `json:"kind"`
	Path           string   `json:"path"`
	Range          LSPRange `json:"range"`
	SelectionRange LSPRange `json:"selectionRange"`
	Detail         string   `json:"detail,omitempty"`
}

TypeHierarchyItem describes a static type hierarchy node.

func PrepareTypeHierarchy

func PrepareTypeHierarchy(workspace string, symbol string, relPath string, line int, character int) ([]TypeHierarchyItem, error)

PrepareTypeHierarchy returns the static type hierarchy item for a symbol or document position.

func TypeHierarchySubtypes

func TypeHierarchySubtypes(workspace string, symbol string, limit int) ([]TypeHierarchyItem, error)

TypeHierarchySubtypes returns static subtypes for a Go type. Structs that embed the target type and types that satisfy a target interface's method set are reported as children.

func TypeHierarchySupertypes

func TypeHierarchySupertypes(workspace string, symbol string, limit int) ([]TypeHierarchyItem, error)

TypeHierarchySupertypes returns static supertypes for a Go type. Struct embedding and embedded interfaces are treated as hierarchy parents.

Jump to

Keyboard shortcuts

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