import { CancellationToken, Disposable } from 'vscode-languageserver'; import { MessagePort, Worker } from 'worker_threads'; import { AnalysisCompleteCallback, AnalysisResults } from './analyzer/analysis'; import { InvalidatedReason } from './analyzer/backgroundAnalysisProgram'; import { ImportResolver } from './analyzer/importResolver'; import { OpenFileOptions, Program } from './analyzer/program'; import { BackgroundThreadBase } from './backgroundThreadBase'; import { ConfigOptions } from './common/configOptions'; import { ConsoleInterface, LogLevel } from './common/console'; import { Diagnostic } from './common/diagnostic'; import { Host, HostKind } from './common/host'; import { LogTracker } from './common/logTracker'; import { ServiceProvider } from './common/serviceProvider'; import { Range } from './common/textRange'; import { Uri } from './common/uri/uri'; import { ProgramView } from './common/extensibility'; export interface IBackgroundAnalysis extends Disposable { setProgramView(program: Program): void; setCompletionCallback(callback?: AnalysisCompleteCallback): void; setImportResolver(importResolver: ImportResolver): void; setConfigOptions(configOptions: ConfigOptions): void; setTrackedFiles(fileUris: Uri[]): void; setAllowedThirdPartyImports(importNames: string[]): void; ensurePartialStubPackages(executionRoot: string | undefined): void; setFileOpened(fileUri: Uri, version: number | null, contents: string, options: OpenFileOptions): void; updateChainedUri(fileUri: Uri, chainedUri: Uri | undefined): void; setFileClosed(fileUri: Uri, isTracked?: boolean): void; addInterimFile(fileUri: Uri): void; markAllFilesDirty(evenIfContentsAreSame: boolean): void; markFilesDirty(fileUris: Uri[], evenIfContentsAreSame: boolean): void; startAnalysis(token: CancellationToken): void; analyzeFile(fileUri: Uri, token: CancellationToken): Promise; analyzeFileAndGetDiagnostics(fileUri: Uri, token: CancellationToken): Promise; getDiagnosticsForRange(fileUri: Uri, range: Range, token: CancellationToken): Promise; writeTypeStub(targetImportPath: Uri, targetIsSingleFile: boolean, stubPath: Uri, token: CancellationToken): Promise; invalidateAndForceReanalysis(reason: InvalidatedReason): void; restart(): void; shutdown(): void; } export declare class BackgroundAnalysisBase implements IBackgroundAnalysis { protected console: ConsoleInterface; private readonly _analysisCancellationMap; private _worker; private _onAnalysisCompletion; private _messageChannel; protected program: ProgramView | undefined; protected constructor(console: ConsoleInterface); dispose(): void; setProgramView(programView: Program): void; setCompletionCallback(callback?: AnalysisCompleteCallback): void; setImportResolver(importResolver: ImportResolver): void; setConfigOptions(configOptions: ConfigOptions): void; setTrackedFiles(fileUris: Uri[]): void; setAllowedThirdPartyImports(importNames: string[]): void; ensurePartialStubPackages(executionRoot: string | undefined): void; setFileOpened(fileUri: Uri, version: number | null, contents: string, options: OpenFileOptions): void; updateChainedUri(fileUri: Uri, chainedUri: Uri | undefined): void; setFileClosed(fileUri: Uri, isTracked?: boolean): void; addInterimFile(fileUri: Uri): void; markAllFilesDirty(evenIfContentsAreSame: boolean): void; markFilesDirty(fileUris: Uri[], evenIfContentsAreSame: boolean): void; startAnalysis(token: CancellationToken): void; analyzeFile(fileUri: Uri, token: CancellationToken): Promise; analyzeFileAndGetDiagnostics(fileUri: Uri, token: CancellationToken): Promise; getDiagnosticsForRange(fileUri: Uri, range: Range, token: CancellationToken): Promise; writeTypeStub(targetImportPath: Uri, targetIsSingleFile: boolean, stubPath: Uri, token: CancellationToken): Promise; invalidateAndForceReanalysis(reason: InvalidatedReason): void; restart(): void; shutdown(): void; protected setup(worker: Worker): void; protected onMessage(msg: BackgroundResponse): void; protected enqueueRequest(request: BackgroundRequest): void; protected log(level: LogLevel, msg: string): void; protected handleBackgroundResponse(msg: BackgroundResponse): void; } export declare abstract class BackgroundAnalysisRunnerBase extends BackgroundThreadBase { protected serviceProvider: ServiceProvider; private _configOptions; private _program; private _responsePort; protected importResolver: ImportResolver; protected logTracker: LogTracker; protected isCaseSensitive: boolean; protected constructor(serviceProvider: ServiceProvider); get program(): Program; get responsePort(): MessagePort; start(): void; protected onMessage(msg: BackgroundRequest): void; protected abstract createHost(): Host; protected abstract createImportResolver(serviceProvider: ServiceProvider, options: ConfigOptions, host: Host): ImportResolver; protected handleAnalyze(port: MessagePort, token: CancellationToken): void; protected handleResumeAnalysis(port: MessagePort, token: CancellationToken): void; protected handleAnalyzeFile(fileUri: Uri, token: CancellationToken): boolean; protected handleAnalyzeFileAndGetDiagnostics(fileUri: Uri, token: CancellationToken): Diagnostic[]; protected handleGetDiagnosticsForRange(fileUri: Uri, range: Range, token: CancellationToken): Diagnostic[]; protected handleWriteTypeStub(targetImportPath: Uri, targetIsSingleFile: boolean, stubPath: Uri, token: CancellationToken): void; protected handleSetImportResolver(hostKind: HostKind): void; protected handleSetConfigOptions(configOptions: ConfigOptions): void; protected handleSetTrackedFiles(fileUris: Uri[]): void; protected handleSetAllowedThirdPartyImports(importNames: string[]): void; protected handleEnsurePartialStubPackages(executionRoot: string | undefined): void; protected handleSetFileOpened(fileUri: Uri, version: number | null, contents: string, options: OpenFileOptions | undefined): void; protected handleUpdateChainedFileUri(fileUri: Uri, chainedFileUri: Uri | undefined): void; protected handleSetFileClosed(fileUri: Uri, isTracked: boolean | undefined): void; protected handleAddInterimFile(fileUri: Uri): void; protected handleMarkFilesDirty(fileUris: Uri[], evenIfContentsAreSame: boolean): void; protected handleMarkAllFilesDirty(evenIfContentsAreSame: boolean): void; protected handleInvalidateAndForceReanalysis(reason: InvalidatedReason): void; protected handleRestart(): void; protected handleShutdown(): void; protected analysisDone(port: MessagePort, token: CancellationToken): void; protected onAnalysisCompletion(port: MessagePort, result: AnalysisResults): void; private _onMessageWrapper; private _reportDiagnostics; private _analysisPaused; } export type BackgroundRequestKind = 'start' | 'analyze' | 'resumeAnalysis' | 'setConfigOptions' | 'setTrackedFiles' | 'setAllowedThirdPartyImports' | 'ensurePartialStubPackages' | 'setFileOpened' | 'updateChainedFileUri' | 'setFileClosed' | 'markAllFilesDirty' | 'markFilesDirty' | 'invalidateAndForceReanalysis' | 'restart' | 'getDiagnosticsForRange' | 'writeTypeStub' | 'setImportResolver' | 'shutdown' | 'addInterimFile' | 'analyzeFile' | 'analyzeFileAndGetDiagnostics' | 'cacheUsageBuffer'; export interface BackgroundRequest { requestType: BackgroundRequestKind; data: string | null; port?: MessagePort | undefined; sharedUsageBuffer?: SharedArrayBuffer; } export type BackgroundResponseKind = 'log' | 'analysisResult' | 'analysisPaused' | 'analysisDone'; export interface BackgroundResponse { requestType: BackgroundResponseKind; data: string | null; } export interface RefreshOptions { changesOnly: boolean; }