lsp

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 67 Imported by: 0

Documentation

Overview

Package lsp: generation-loop wiring.

This file binds the per-workspace generation.Loop to the server's init / shutdown lifecycle, forwards loop events to the extension as custom notifications, and threads config updates to the Manager.

Package lsp wires the gossip framework with the Telescope OpenAPI model, rules, and all LSP feature handlers.

Index

Constants

View Source
const GeneratedURIScheme = "telescope-generated"

GeneratedURIScheme is the virtual-document URI scheme the extension uses to display the in-memory spec when no disk path is configured.

Variables

View Source
var SemanticTokenCacheCapacity = 8

SemanticTokenCacheCapacity is the default number of URIs retained. For typical editor sessions (one or two open OpenAPI files at a time), 8 entries covers multi-file editing without noticeable memory overhead. Exposed as a variable rather than a const so test harnesses can shrink it to exercise eviction quickly.

View Source
var Version = "dev"

Version is set at build time.

Functions

func ExecuteGenerationCommand

func ExecuteGenerationCommand(ctx context.Context, mgr *generation.Manager, command string, args []interface{}) (interface{}, error)

ExecuteGenerationCommand dispatches the generation-loop commands the VS Code extension invokes via workspace/executeCommand. Exported so tests and alternative server wirings can share the same handler shape.

func GenerationCommandNames

func GenerationCommandNames() []string

GenerationCommandNames lists the command ids the server registers so they can be advertised via ExecuteCommandProvider in InitializeResult.

func IsWatchedFile

func IsWatchedFile(filePath string) bool

IsWatchedFile reports whether the given file path is a ruleset config file that should trigger a reload.

func NewCallHierarchyIncomingHandler

func NewCallHierarchyIncomingHandler(cache *openapi.IndexCache, graphBridge *GraphBridge) gossip.CallHierarchyIncomingHandler

NewCallHierarchyIncomingHandler returns all $ref usages pointing to the item.

func NewCallHierarchyOutgoingHandler

func NewCallHierarchyOutgoingHandler(cache *openapi.IndexCache, _ *GraphBridge) gossip.CallHierarchyOutgoingHandler

NewCallHierarchyOutgoingHandler returns all $ref targets from within the item.

func NewCodeActionHandler

func NewCodeActionHandler(cache *openapi.IndexCache, _ *GraphBridge) gossip.CodeActionHandler

NewCodeActionHandler provides quick fixes, rule suppression, and refactoring actions.

func NewCodeLensHandler

func NewCodeLensHandler(cache *openapi.IndexCache, graphBridge *GraphBridge) gossip.CodeLensHandler

NewCodeLensHandler provides reference counts on components, file header info, required-field previews, and operation summaries.

func NewCompletionHandler

func NewCompletionHandler(cache *openapi.IndexCache, _ *GraphBridge) gossip.CompletionHandler

NewCompletionHandler returns completions for $ref paths, HTTP status codes, media types, security schemes, tags, vendor extensions, and common OpenAPI fields.

func NewCompletionResolveHandler

func NewCompletionResolveHandler(cache *openapi.IndexCache, _ *GraphBridge) gossip.CompletionResolveHandler

NewCompletionResolveHandler enriches a completion item with documentation.

func NewDefinitionHandler

func NewDefinitionHandler(cache *openapi.IndexCache, projMgr *project.Manager, graphBridge *GraphBridge) gossip.DefinitionHandler

NewDefinitionHandler provides go-to-definition for $ref targets, security scheme names, tags, operationId in links/callbacks, and discriminator mappings.

func NewDocumentHighlightHandler

func NewDocumentHighlightHandler(cache *openapi.IndexCache, _ *GraphBridge) gossip.DocumentHighlightHandler

NewDocumentHighlightHandler highlights all occurrences of a $ref target, operationId, tag, or component name within the current document.

func NewDocumentLinkHandler

func NewDocumentLinkHandler(cache *openapi.IndexCache, _ *GraphBridge) gossip.DocumentLinkHandler

NewDocumentLinkHandler provides clickable $ref links, URLs extracted from description fields, and externalDocs.url links.

func NewExecuteCommandHandler

func NewExecuteCommandHandler(cache *openapi.IndexCache, bridge *GraphBridge, deps *ExecuteCommandDeps) gossip.ExecuteCommandHandler

NewExecuteCommandHandler handles custom telescope commands. Commands expect a document URI as the first argument.

func NewFoldingRangeHandler

func NewFoldingRangeHandler(cache *openapi.IndexCache, _ *GraphBridge) gossip.FoldingRangeHandler

NewFoldingRangeHandler provides folding ranges based on the OpenAPI structure.

func NewFormattingHandler

func NewFormattingHandler(cache *openapi.IndexCache, _ *GraphBridge) gossip.FormattingHandler

NewFormattingHandler provides document formatting for JSON OpenAPI files. JSON files are re-formatted with consistent indentation via json.MarshalIndent. YAML files are given a trailing-newline normalization pass.

func NewHoverHandler

func NewHoverHandler(cache *openapi.IndexCache, bridge *GraphBridge) gossip.HoverHandler

NewHoverHandler returns a handler that provides hover information for $ref targets, schema types, parameters, responses, security schemes, tags, operationIds, and path items.

func NewInlayHintHandler

func NewInlayHintHandler(cache *openapi.IndexCache, _ *GraphBridge) gossip.InlayHintHandler

NewInlayHintHandler provides inline hints for $ref types, required fields, deprecated markers, and parameter locations.

func NewLinkedEditingRangeHandler

func NewLinkedEditingRangeHandler(cache *openapi.IndexCache, _ *GraphBridge) gossip.LinkedEditingRangeHandler

NewLinkedEditingRangeHandler returns linked editing ranges for $ref target strings. When the cursor is on a $ref value, all identical $ref values in the document are returned so editing one edits all simultaneously.

func NewPrepareCallHierarchyHandler

func NewPrepareCallHierarchyHandler(cache *openapi.IndexCache, _ *GraphBridge) gossip.PrepareCallHierarchyHandler

NewPrepareCallHierarchyHandler identifies the component at cursor and returns a CallHierarchyItem for it.

func NewPrepareRenameHandler

func NewPrepareRenameHandler(cache *openapi.IndexCache, _ *GraphBridge) gossip.PrepareRenameHandler

NewPrepareRenameHandler validates whether a rename is possible at the cursor.

func NewReferencesHandler

func NewReferencesHandler(cache *openapi.IndexCache, graphBridge *GraphBridge) gossip.ReferencesHandler

NewReferencesHandler finds all references to a component, operationId, or tag.

func NewRenameHandler

func NewRenameHandler(cache *openapi.IndexCache, graphBridge *GraphBridge) gossip.RenameHandler

NewRenameHandler supports renaming operationId, all component types, tags, and security scheme usages across workspace files.

func NewSelectionRangeHandler

func NewSelectionRangeHandler(cache *openapi.IndexCache, _ *GraphBridge) gossip.SelectionRangeHandler

NewSelectionRangeHandler builds nested selection ranges by walking up the tree-sitter AST from the cursor position through parent nodes.

func NewSemanticTokensHandler

func NewSemanticTokensHandler(cache *openapi.IndexCache, _ *GraphBridge, tokenCache *SemanticTokenCache) gossip.SemanticTokensHandler

NewSemanticTokensHandler provides OpenAPI-aware syntax highlighting. The handler consults tokenCache (may be nil) for a previously-built token slice keyed by the document's edit version; on hit it returns the cached delta-encoded payload directly.

func NewSemanticTokensRangeHandler

func NewSemanticTokensRangeHandler(cache *openapi.IndexCache, _ *GraphBridge, tokenCache *SemanticTokenCache) gossip.SemanticTokensRangeHandler

NewSemanticTokensRangeHandler provides range-scoped semantic tokens. When a cached entry for the current document version exists, we binary-search the cached sorted slice for the viewport window in O(log N + W) instead of rebuilding. On cache miss, we build the full token slice once (which itself uses the sorted openapi.Index views for $refs and components to skip work on ref-heavy specs), store it, and serve the Range sub-slice from it. The first Full handler hit after a Range miss then reuses the same payload.

func NewServer

func NewServer(cfg *config.Config, logger *slog.Logger) (*gossip.Server, func())

NewServer creates a fully wired Telescope LSP server and returns a cleanup function that must be called when the server exits to clean up temporary resources.

func NewSymbolHandler

func NewSymbolHandler(cache *openapi.IndexCache, _ *GraphBridge) gossip.DocumentSymbolHandler

NewSymbolHandler provides document symbols for the OpenAPI structure.

func NewTypeDefinitionHandler

func NewTypeDefinitionHandler(cache *openapi.IndexCache, projMgr *project.Manager, graphBridge *GraphBridge) gossip.TypeDefinitionHandler

NewTypeDefinitionHandler resolves the type (schema) of the element at the cursor. For $ref targets it jumps to the resolved schema. For parameters and response content it navigates to the underlying schema definition.

func NewWatchedFilesHandler

func NewWatchedFilesHandler(rsMgr *RulesetManager, projMgr *project.Manager, graphBridge *GraphBridge, indexCache *openapi.IndexCache, genMgr *generation.Manager, logger *slog.Logger) gossip.DidChangeWatchedFilesHandler

NewWatchedFilesHandler returns a handler that triggers ruleset reload when Spectral or Telescope config files change on disk, and propagates changes to the project manager for cross-file diagnostic updates.

When genMgr is non-nil, file events on cartographer-watched source globs are additionally dispatched to generation.Loop.NotifyChange so the generation loop can debounce-regenerate the spec.

func NewWorkspaceSymbolHandler

func NewWorkspaceSymbolHandler(cache *openapi.IndexCache, _ *GraphBridge) gossip.WorkspaceSymbolHandler

NewWorkspaceSymbolHandler queries operations, schemas, parameters, and responses across all cached indexes.

func WatchPatterns

func WatchPatterns() []string

WatchPatterns returns the file glob patterns that should be watched for changes to trigger a ruleset reload.

Types

type DeprecatedRange

type DeprecatedRange struct {
	Range protocol.Range `json:"range"`
	Name  string         `json:"name"`
	Kind  string         `json:"kind"` // "operation", "schema", "parameter", "header"
}

DeprecatedRange describes a single deprecated element for client-side decoration.

type DeprecatedRangesParams

type DeprecatedRangesParams struct {
	URI    string            `json:"uri"`
	Ranges []DeprecatedRange `json:"ranges"`
}

DeprecatedRangesParams is the payload for the telescope/deprecatedRanges notification.

type DiagnosticMux

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

DiagnosticMux merges Telescope-owned diagnostic sources before publishing. It intentionally does not proxy YAML/JSON child language servers.

Publishes are coalesced per URI over a short window so that a single edit firing Barrelman + Vacuum + diff-on-save yields one PublishDiagnostics RPC rather than three. FlushNow and ClearSource still publish synchronously to preserve the contract callers depend on (tests rely on FlushNow being an immediate write).

func NewDiagnosticMux

func NewDiagnosticMux(publish diagnosticPublishFunc, logger *slog.Logger) *DiagnosticMux

func (*DiagnosticMux) ClearSource

func (m *DiagnosticMux) ClearSource(uri protocol.DocumentURI, source string)

ClearSource removes a source's contribution and publishes the merged remainder immediately. Flush-through is intentional: when a source is silenced we want the client to see the updated picture without the coalesce delay, matching the pre-coalescing contract.

func (*DiagnosticMux) FlushNow

func (m *DiagnosticMux) FlushNow(uri protocol.DocumentURI)

FlushNow cancels any pending coalesced publish for the URI and publishes synchronously. Tests rely on this being immediate.

func (*DiagnosticMux) Set

func (m *DiagnosticMux) Set(uri protocol.DocumentURI, source string, diags []protocol.Diagnostic)

func (*DiagnosticMux) SetCoalesceWindow

func (m *DiagnosticMux) SetCoalesceWindow(d time.Duration)

SetCoalesceWindow overrides the per-URI publish coalescing window. Pass 0 to disable coalescing entirely (useful in tests that want synchronous publish-per-Set semantics). Any pending timers are cancelled so the new window takes effect on the next Set.

func (*DiagnosticMux) SetLogger

func (m *DiagnosticMux) SetLogger(logger *slog.Logger)

func (*DiagnosticMux) SetPublishFunc

func (m *DiagnosticMux) SetPublishFunc(publish diagnosticPublishFunc)

type DiffProvider

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

DiffProvider publishes breaking-change diagnostics after save when enabled in config.

func NewDiffProvider

func NewDiffProvider(cfg *config.Config, mux *DiagnosticMux, log *slog.Logger) *DiffProvider

NewDiffProvider wires diff-on-save against a git base ref.

func (*DiffProvider) OnDidSave

func (p *DiffProvider) OnDidSave(ctx *gossip.Context, params *protocol.DidSaveTextDocumentParams) error

OnDidSave implements gossip.DidSaveHandler.

type DocsPreviewManager

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

func NewDocsPreviewManager

func NewDocsPreviewManager(logger *slog.Logger) *DocsPreviewManager

func (*DocsPreviewManager) Refresh

func (m *DocsPreviewManager) Refresh(ctx *gossip.Context, cache *openapi.IndexCache, bridge *GraphBridge, uri protocol.DocumentURI) error

func (*DocsPreviewManager) StartPreview

func (m *DocsPreviewManager) StartPreview(ctx *gossip.Context, cache *openapi.IndexCache, bridge *GraphBridge, uri protocol.DocumentURI, cfg *config.Config) (string, error)

func (*DocsPreviewManager) StopAll

func (m *DocsPreviewManager) StopAll()

func (*DocsPreviewManager) StopPreview

func (m *DocsPreviewManager) StopPreview(uri protocol.DocumentURI)

type ExecuteCommandDeps

type ExecuteCommandDeps struct {
	Config               *config.Config
	ConfigProvider       func() *config.Config
	WorkspaceEnvProvider func() map[string]string
	Runner               *contractrunner.Runner
	DocsPreview          *DocsPreviewManager
	DiagnosticMux        *DiagnosticMux
	// Generation is the shared generation.Manager; non-nil when the
	// generation loop is wired into the server. The generation-facing
	// execute commands (regenerate, openGeneratedSpec, etc.) key off it.
	Generation *generation.Manager
}

ExecuteCommandDeps wires contract testing and diagnostic aggregation for executeCommand.

func (*ExecuteCommandDeps) EffectiveConfig

func (d *ExecuteCommandDeps) EffectiveConfig() *config.Config

EffectiveConfig returns live workspace Telescope config when ConfigProvider is set.

func (*ExecuteCommandDeps) WorkspaceEnv

func (d *ExecuteCommandDeps) WorkspaceEnv() map[string]string

WorkspaceEnv returns merged dotenv variables for the workspace (or nil).

type GraphBridge

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

GraphBridge connects the new core graph engine with the existing LSP handlers, providing incremental migration from IndexCache/ProjectManager to WorkspaceGraph/SnapshotManager.

func NewGraphBridge

func NewGraphBridge(logger *slog.Logger) (*GraphBridge, error)

NewGraphBridge creates a bridge that wraps the new V2 infrastructure. Returns an error if the pipeline cannot be initialized; callers should degrade gracefully (nil bridge) rather than crashing.

func (*GraphBridge) BuildSnapshot

func (b *GraphBridge) BuildSnapshot() *graph.Snapshot

BuildSnapshot builds a new snapshot from the current graph state.

func (*GraphBridge) Classifier

func (b *GraphBridge) Classifier() *classify.FileClassifier

Classifier returns the file classifier.

func (*GraphBridge) CurrentSnapshot

func (b *GraphBridge) CurrentSnapshot() *graph.Snapshot

CurrentSnapshot returns the latest immutable snapshot. Returns nil before any snapshot has been built.

func (*GraphBridge) Dependencies

func (b *GraphBridge) Dependencies(uri string) []string

Dependencies returns URIs of documents that the given URI references.

func (*GraphBridge) Dependents

func (b *GraphBridge) Dependents(uri string) []string

Dependents returns URIs of documents that reference the given URI.

func (*GraphBridge) EdgesFrom

func (b *GraphBridge) EdgesFrom(uri string) []graph.Edge

EdgesFrom returns all edges originating from the given URI.

func (*GraphBridge) EdgesTo

func (b *GraphBridge) EdgesTo(uri string) []graph.Edge

EdgesTo returns all edges pointing to the given URI (reverse references).

func (*GraphBridge) EnrichDiagnosticsWithRefContext

func (b *GraphBridge) EnrichDiagnosticsWithRefContext(uri string, diags []ctypes.Diagnostic) []ctypes.Diagnostic

EnrichDiagnosticsWithRefContext adds RelatedInformation to diagnostics that occur within nodes resolved from $ref, linking back to the reference site.

func (*GraphBridge) FindReferences

func (b *GraphBridge) FindReferences(uri string) []protocol.Location

FindReferences uses the reverse edge index to find all references to a URI.

func (*GraphBridge) Graph

func (b *GraphBridge) Graph() *graph.WorkspaceGraph

Graph returns the workspace graph.

func (*GraphBridge) HasIncomingRefs

func (b *GraphBridge) HasIncomingRefs(uri string) bool

HasIncomingRefs returns true if the given URI is a $ref target.

func (*GraphBridge) IndexForURI

func (b *GraphBridge) IndexForURI(uri string) *openapi.Index

IndexForURI projects the current graph-backed parse output into the legacy openapi.Index surface used by existing handlers.

func (*GraphBridge) LoadWorkspaceFiles

func (b *GraphBridge) LoadWorkspaceFiles(ctx context.Context, cache *openapi.IndexCache, files []*project.DiscoveredFile) (*graph.Snapshot, error)

LoadWorkspaceFiles seeds the graph with filesystem-backed sources discovered during workspace initialization and builds a fresh snapshot from the pipeline-backed graph state.

func (*GraphBridge) LookupDefinition

func (b *GraphBridge) LookupDefinition(uri, ref string) (targetURI, targetPointer string, found bool)

LookupDefinition uses the graph's edge index for $ref resolution. Returns the target URI and JSON pointer fragment, or empty values if not found.

func (*GraphBridge) OnDocumentChange

func (b *GraphBridge) OnDocumentChange(uri string, content []byte)

OnDocumentChange handles a document update.

func (*GraphBridge) OnDocumentClose

func (b *GraphBridge) OnDocumentClose(uri string)

OnDocumentClose removes a document from the graph.

func (*GraphBridge) OnDocumentOpen

func (b *GraphBridge) OnDocumentOpen(uri string, content []byte)

OnDocumentOpen handles a new document opening by registering it in the graph.

func (*GraphBridge) OnFileChanged

func (b *GraphBridge) OnFileChanged(ctx context.Context, cache *openapi.IndexCache, uri string) (*graph.Snapshot, error)

OnFileChanged refreshes a filesystem-backed source and invalidates its dependents before re-running the pipeline. Open synthetic documents remain authoritative while they are open in the editor.

func (*GraphBridge) OnFileCreated

func (b *GraphBridge) OnFileCreated(ctx context.Context, cache *openapi.IndexCache, path string) (*graph.Snapshot, error)

OnFileCreated adds a filesystem-backed source and rebuilds the pipeline view.

func (*GraphBridge) OnFileDeleted

func (b *GraphBridge) OnFileDeleted(ctx context.Context, cache *openapi.IndexCache, path string) (*graph.Snapshot, error)

OnFileDeleted removes a filesystem-backed source, invalidates reverse dependents, and rebuilds the snapshot.

func (*GraphBridge) OnSnapshot

func (b *GraphBridge) OnSnapshot(fn func(*graph.Snapshot))

OnSnapshot registers a callback for when a new snapshot becomes current.

func (*GraphBridge) Pipeline

func (b *GraphBridge) Pipeline() *graph.PipelineRunner

Pipeline returns the graph pipeline runner.

func (*GraphBridge) ResolveRef

func (b *GraphBridge) ResolveRef(cache *openapi.IndexCache, fromURI, ref string) (protocol.DocumentURI, interface{}, error)

ResolveRef resolves a local or cross-file $ref through the graph-backed workspace model using the projection index cache for target materialization.

func (*GraphBridge) RunPipeline

func (b *GraphBridge) RunPipeline(ctx context.Context, cache *openapi.IndexCache, uris ...string) (*graph.Snapshot, error)

RunPipeline executes the graph pipeline for the given URIs, recursively materializing missing file-backed dependencies and then rebuilding the immutable snapshot. Projection indexes are refreshed into the cache when one is provided.

func (*GraphBridge) SnapshotManager

func (b *GraphBridge) SnapshotManager() *graph.SnapshotManager

SnapshotManager returns the snapshot manager.

func (*GraphBridge) SnapshotNode

func (b *GraphBridge) SnapshotNode(uri string) *graph.SnapshotNode

SnapshotNode returns the snapshot node for a URI, or nil if not found.

func (*GraphBridge) SnapshotPointerIndex

func (b *GraphBridge) SnapshotPointerIndex(uri string) *parser.PointerIndex

SnapshotPointerIndex returns the pointer index from the latest snapshot.

func (*GraphBridge) VirtualDocManager

func (b *GraphBridge) VirtualDocManager() *parser.VirtualDocumentManager

VirtualDocManager returns the virtual document manager.

type GraphResolver

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

GraphResolver adapts the graph-backed workspace model to the resolver interface expected by Barrelman analyzers and legacy call sites.

func NewGraphResolver

func NewGraphResolver(bridge *GraphBridge, cache *openapi.IndexCache) *GraphResolver

NewGraphResolver returns a resolver backed by GraphBridge edges plus the graph-projected openapi.Index cache.

func (*GraphResolver) CanResolve

func (r *GraphResolver) CanResolve(fromURI, ref string) bool

CanResolve reports whether the given ref can be resolved from the source URI.

func (*GraphResolver) Resolve

func (r *GraphResolver) Resolve(fromURI, ref string) (protocol.DocumentURI, interface{}, error)

Resolve returns the resolved target URI and value for callers that need more than the boolean CrossRefResolver interface exposes.

type HealthScore

type HealthScore struct {
	Total          int
	Documentation  int // 0-25
	Security       int // 0-25
	Completeness   int // 0-25
	Structure      int // 0-25
	PathCount      int
	SchemaCount    int
	OperationCount int
}

HealthScore represents a computed API quality score breakdown.

type RulesetManager

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

RulesetManager coordinates ruleset loading, merging, and application. It owns the DiagnosticTransformer lifecycle and the Spectral custom rule engine.

func NewRulesetManager

func NewRulesetManager(engine *treesitter.DiagnosticEngine, logger *slog.Logger) *RulesetManager

NewRulesetManager creates a new manager bound to a DiagnosticEngine.

func (*RulesetManager) Load

func (m *RulesetManager) Load(workspaceRoot string) error

Load discovers and loads both Telescope config and Spectral rulesets from the workspace root, resolves extends chains, merges them, and installs the DiagnosticTransformer on the engine.

func (*RulesetManager) Reload

func (m *RulesetManager) Reload() error

Reload re-discovers and re-loads all rulesets, updates the transformer, and invalidates all cached diagnostics to trigger re-evaluation.

func (*RulesetManager) SetTelescopeConfig

func (m *RulesetManager) SetTelescopeConfig(cfg *config.Config)

SetTelescopeConfig sets the Telescope configuration used during merging.

func (*RulesetManager) SpectralEngine

func (m *RulesetManager) SpectralEngine() *spectral.Engine

SpectralEngine returns the Spectral custom rule engine, creating one if it does not yet exist. The engine is registered as an analyzer on first access.

func (*RulesetManager) TelescopeConfig

func (m *RulesetManager) TelescopeConfig() *config.Config

TelescopeConfig returns the current merged Telescope config (workspace .telescope.yaml).

func (*RulesetManager) WorkspaceEnv

func (m *RulesetManager) WorkspaceEnv() map[string]string

WorkspaceEnv returns a copy of merged workspace dotenv variables used for contractTests *Env resolution.

type SemanticTokenCache

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

SemanticTokenCache is an LRU cache of semantic token slices keyed by document URI, versioned by the document's edit version so changes automatically invalidate a prior build. Safe for concurrent use by multiple LSP request handlers.

func NewSemanticTokenCache

func NewSemanticTokenCache(capacity int) *SemanticTokenCache

NewSemanticTokenCache returns a new cache. capacity<=0 means "use the package default".

func (*SemanticTokenCache) Get

func (c *SemanticTokenCache) Get(uri protocol.DocumentURI, version int32) *semanticTokenCacheEntry

Get returns the cached entry for (uri, version) if one is present and its version matches. A version mismatch is treated as a miss AND evicts the stale entry so subsequent Get calls don't keep paying the version check. Returns nil on miss.

func (*SemanticTokenCache) Len

func (c *SemanticTokenCache) Len() int

Len returns the number of entries currently in the cache (test helper).

func (*SemanticTokenCache) Put

func (c *SemanticTokenCache) Put(uri protocol.DocumentURI, entry *semanticTokenCacheEntry)

Put installs a new entry, evicting the oldest if needed. If a stale entry for the same URI exists (any version), it is replaced in place and moved to the MRU position.

func (*SemanticTokenCache) Remove

func (c *SemanticTokenCache) Remove(uri protocol.DocumentURI)

Remove drops the entry for uri, if any. Called on didClose.

Directories

Path Synopsis
Package adapt converts between protocol-independent core types and LSP protocol types.
Package adapt converts between protocol-independent core types and LSP protocol types.
Package navadapt bridges gossip protocol types and navigator types.
Package navadapt bridges gossip protocol types and navigator types.
Package projection maps spec-side diagnostics back to the source files that contributed each spec element.
Package projection maps spec-side diagnostics back to the source files that contributed each spec element.

Jump to

Keyboard shortcuts

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