import { CancellationToken } from 'vscode-languageserver'; import { Declaration } from '../analyzer/declaration'; import { ImportResolver } from '../analyzer/importResolver'; import * as prog from '../analyzer/program'; import { IPythonMode } from '../analyzer/sourceFile'; import { SourceMapper } from '../analyzer/sourceMapper'; import { SymbolTable } from '../analyzer/symbol'; import { TypeEvaluator } from '../analyzer/typeEvaluatorTypes'; import { Diagnostic } from '../common/diagnostic'; import { ServerSettings } from '../common/languageServerInterface'; import { ParseNode } from '../parser/parseNodes'; import { ParseFileResults, ParserOutput } from '../parser/parser'; import { ConfigOptions } from './configOptions'; import { ConsoleInterface } from './console'; import { ReadOnlyFileSystem } from './fileSystem'; import { ServiceProvider } from './serviceProvider'; import { Range } from './textRange'; import { Uri } from './uri/uri'; export interface SourceFile { isStubFile(): boolean; isTypingStubFile(): boolean; isThirdPartyPyTypedPresent(): boolean; getIPythonMode(): IPythonMode; getUri(): Uri; getFileContent(): string | undefined; getClientVersion(): number | undefined; getOpenFileContents(): string | undefined; getModuleSymbolTable(): SymbolTable | undefined; getDiagnostics(options: ConfigOptions): Diagnostic[] | undefined; getParserOutput(): ParserOutput | undefined; } export interface SourceFileInfo { readonly uri: Uri; readonly contents: string; readonly ipythonMode: IPythonMode; readonly isTypeshedFile: boolean; readonly isThirdPartyImport: boolean; readonly isThirdPartyPyTypedPresent: boolean; readonly isTypingStubFile: boolean; readonly hasTypeAnnotations: boolean; readonly diagnosticsVersion: number | undefined; readonly semanticVersion: number; readonly clientVersion: number | undefined; readonly chainedSourceFile?: SourceFileInfo | undefined; readonly isTracked: boolean; readonly isOpenByClient: boolean; readonly imports: readonly SourceFileInfo[]; readonly importedBy: readonly SourceFileInfo[]; readonly shadows: readonly SourceFileInfo[]; readonly shadowedBy: readonly SourceFileInfo[]; } export interface ProgramView { readonly id: string; readonly rootPath: Uri; readonly console: ConsoleInterface; readonly evaluator: TypeEvaluator | undefined; readonly configOptions: ConfigOptions; readonly importResolver: ImportResolver; readonly fileSystem: ReadOnlyFileSystem; readonly serviceProvider: ServiceProvider; owns(uri: Uri): boolean; getSourceFileInfoList(): readonly SourceFileInfo[]; getParserOutput(fileUri: Uri): ParserOutput | undefined; getParseResults(fileUri: Uri): ParseFileResults | undefined; getSourceFileInfo(fileUri: Uri): SourceFileInfo | undefined; getModuleSymbolTable(fileUri: Uri): SymbolTable | undefined; getChainedUri(fileUri: Uri): Uri | undefined; getSourceMapper(fileUri: Uri, token: CancellationToken, mapCompiled?: boolean, preferStubs?: boolean): SourceMapper; analyzeFile(fileUri: Uri, token: CancellationToken): boolean; getDiagnosticsForRange(fileUri: Uri, range: Range): readonly Diagnostic[]; getParseDiagnostics(fileUri: Uri): readonly Diagnostic[] | undefined; handleMemoryHighUsage(): void; clone(): prog.Program; } export interface EditableProgram extends ProgramView { addInterimFile(uri: Uri): void; setFileOpened(fileUri: Uri, version: number | null, contents: string, options?: prog.OpenFileOptions): void; updateChainedUri(fileUri: Uri, chainedUri: Uri | undefined): void; } export interface ProgramMutator { addInterimFile(fileUri: Uri): void; setFileOpened(fileUri: Uri, version: number | null, contents: string, ipythonMode: IPythonMode, chainedFilePath?: Uri): void; updateOpenFileContents(path: Uri, version: number | null, contents: string, ipythonMode: IPythonMode): void; } export declare enum ReferenceUseCase { Rename = 0, References = 1 } export interface SymbolDefinitionProvider { tryGetDeclarations(node: ParseNode, offset: number, token: CancellationToken): Declaration[]; } export interface SymbolUsageProviderFactory { tryCreateProvider(useCase: ReferenceUseCase, declarations: readonly Declaration[], token: CancellationToken): SymbolUsageProvider | undefined; } /** * All Apis are supposed to be `idempotent` and `deterministic` * * All Apis should return the same results regardless how often there are called * in whatever orders for the same inputs. */ export interface SymbolUsageProvider { appendSymbolNamesTo(symbolNames: Set): void; appendDeclarationsTo(to: Declaration[]): void; appendDeclarationsAt(context: ParseNode, from: readonly Declaration[], to: Declaration[]): void; } export interface StatusMutationListener { onFileDirty?: (fileUri: Uri) => void; onClearCache?: () => void; onUpdateSettings?: (settings: T) => void; } export interface DebugInfoInspector { getCycleDetail(program: ProgramView, fileInfo: SourceFileInfo): string; }