svelte-language-server
Version:
A language server for Svelte
95 lines (94 loc) • 3.89 kB
TypeScript
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;
}
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 {};