Documentation
¶
Index ¶
- Variables
- func CollectExternalRefTargets(sourceURI string, idx *openapi.Index) []string
- func PathToURI(fsPath string) string
- func URIToPath(uri string) string
- func UpdateGraphFromIndex(g *FileGraph, sourceURI string, idx *openapi.Index)
- type CrossFileResolver
- type DiscoveredFile
- type Discovery
- func (d *Discovery) AllFiles() []*DiscoveredFile
- func (d *Discovery) FileByPath(path string) *DiscoveredFile
- func (d *Discovery) FileByURI(uri string) *DiscoveredFile
- func (d *Discovery) IsRoot(uri string) bool
- func (d *Discovery) RemoveFile(path string)
- func (d *Discovery) Roots() []string
- func (d *Discovery) Scan(workspaceRoot string) error
- func (d *Discovery) UpdateFile(path string) *DiscoveredFile
- type FileGraph
- type FileRole
- type Manager
- func (m *Manager) Discovery() *Discovery
- func (m *Manager) Initialize(workspaceRoot string, exclude []string)
- func (m *Manager) OnFileChanged(uri string)
- func (m *Manager) OnFileCreated(path string)
- func (m *Manager) OnFileDeleted(path string)
- func (m *Manager) ProjectForFile(uri string) *ProjectContext
- func (m *Manager) Projects() map[string]*ProjectContext
- func (m *Manager) ResolverForFile(uri string) rules.CrossRefResolver
- func (m *Manager) SetAnalyzers(a []rules.NamedAnalyzer)
- func (m *Manager) SetOnDiscovered(fn func([]*DiscoveredFile))
- func (m *Manager) SetPublish(fn PublishFunc)
- func (m *Manager) SetResolver(resolver rules.CrossRefResolver)
- func (m *Manager) SetShouldPublish(fn func(uri string) bool)
- func (m *Manager) WaitReady(timeout time.Duration) bool
- type ProjectContext
- func (p *ProjectContext) AllURIs() []string
- func (p *ProjectContext) ContainsFile(uri string) bool
- func (p *ProjectContext) DocIndex(uri string) *openapi.Index
- func (p *ProjectContext) DocsSnapshot() map[string]*openapi.Index
- func (p *ProjectContext) GetResolver() *CrossFileResolver
- func (p *ProjectContext) RebuildIndex(uri string, cache *openapi.IndexCache) error
- type PublishFunc
- type RefEdge
- type ResolveResult
Constants ¶
This section is empty.
Variables ¶
var NewFileGraph = navigator.NewFileGraph
NewFileGraph delegates to navigator.NewFileGraph.
Functions ¶
func CollectExternalRefTargets ¶
CollectExternalRefTargets returns the set of unique target URIs referenced by external $refs in the given index.
Types ¶
type CrossFileResolver ¶
type CrossFileResolver struct {
// contains filtered or unexported fields
}
CrossFileResolver resolves $ref values that span across files within a project. It uses the project's merged set of indexes to locate the target document and then delegates to its local resolver.
func NewCrossFileResolver ¶
func NewCrossFileResolver(docs map[string]*openapi.Index) *CrossFileResolver
NewCrossFileResolver creates a resolver over the given set of document indexes.
func (*CrossFileResolver) CanResolve ¶
func (r *CrossFileResolver) CanResolve(fromURI, ref string) bool
CanResolve checks whether a $ref from the given source can be resolved.
func (*CrossFileResolver) Resolve ¶
func (r *CrossFileResolver) Resolve(fromURI, ref string) (*ResolveResult, error)
Resolve follows a $ref value from the given source document. For local refs (#/...) it uses the source document's index. For external refs (./file.yaml#/...) it resolves the file path relative to the source and then resolves the fragment within the target index.
type DiscoveredFile ¶
type DiscoveredFile struct {
Path string // absolute filesystem path
URI string // file:// URI
Role FileRole
MTime int64 // modification time (Unix nanos) for cache invalidation
}
DiscoveredFile holds information about a file found during workspace scanning.
type Discovery ¶
type Discovery struct {
// contains filtered or unexported fields
}
Discovery scans workspace directories for YAML/JSON files and classifies them as OpenAPI roots or fragments. Results are cached by mtime.
func NewDiscovery ¶
NewDiscovery creates a Discovery with the given exclude patterns. Patterns follow filepath.Match syntax (e.g., "node_modules/**").
func (*Discovery) AllFiles ¶
func (d *Discovery) AllFiles() []*DiscoveredFile
AllFiles returns all discovered files.
func (*Discovery) FileByPath ¶
func (d *Discovery) FileByPath(path string) *DiscoveredFile
FileByPath returns the discovered file for a filesystem path, or nil.
func (*Discovery) FileByURI ¶
func (d *Discovery) FileByURI(uri string) *DiscoveredFile
FileByURI returns the discovered file for a URI, or nil.
func (*Discovery) RemoveFile ¶
RemoveFile removes a file from the discovery cache (after deletion).
func (*Discovery) Scan ¶
Scan walks the given workspace root, discovering and classifying all YAML and JSON files. Files matching exclude patterns are skipped. The scan replaces any previous results.
func (*Discovery) UpdateFile ¶
func (d *Discovery) UpdateFile(path string) *DiscoveredFile
UpdateFile re-classifies a single file (after a change event) and updates the discovery cache. Returns the updated DiscoveredFile.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager coordinates workspace scanning, project context building, and repo-wide diagnostic publishing. It is the top-level orchestrator for cross-file OpenAPI analysis.
func NewManager ¶
func NewManager(indexCache *openapi.IndexCache, logger *slog.Logger) *Manager
NewManager creates a project Manager.
func (*Manager) Initialize ¶
Initialize performs workspace discovery and builds project contexts for all root documents. Call this on server initialized.
func (*Manager) OnFileChanged ¶
OnFileChanged should be called when a file is modified. It rebuilds the affected project indexes and re-publishes diagnostics.
func (*Manager) OnFileCreated ¶
OnFileCreated should be called when a new file appears. It may need to add the file to existing projects or create new ones.
func (*Manager) OnFileDeleted ¶
OnFileDeleted should be called when a file is removed.
func (*Manager) ProjectForFile ¶
func (m *Manager) ProjectForFile(uri string) *ProjectContext
ProjectForFile returns the ProjectContext that contains the given URI. Returns nil if the file is not part of any known project.
func (*Manager) Projects ¶
func (m *Manager) Projects() map[string]*ProjectContext
Projects returns all current project contexts.
func (*Manager) ResolverForFile ¶
func (m *Manager) ResolverForFile(uri string) rules.CrossRefResolver
ResolverForFile returns a CrossRefResolver for the given file's project, satisfying the rules.CrossRefResolver interface. Returns nil if the file is not part of any known project.
func (*Manager) SetAnalyzers ¶
func (m *Manager) SetAnalyzers(a []rules.NamedAnalyzer)
SetAnalyzers sets the rule analyzers to run during startup diagnostics.
func (*Manager) SetOnDiscovered ¶
func (m *Manager) SetOnDiscovered(fn func([]*DiscoveredFile))
SetOnDiscovered registers a callback that receives the full workspace file list after discovery completes and before project contexts are built.
func (*Manager) SetPublish ¶
func (m *Manager) SetPublish(fn PublishFunc)
SetPublish sets the function used to send project-level diagnostics.
func (*Manager) SetResolver ¶
func (m *Manager) SetResolver(resolver rules.CrossRefResolver)
SetResolver sets the cross-file resolver used for analyzer inputs and unresolved-ref checks. When nil, the manager falls back to project-local resolvers.
func (*Manager) SetShouldPublish ¶
SetShouldPublish sets a URI-level filter for project diagnostic publishing. When nil, all URIs are publishable.
type ProjectContext ¶
type ProjectContext struct {
RootURI string
Docs map[string]*openapi.Index
Graph *FileGraph
Resolver *CrossFileResolver
// contains filtered or unexported fields
}
ProjectContext represents a single OpenAPI "project" consisting of a root document and all files transitively referenced via $ref. It is analogous to a TypeScript Program that includes all source files reachable from the tsconfig entry points.
func BuildProjectContext ¶
func BuildProjectContext(rootURI string, indexCache *openapi.IndexCache, logger *slog.Logger) (*ProjectContext, error)
BuildProjectContext creates a ProjectContext starting from a root document URI. It reads the root file from disk, builds its index, follows all external $refs transitively, and constructs the dependency graph.
The indexCache is consulted first; if the URI is already cached (e.g., from an open document), that index is used instead of re-reading from disk.
func (*ProjectContext) AllURIs ¶
func (p *ProjectContext) AllURIs() []string
AllURIs returns every file URI in the project.
func (*ProjectContext) ContainsFile ¶
func (p *ProjectContext) ContainsFile(uri string) bool
ContainsFile reports whether the given URI is part of this project. The URI is normalized before lookup to handle encoding differences.
func (*ProjectContext) DocIndex ¶
func (p *ProjectContext) DocIndex(uri string) *openapi.Index
DocIndex returns the index for a single URI, or nil if not found.
func (*ProjectContext) DocsSnapshot ¶
func (p *ProjectContext) DocsSnapshot() map[string]*openapi.Index
DocsSnapshot returns a shallow copy of the Docs map for safe iteration.
func (*ProjectContext) GetResolver ¶
func (p *ProjectContext) GetResolver() *CrossFileResolver
GetResolver returns the current cross-file resolver.
func (*ProjectContext) RebuildIndex ¶
func (p *ProjectContext) RebuildIndex(uri string, cache *openapi.IndexCache) error
RebuildIndex re-indexes a single file within the project, updating the graph and resolver. Newly referenced files are loaded transitively.
type PublishFunc ¶
type PublishFunc func(ctx context.Context, uri protocol.DocumentURI, diags []protocol.Diagnostic) error
PublishFunc sends diagnostics for a given URI to the LSP client.
type ResolveResult ¶
ResolveResult holds the outcome of a cross-file $ref resolution.