UNPKG

svelte-language-server

Version:
101 lines (100 loc) 4.16 kB
import ts from 'typescript'; import { PublishDiagnosticsParams, RelativePattern, TextDocumentContentChangeEvent } from 'vscode-languageserver'; import { Document, DocumentManager } from '../../lib/documents'; import { LSConfigManager } from '../../ls-config'; import { DocumentSnapshot, SvelteDocumentSnapshot } from './DocumentSnapshot'; import { LanguageServiceContainer } from './service'; interface LSAndTSDocResolverOptions { notifyExceedSizeLimit?: () => void; /** * True, if used in the context of svelte-check */ isSvelteCheck?: boolean; /** * This should only be set via svelte-check. Makes sure all documents are resolved to that tsconfig. Has to be absolute. */ tsconfigPath?: string; onProjectReloaded?: () => void; reportConfigError?: (diagnostic: PublishDiagnosticsParams) => void; watch?: boolean; tsSystem?: ts.System; watchDirectory?: (patterns: RelativePattern[]) => void; nonRecursiveWatchPattern?: string; /** * Optional callback invoked when a new snapshot is created. * Passes the absolute file path of the created snapshot. * Consumers (like svelte-check) can derive the directory as needed. */ onFileSnapshotCreated?: (filePath: string) => void; } export declare class LSAndTSDocResolver { private readonly docManager; private readonly workspaceUris; private readonly configManager; private readonly options?; constructor(docManager: DocumentManager, workspaceUris: string[], configManager: LSConfigManager, options?: LSAndTSDocResolverOptions | undefined); /** * Create a svelte document -> should only be invoked with svelte files. */ private createDocument; private tsSystem; private globalSnapshotsManager; private extendedConfigCache; private getCanonicalFileName; private userPreferencesAccessor; private readonly packageJsonWatchers; private lsDocumentContext; private readonly watchedDirectories; getLSAndTSDoc(document: Document): Promise<{ tsDoc: SvelteDocumentSnapshot; lang: ts.LanguageService; userPreferences: ts.UserPreferences; lsContainer: LanguageServiceContainer; }>; /** * Retrieves the LS for operations that don't need cross-files information. * can save some time by not synchronizing languageService program */ getLsForSyntheticOperations(document: Document): Promise<{ tsDoc: SvelteDocumentSnapshot; lang: ts.LanguageService; userPreferences: ts.UserPreferences; }>; private getLSAndTSDocWorker; /** * Retrieves and updates the snapshot for the given document or path from * the ts service it primarily belongs into. * The update is mirrored in all other services, too. */ getOrCreateSnapshot(document: Document): Promise<SvelteDocumentSnapshot>; getOrCreateSnapshot(pathOrDoc: string | Document): Promise<DocumentSnapshot>; private updateSnapshot; /** * Updates snapshot path in all existing ts services and retrieves snapshot */ updateSnapshotPath(oldPath: string, newPath: string): Promise<void>; /** * Deletes snapshot in all existing ts services */ deleteSnapshot(filePath: string): Promise<void>; invalidateModuleCache(filePaths: string[]): Promise<void>; /** * Updates project files in all existing ts services */ updateProjectFiles(watcherNewFiles: string[]): Promise<void>; /** * Updates file in all ts services where it exists */ updateExistingTsOrJsFile(path: string, changes?: TextDocumentContentChangeEvent[]): Promise<void>; updateExistingSvelteFile(path: string): Promise<void>; private updateExistingFile; getTSService(filePath?: string): Promise<LanguageServiceContainer>; getTSServiceByConfigPath(tsconfigPath: string, workspacePath: string): Promise<LanguageServiceContainer>; private getUserPreferences; private getTsUserPreferences; private wrapWithPackageJsonMonitoring; private onPackageJsonWatchChange; private updateSnapshotsInDirectory; private watchDirectory; } export {};