Documentation
¶
Index ¶
- type APISnapshotRequest
- type ATAStateChange
- type Client
- type Config
- type ConfigFileRegistry
- type CreateProgramResult
- type FileChange
- type FileChangeKind
- type FileChangeSummary
- type FileContent
- type FileHandle
- type FileSource
- type Kind
- type ParseCache
- type ParseCacheOptions
- type PendingReload
- type ProgramUpdateKind
- type Project
- func (p *Project) Clone() *Project
- func (p *Project) CloneWatchers(workspaceDir string, libDir string) (programFilesWatch *WatchedFiles[patternsAndIgnored], ...)
- func (p *Project) ComputeTypingsInfo() ata.TypingsInfo
- func (p *Project) ConfigFileName() string
- func (p *Project) ConfigFilePath() tspath.Path
- func (p *Project) CreateProgram() CreateProgramResult
- func (p *Project) GetProgram() *compiler.Program
- func (p *Project) GetTypeAcquisition() *core.TypeAcquisition
- func (p *Project) GetUnresolvedImports() *collections.Set[string]
- func (p *Project) IsSourceFromProjectReference(path tspath.Path) bool
- func (p *Project) Name() string
- func (p *Project) ShouldTriggerATA(snapshotID uint64) bool
- type ProjectCollection
- func (c *ProjectCollection) ConfiguredProject(path tspath.Path) *Project
- func (c *ProjectCollection) ConfiguredProjects() []*Project
- func (c *ProjectCollection) GetDefaultProject(fileName string, path tspath.Path) *Project
- func (c *ProjectCollection) GetProjectByPath(projectPath tspath.Path) *Project
- func (c *ProjectCollection) InferredProject() *Project
- func (c *ProjectCollection) Projects() []*Project
- func (c *ProjectCollection) ProjectsByPath() *collections.OrderedMap[tspath.Path, *Project]
- type Session
- func (s *Session) Close()
- func (s *Session) Configure(userPreferences *ls.UserPreferences)
- func (s *Session) DidChangeCompilerOptionsForInferredProjects(ctx context.Context, options *core.CompilerOptions)
- func (s *Session) DidChangeFile(ctx context.Context, uri lsproto.DocumentUri, version int32, ...)
- func (s *Session) DidChangeWatchedFiles(ctx context.Context, changes []*lsproto.FileEvent)
- func (s *Session) DidCloseFile(ctx context.Context, uri lsproto.DocumentUri)
- func (s *Session) DidOpenFile(ctx context.Context, uri lsproto.DocumentUri, version int32, content string, ...)
- func (s *Session) DidSaveFile(ctx context.Context, uri lsproto.DocumentUri)
- func (s *Session) FS() vfs.FS
- func (s *Session) GetCurrentDirectory() string
- func (s *Session) GetLanguageService(ctx context.Context, uri lsproto.DocumentUri) (*ls.LanguageService, error)
- func (s *Session) InitializeWithConfig(userPreferences *ls.UserPreferences)
- func (s *Session) NewUserPreferences() *ls.UserPreferences
- func (s *Session) NpmInstall(cwd string, npmInstallArgs []string) ([]byte, error)
- func (s *Session) OpenProject(ctx context.Context, configFileName string) (*Project, error)
- func (s *Session) ScheduleDiagnosticsRefresh()
- func (s *Session) Snapshot() (*Snapshot, func())
- func (s *Session) Trace(msg string)
- func (s *Session) UpdateSnapshot(ctx context.Context, overlays map[tspath.Path]*overlay, change SnapshotChange) *Snapshot
- func (s *Session) UserPreferences() *ls.UserPreferences
- func (s *Session) WaitForBackgroundTasks()
- type SessionInit
- type SessionOptions
- type Snapshot
- func (s *Snapshot) Clone(ctx context.Context, change SnapshotChange, overlays map[tspath.Path]*overlay, ...) *Snapshot
- func (s *Snapshot) Converters() *ls.Converters
- func (s *Snapshot) Deref() bool
- func (s *Snapshot) FormatOptions() *format.FormatCodeSettings
- func (s *Snapshot) GetDefaultProject(uri lsproto.DocumentUri) *Project
- func (s *Snapshot) GetECMALineInfo(fileName string) *sourcemap.ECMALineInfo
- func (s *Snapshot) GetFile(fileName string) FileHandle
- func (s *Snapshot) ID() uint64
- func (s *Snapshot) LSPLineMap(fileName string) *ls.LSPLineMap
- func (s *Snapshot) ReadFile(fileName string) (string, bool)
- func (s *Snapshot) Ref()
- func (s *Snapshot) UseCaseSensitiveFileNames() bool
- func (s *Snapshot) UserPreferences() *ls.UserPreferences
- type SnapshotChange
- type UpdateReason
- type WatchedFiles
- type WatcherID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APISnapshotRequest ¶
type APISnapshotRequest struct {
OpenProjects *collections.Set[string]
CloseProjects *collections.Set[tspath.Path]
UpdateProjects *collections.Set[tspath.Path]
}
type ATAStateChange ¶
type ATAStateChange struct {
ProjectID tspath.Path
// TypingsInfo is the new typings info for the project.
TypingsInfo *ata.TypingsInfo
// TypingsFiles is the new list of typing files for the project.
TypingsFiles []string
// TypingsFilesToWatch is the new list of typing files to watch for changes.
TypingsFilesToWatch []string
Logs *logging.LogTree
}
ATAStateChange represents a change to a project's ATA state.
type ConfigFileRegistry ¶
type ConfigFileRegistry struct {
// contains filtered or unexported fields
}
func (*ConfigFileRegistry) GetAncestorConfigFileName ¶
func (c *ConfigFileRegistry) GetAncestorConfigFileName(path tspath.Path, higherThanConfig string) string
func (*ConfigFileRegistry) GetConfig ¶
func (c *ConfigFileRegistry) GetConfig(path tspath.Path) *tsoptions.ParsedCommandLine
func (*ConfigFileRegistry) GetConfigFileName ¶
func (c *ConfigFileRegistry) GetConfigFileName(path tspath.Path) string
type CreateProgramResult ¶
type CreateProgramResult struct {
Program *compiler.Program
UpdateKind ProgramUpdateKind
CheckerPool *checkerPool
}
type FileChange ¶
type FileChange struct {
Kind FileChangeKind
URI lsproto.DocumentUri
Hash xxh3.Uint128 // Only set for Close
Version int32 // Only set for Open/Change
Content string // Only set for Open
LanguageKind lsproto.LanguageKind // Only set for Open
Changes []lsproto.TextDocumentContentChangePartialOrWholeDocument // Only set for Change
}
type FileChangeKind ¶
type FileChangeKind int
const ( FileChangeKindOpen FileChangeKind = iota FileChangeKindClose FileChangeKindChange FileChangeKindSave FileChangeKindWatchCreate FileChangeKindWatchChange FileChangeKindWatchDelete )
func (FileChangeKind) IsWatchKind ¶
func (k FileChangeKind) IsWatchKind() bool
type FileChangeSummary ¶
type FileChangeSummary struct {
// Only one file can be opened at a time per request
Opened lsproto.DocumentUri
// Values are the content hashes of the overlays before closing.
Closed map[lsproto.DocumentUri]xxh3.Uint128
Changed collections.Set[lsproto.DocumentUri]
// Only set when file watching is enabled
Created collections.Set[lsproto.DocumentUri]
// Only set when file watching is enabled
Deleted collections.Set[lsproto.DocumentUri]
// IncludesWatchChangeOutsideNodeModules is true if the summary includes a create, change, or delete watch
// event of a file outside a node_modules directory.
IncludesWatchChangeOutsideNodeModules bool
}
func (FileChangeSummary) HasExcessiveNonCreateWatchEvents ¶
func (f FileChangeSummary) HasExcessiveNonCreateWatchEvents() bool
func (FileChangeSummary) HasExcessiveWatchEvents ¶
func (f FileChangeSummary) HasExcessiveWatchEvents() bool
func (FileChangeSummary) IsEmpty ¶
func (f FileChangeSummary) IsEmpty() bool
type FileContent ¶
type FileHandle ¶
type FileHandle interface {
FileContent
FileName() string
Version() int32
MatchesDiskText() bool
IsOverlay() bool
LSPLineMap() *ls.LSPLineMap
ECMALineInfo() *sourcemap.ECMALineInfo
Kind() core.ScriptKind
}
type FileSource ¶
type FileSource interface {
FS() vfs.FS
GetFile(fileName string) FileHandle
}
type ParseCache ¶
type ParseCache struct {
Options ParseCacheOptions
// contains filtered or unexported fields
}
func (*ParseCache) Acquire ¶
func (c *ParseCache) Acquire( fh FileContent, opts ast.SourceFileParseOptions, scriptKind core.ScriptKind, ) *ast.SourceFile
func (*ParseCache) Deref ¶
func (c *ParseCache) Deref(file *ast.SourceFile)
func (*ParseCache) Ref ¶
func (c *ParseCache) Ref(file *ast.SourceFile)
type ParseCacheOptions ¶
type ParseCacheOptions struct {
// DisableDeletion prevents entries from being removed from the cache.
// Used for testing.
DisableDeletion bool
}
type PendingReload ¶
type PendingReload int
const ( PendingReloadNone PendingReload = iota PendingReloadFileNames PendingReloadFull )
type ProgramUpdateKind ¶
type ProgramUpdateKind int
const ( ProgramUpdateKindNone ProgramUpdateKind = iota ProgramUpdateKindCloned ProgramUpdateKindSameFileNames ProgramUpdateKindNewFiles )
type Project ¶
type Project struct {
Kind Kind
CommandLine *tsoptions.ParsedCommandLine
Program *compiler.Program
// The kind of update that was performed on the program last time it was updated.
ProgramUpdateKind ProgramUpdateKind
// The ID of the snapshot that created the program stored in this project.
ProgramLastUpdate uint64
// contains filtered or unexported fields
}
Project represents a TypeScript project. If changing struct fields, also update the Clone method.
func NewConfiguredProject ¶
func NewInferredProject ¶
func NewProject ¶
func (*Project) CloneWatchers ¶
func (p *Project) CloneWatchers(workspaceDir string, libDir string) (programFilesWatch *WatchedFiles[patternsAndIgnored], failedLookupsWatch *WatchedFiles[map[tspath.Path]string], affectingLocationsWatch *WatchedFiles[map[tspath.Path]string])
func (*Project) ComputeTypingsInfo ¶
func (p *Project) ComputeTypingsInfo() ata.TypingsInfo
func (*Project) ConfigFileName ¶
ConfigFileName panics if Kind() is not KindConfigured.
func (*Project) ConfigFilePath ¶
ConfigFilePath panics if Kind() is not KindConfigured.
func (*Project) CreateProgram ¶
func (p *Project) CreateProgram() CreateProgramResult
func (*Project) GetProgram ¶
func (*Project) GetTypeAcquisition ¶
func (p *Project) GetTypeAcquisition() *core.TypeAcquisition
GetTypeAcquisition returns the type acquisition settings for this project.
func (*Project) GetUnresolvedImports ¶
func (p *Project) GetUnresolvedImports() *collections.Set[string]
GetUnresolvedImports extracts unresolved imports from this project's program.
func (*Project) IsSourceFromProjectReference ¶
func (*Project) ShouldTriggerATA ¶
ShouldTriggerATA determines if ATA should be triggered for this project.
type ProjectCollection ¶
type ProjectCollection struct {
// contains filtered or unexported fields
}
func (*ProjectCollection) ConfiguredProject ¶
func (c *ProjectCollection) ConfiguredProject(path tspath.Path) *Project
func (*ProjectCollection) ConfiguredProjects ¶
func (c *ProjectCollection) ConfiguredProjects() []*Project
ConfiguredProjects returns all configured projects in a stable order.
func (*ProjectCollection) GetDefaultProject ¶
func (c *ProjectCollection) GetDefaultProject(fileName string, path tspath.Path) *Project
!!! result could be cached
func (*ProjectCollection) GetProjectByPath ¶
func (c *ProjectCollection) GetProjectByPath(projectPath tspath.Path) *Project
func (*ProjectCollection) InferredProject ¶
func (c *ProjectCollection) InferredProject() *Project
func (*ProjectCollection) Projects ¶
func (c *ProjectCollection) Projects() []*Project
Projects returns all projects, including the inferred project if it exists, in a stable order.
func (*ProjectCollection) ProjectsByPath ¶
func (c *ProjectCollection) ProjectsByPath() *collections.OrderedMap[tspath.Path, *Project]
ProjectsByPath returns an ordered map of configured projects keyed by their config file path, plus the inferred project, if it exists, with the key `inferredProjectName`.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session manages the state of an LSP session. It receives textDocument events and requests for LanguageService objects from the LPS server and processes them into immutable snapshots as the data source for LanguageServices. When Session transitions from one snapshot to the next, it diffs them and updates file watchers and Automatic Type Acquisition (ATA) state accordingly.
func NewSession ¶
func NewSession(init *SessionInit) *Session
func (*Session) Configure ¶
func (s *Session) Configure(userPreferences *ls.UserPreferences)
func (*Session) DidChangeCompilerOptionsForInferredProjects ¶
func (s *Session) DidChangeCompilerOptionsForInferredProjects(ctx context.Context, options *core.CompilerOptions)
func (*Session) DidChangeFile ¶
func (s *Session) DidChangeFile(ctx context.Context, uri lsproto.DocumentUri, version int32, changes []lsproto.TextDocumentContentChangePartialOrWholeDocument)
func (*Session) DidChangeWatchedFiles ¶
func (*Session) DidCloseFile ¶
func (s *Session) DidCloseFile(ctx context.Context, uri lsproto.DocumentUri)
func (*Session) DidOpenFile ¶
func (s *Session) DidOpenFile(ctx context.Context, uri lsproto.DocumentUri, version int32, content string, languageKind lsproto.LanguageKind)
func (*Session) DidSaveFile ¶
func (s *Session) DidSaveFile(ctx context.Context, uri lsproto.DocumentUri)
func (*Session) GetCurrentDirectory ¶
GetCurrentDirectory implements module.ResolutionHost
func (*Session) GetLanguageService ¶
func (s *Session) GetLanguageService(ctx context.Context, uri lsproto.DocumentUri) (*ls.LanguageService, error)
func (*Session) InitializeWithConfig ¶
func (s *Session) InitializeWithConfig(userPreferences *ls.UserPreferences)
func (*Session) NewUserPreferences ¶
func (s *Session) NewUserPreferences() *ls.UserPreferences
Gets original UserPreferences of the session
func (*Session) NpmInstall ¶
func (*Session) OpenProject ¶
func (*Session) ScheduleDiagnosticsRefresh ¶
func (s *Session) ScheduleDiagnosticsRefresh()
func (*Session) UpdateSnapshot ¶
func (*Session) UserPreferences ¶
func (s *Session) UserPreferences() *ls.UserPreferences
Gets current UserPreferences, always a copy
func (*Session) WaitForBackgroundTasks ¶
func (s *Session) WaitForBackgroundTasks()
WaitForBackgroundTasks waits for all background tasks to complete. This is intended to be used only for testing purposes.
type SessionInit ¶
type SessionInit struct {
Options *SessionOptions
FS vfs.FS
Client Client
Logger logging.Logger
NpmExecutor ata.NpmExecutor
ParseCache *ParseCache
}
type SessionOptions ¶
type SessionOptions struct {
CurrentDirectory string
DefaultLibraryPath string
TypingsLocation string
PositionEncoding lsproto.PositionEncodingKind
WatchEnabled bool
LoggingEnabled bool
DebounceDelay time.Duration
}
SessionOptions are the immutable initialization options for a session. Snapshots may reference them as a pointer since they never change.
type Snapshot ¶
type Snapshot struct {
ProjectCollection *ProjectCollection
ConfigFileRegistry *ConfigFileRegistry
// contains filtered or unexported fields
}
func NewSnapshot ¶
func NewSnapshot( id uint64, fs *snapshotFS, sessionOptions *SessionOptions, parseCache *ParseCache, extendedConfigCache *extendedConfigCache, configFileRegistry *ConfigFileRegistry, compilerOptionsForInferredProjects *core.CompilerOptions, config Config, toPath func(fileName string) tspath.Path, ) *Snapshot
NewSnapshot
func (*Snapshot) Converters ¶
func (s *Snapshot) Converters() *ls.Converters
func (*Snapshot) FormatOptions ¶
func (s *Snapshot) FormatOptions() *format.FormatCodeSettings
func (*Snapshot) GetDefaultProject ¶
func (s *Snapshot) GetDefaultProject(uri lsproto.DocumentUri) *Project
func (*Snapshot) GetECMALineInfo ¶
func (s *Snapshot) GetECMALineInfo(fileName string) *sourcemap.ECMALineInfo
func (*Snapshot) GetFile ¶
func (s *Snapshot) GetFile(fileName string) FileHandle
func (*Snapshot) LSPLineMap ¶
func (s *Snapshot) LSPLineMap(fileName string) *ls.LSPLineMap
func (*Snapshot) UseCaseSensitiveFileNames ¶
func (*Snapshot) UserPreferences ¶
func (s *Snapshot) UserPreferences() *ls.UserPreferences
type SnapshotChange ¶
type SnapshotChange struct {
// contains filtered or unexported fields
}
type UpdateReason ¶
type UpdateReason int
const ( UpdateReasonUnknown UpdateReason = iota UpdateReasonDidOpenFile UpdateReasonDidChangeCompilerOptionsForInferredProjects UpdateReasonRequestedLanguageServicePendingChanges UpdateReasonRequestedLanguageServiceProjectNotLoaded UpdateReasonRequestedLanguageServiceProjectDirty )
type WatchedFiles ¶
type WatchedFiles[T any] struct { // contains filtered or unexported fields }
func NewWatchedFiles ¶
func NewWatchedFiles[T any](name string, watchKind lsproto.WatchKind, computeGlobPatterns func(input T) patternsAndIgnored) *WatchedFiles[T]
func (*WatchedFiles[T]) Clone ¶
func (w *WatchedFiles[T]) Clone(input T) *WatchedFiles[T]
func (*WatchedFiles[T]) ID ¶
func (w *WatchedFiles[T]) ID() WatcherID
func (*WatchedFiles[T]) Name ¶
func (w *WatchedFiles[T]) Name() string
func (*WatchedFiles[T]) WatchKind ¶
func (w *WatchedFiles[T]) WatchKind() lsproto.WatchKind
func (*WatchedFiles[T]) Watchers ¶
func (w *WatchedFiles[T]) Watchers() (WatcherID, []*lsproto.FileSystemWatcher, map[string]struct{})
Source Files
¶
- api.go
- checkerpool.go
- client.go
- compilerhost.go
- configfileregistry.go
- configfileregistrybuilder.go
- extendedconfigcache.go
- filechange.go
- overlayfs.go
- parsecache.go
- programcounter.go
- project.go
- project_stringer_generated.go
- projectcollection.go
- projectcollectionbuilder.go
- session.go
- snapshot.go
- snapshotfs.go
- util.go
- watch.go