Documentation
¶
Index ¶
- type Client
- type DocumentRegistry
- type DocumentRegistryHooks
- type Kind
- type LogLevel
- type Logger
- func (l *Logger) Close()
- func (l *Logger) EndGroup()
- func (l *Logger) Error(s string)
- func (l *Logger) HasLevel(level LogLevel) bool
- func (l *Logger) Info(s string)
- func (l *Logger) LoggingEnabled() bool
- func (l *Logger) PerfTrace(s string)
- func (l *Logger) SetFile(file string)
- func (l *Logger) StartGroup()
- type PendingReload
- type Project
- func (p *Project) AddRoot(info *ScriptInfo)
- func (p *Project) Close()
- func (p *Project) CurrentProgram() *compiler.Program
- func (p *Project) DefaultLibraryPath() string
- func (p *Project) FS() vfs.FS
- func (p *Project) GetCompilerOptions() *core.CompilerOptions
- func (p *Project) GetCurrentDirectory() string
- func (p *Project) GetDefaultLibraryPath() string
- func (p *Project) GetLanguageServiceForRequest(ctx context.Context) (*ls.LanguageService, func())
- func (p *Project) GetProgram() *compiler.Program
- func (p *Project) GetRootFileNames() []string
- func (p *Project) GetSourceFile(fileName string, path tspath.Path, languageVersion core.ScriptTarget) *ast.SourceFile
- func (p *Project) Kind() Kind
- func (p *Project) LoadConfig() error
- func (p *Project) MarkFileAsDirty(path tspath.Path)
- func (p *Project) Name() string
- func (p *Project) NewLine() string
- func (p *Project) RemoveFile(info *ScriptInfo, fileExists bool, detachFromProject bool)
- func (p *Project) Trace(msg string)
- func (p *Project) Version() int
- type ProjectHost
- type ScriptInfo
- type Service
- func (s *Service) ChangeFile(document lsproto.VersionedTextDocumentIdentifier, ...) error
- func (s *Service) Client() Client
- func (s *Service) Close()
- func (s *Service) CloseFile(fileName string)
- func (s *Service) DefaultLibraryPath() string
- func (s *Service) DocumentRegistry() *DocumentRegistry
- func (s *Service) EnsureDefaultProjectForFile(fileName string) (*ScriptInfo, *Project)
- func (s *Service) EnsureDefaultProjectForURI(url lsproto.DocumentUri) *Project
- func (s *Service) FS() vfs.FS
- func (s *Service) GetCurrentDirectory() string
- func (s *Service) GetOrCreateScriptInfoForFile(fileName string, path tspath.Path, scriptKind core.ScriptKind) *ScriptInfo
- func (s *Service) GetScriptInfo(fileName string) *ScriptInfo
- func (s *Service) GetScriptInfoByPath(path tspath.Path) *ScriptInfo
- func (s *Service) IsWatchEnabled() bool
- func (s *Service) Log(msg string)
- func (s *Service) MarkFileSaved(fileName string, text string)
- func (s *Service) NewLine() string
- func (s *Service) OnDiscoveredSymlink(info *ScriptInfo)
- func (s *Service) OnWatchedFilesChanged(ctx context.Context, changes []*lsproto.FileEvent) error
- func (s *Service) OpenFile(fileName string, fileContent string, scriptKind core.ScriptKind, ...)
- func (s *Service) PositionEncoding() lsproto.PositionEncodingKind
- func (s *Service) Projects() []*Project
- func (s *Service) SourceFileCount() int
- type ServiceHost
- type ServiceOptions
- type WatcherHandle
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { WatchFiles(ctx context.Context, watchers []*lsproto.FileSystemWatcher) (WatcherHandle, error) UnwatchFiles(ctx context.Context, handle WatcherHandle) error RefreshDiagnostics(ctx context.Context) error }
type DocumentRegistry ¶
type DocumentRegistry struct { Options tspath.ComparePathsOptions Hooks DocumentRegistryHooks // contains filtered or unexported fields }
The document registry represents a store of SourceFile objects that can be shared between multiple LanguageService instances.
func (*DocumentRegistry) AcquireDocument ¶
func (r *DocumentRegistry) AcquireDocument(scriptInfo *ScriptInfo, compilerOptions *core.CompilerOptions, oldSourceFile *ast.SourceFile, oldCompilerOptions *core.CompilerOptions) *ast.SourceFile
AcquireDocument gets a SourceFile from the registry if it exists as the same version tracked by the ScriptInfo. If it does not exist, or is out of date, it creates a new SourceFile and stores it, tracking that the caller has referenced it. If an oldSourceFile is passed, the registry will decrement its reference count and remove it from the registry if the count reaches 0. (If the old file and new file have the same key, this results in a no-op to the ref count.)
This code is greatly simplified compared to the old TS codebase because of the lack of incremental parsing. Previously, source files could be updated and reused by the same LanguageService instance over time, as well as across multiple instances. Here, we still reuse files across multiple LanguageServices, but we only reuse them across Program updates when the files haven't changed.
func (*DocumentRegistry) ReleaseDocument ¶
func (r *DocumentRegistry) ReleaseDocument(file *ast.SourceFile, compilerOptions *core.CompilerOptions)
type DocumentRegistryHooks ¶
type DocumentRegistryHooks struct {
OnReleaseDocument func(file *ast.SourceFile)
}
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func (*Logger) LoggingEnabled ¶
func (*Logger) StartGroup ¶
func (l *Logger) StartGroup()
type PendingReload ¶
type PendingReload int
const ( PendingReloadNone PendingReload = iota PendingReloadFileNames PendingReloadFull )
type Project ¶
type Project struct {
// contains filtered or unexported fields
}
func NewConfiguredProject ¶
func NewConfiguredProject(configFileName string, configFilePath tspath.Path, host ProjectHost) *Project
func NewInferredProject ¶
func NewInferredProject(compilerOptions *core.CompilerOptions, currentDirectory string, projectRootPath tspath.Path, host ProjectHost) *Project
func NewProject ¶
func NewProject(name string, kind Kind, currentDirectory string, host ProjectHost) *Project
func (*Project) AddRoot ¶
func (p *Project) AddRoot(info *ScriptInfo)
func (*Project) CurrentProgram ¶
func (*Project) DefaultLibraryPath ¶
DefaultLibraryPath implements compiler.CompilerHost.
func (*Project) GetCompilerOptions ¶
func (p *Project) GetCompilerOptions() *core.CompilerOptions
func (*Project) GetCurrentDirectory ¶
GetCurrentDirectory implements compiler.CompilerHost.
func (*Project) GetDefaultLibraryPath ¶
GetDefaultLibraryPath implements compiler.CompilerHost.
func (*Project) GetLanguageServiceForRequest ¶
func (p *Project) GetLanguageServiceForRequest(ctx context.Context) (*ls.LanguageService, func())
func (*Project) GetProgram ¶
Updates the program if needed.
func (*Project) GetRootFileNames ¶
func (*Project) GetSourceFile ¶
func (p *Project) GetSourceFile(fileName string, path tspath.Path, languageVersion core.ScriptTarget) *ast.SourceFile
GetSourceFile implements compiler.CompilerHost.
func (*Project) LoadConfig ¶
func (*Project) MarkFileAsDirty ¶
func (*Project) RemoveFile ¶
func (p *Project) RemoveFile(info *ScriptInfo, fileExists bool, detachFromProject bool)
type ProjectHost ¶
type ProjectHost interface { tsoptions.ParseConfigHost NewLine() string DefaultLibraryPath() string DocumentRegistry() *DocumentRegistry GetScriptInfoByPath(path tspath.Path) *ScriptInfo GetOrCreateScriptInfoForFile(fileName string, path tspath.Path, scriptKind core.ScriptKind) *ScriptInfo OnDiscoveredSymlink(info *ScriptInfo) Log(s string) PositionEncoding() lsproto.PositionEncodingKind IsWatchEnabled() bool Client() Client }
type ScriptInfo ¶
type ScriptInfo struct {
// contains filtered or unexported fields
}
func NewScriptInfo ¶
func NewScriptInfo(fileName string, path tspath.Path, scriptKind core.ScriptKind, fs vfs.FS) *ScriptInfo
func (*ScriptInfo) FileName ¶
func (s *ScriptInfo) FileName() string
func (*ScriptInfo) LineMap ¶
func (s *ScriptInfo) LineMap() *ls.LineMap
func (*ScriptInfo) Path ¶
func (s *ScriptInfo) Path() tspath.Path
func (*ScriptInfo) SetTextFromDisk ¶
func (s *ScriptInfo) SetTextFromDisk(newText string)
func (*ScriptInfo) Text ¶
func (s *ScriptInfo) Text() string
func (*ScriptInfo) Version ¶
func (s *ScriptInfo) Version() int
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(host ServiceHost, options ServiceOptions) *Service
func (*Service) ChangeFile ¶
func (s *Service) ChangeFile(document lsproto.VersionedTextDocumentIdentifier, changes []lsproto.TextDocumentContentChangeEvent) error
func (*Service) DefaultLibraryPath ¶
DefaultLibraryPath implements ProjectHost.
func (*Service) DocumentRegistry ¶
func (s *Service) DocumentRegistry() *DocumentRegistry
DocumentRegistry implements ProjectHost.
func (*Service) EnsureDefaultProjectForFile ¶
func (s *Service) EnsureDefaultProjectForFile(fileName string) (*ScriptInfo, *Project)
func (*Service) EnsureDefaultProjectForURI ¶
func (s *Service) EnsureDefaultProjectForURI(url lsproto.DocumentUri) *Project
func (*Service) GetCurrentDirectory ¶
GetCurrentDirectory implements ProjectHost.
func (*Service) GetOrCreateScriptInfoForFile ¶
func (s *Service) GetOrCreateScriptInfoForFile(fileName string, path tspath.Path, scriptKind core.ScriptKind) *ScriptInfo
GetOrCreateScriptInfoForFile implements ProjectHost.
func (*Service) GetScriptInfo ¶
func (s *Service) GetScriptInfo(fileName string) *ScriptInfo
func (*Service) GetScriptInfoByPath ¶
func (s *Service) GetScriptInfoByPath(path tspath.Path) *ScriptInfo
func (*Service) IsWatchEnabled ¶
IsWatchEnabled implements ProjectHost.
func (*Service) MarkFileSaved ¶
func (*Service) OnDiscoveredSymlink ¶
func (s *Service) OnDiscoveredSymlink(info *ScriptInfo)
func (*Service) OnWatchedFilesChanged ¶
func (*Service) PositionEncoding ¶
func (s *Service) PositionEncoding() lsproto.PositionEncodingKind
PositionEncoding implements ProjectHost.
func (*Service) SourceFileCount ¶
SourceFileCount should only be used for testing.
type ServiceHost ¶
type ServiceOptions ¶
type ServiceOptions struct { Logger *Logger PositionEncoding lsproto.PositionEncodingKind WatchEnabled bool }
type WatcherHandle ¶
type WatcherHandle string