import { CancellationToken, CompletionItem, CompletionItemKind, SymbolKind } from 'vscode-languageserver'; import { ImportResolver, ModuleNameAndType } from '../analyzer/importResolver'; import { ImportGroup } from '../analyzer/importStatementUtils'; import { Symbol } from '../analyzer/symbol'; import { ExecutionEnvironment } from '../common/configOptions'; import { TextEditAction } from '../common/editAction'; import { ProgramView, SourceFileInfo } from '../common/extensibility'; import { Position } from '../common/textRange'; import { Uri } from '../common/uri/uri'; import { ParseFileResults } from '../parser/parser'; import { CompletionItemData, CompletionMap } from './completionProvider'; import { IndexAliasData } from './symbolIndexer'; export interface AutoImportSymbol { readonly name: string; readonly library: boolean; readonly kind?: SymbolKind; readonly itemKind?: CompletionItemKind; readonly importAlias?: IndexAliasData; readonly symbol?: Symbol; readonly inDunderAll?: boolean; readonly hasRedundantAlias?: boolean; } export interface ModuleSymbolTable { readonly uri: Uri; getSymbols(): Generator; } export type ModuleSymbolMap = Map; export interface AutoImportResult { readonly name: string; readonly declUri: Uri; readonly originalName: string; readonly originalDeclUri: Uri; readonly insertionText: string; readonly symbol?: Symbol; readonly source?: string; readonly edits?: TextEditAction[]; readonly alias?: string; readonly kind?: CompletionItemKind; } export interface AutoImportOptions { readonly patternMatcher?: (pattern: string, name: string) => boolean; readonly lazyEdit?: boolean; } export interface ImportParts { readonly importName: string; readonly symbolName?: string; readonly importFrom?: string; readonly fileUri: Uri; readonly dotCount: number; readonly moduleNameAndType: ModuleNameAndType; } export interface ImportAliasData { readonly importParts: ImportParts; readonly importGroup: ImportGroup; readonly symbol?: Symbol; readonly kind?: SymbolKind; readonly itemKind?: CompletionItemKind; readonly inDunderAll?: boolean; readonly hasRedundantAlias?: boolean; readonly fileUri: Uri; } export type AutoImportResultMap = Map; export declare function buildModuleSymbolsMap(program: ProgramView, files: readonly SourceFileInfo[]): ModuleSymbolMap; export declare class AutoImporter { protected readonly program: ProgramView; protected readonly execEnvironment: ExecutionEnvironment; protected readonly parseResults: ParseFileResults; private readonly _invocationPosition; private readonly _excludes; protected readonly moduleSymbolMap: ModuleSymbolMap; protected readonly options: AutoImportOptions; private readonly _importStatements; constructor(program: ProgramView, execEnvironment: ExecutionEnvironment, parseResults: ParseFileResults, _invocationPosition: Position, _excludes: CompletionMap, moduleSymbolMap: ModuleSymbolMap, options: AutoImportOptions); getAutoImportCandidates(word: string, similarityLimit: number, abbrFromUsers: string | undefined, token: CancellationToken): AutoImportResult[]; protected get importResolver(): ImportResolver; protected getCompletionItemData(item: CompletionItem): CompletionItemData | undefined; protected getCandidates(word: string, similarityLimit: number, abbrFromUsers: string | undefined, token: CancellationToken): Map; protected addImportsFromModuleMap(word: string, similarityLimit: number, abbrFromUsers: string | undefined, aliasMap: Map>, results: AutoImportResultMap, token: CancellationToken): void; protected addImportsFromImportAliasMap(importAliasMap: Map>, abbrFromUsers: string | undefined, results: AutoImportResultMap, token: CancellationToken): void; protected processModuleSymbolTable(topLevelSymbols: ModuleSymbolTable, moduleUri: Uri, word: string, similarityLimit: number, fileProperties: { isStub: boolean; hasInit: boolean; isUserCode: boolean; }, abbrFromUsers: string | undefined, importAliasMap: Map>, results: AutoImportResultMap, token: CancellationToken): void; protected getNameForImportFrom(library: boolean, moduleUri: Uri): string | undefined; protected getUriProperties(map: Map, uri: Uri): { isStub: boolean; hasInit: boolean; isUserCode: boolean; }; protected compareImportAliasData(left: ImportAliasData, right: ImportAliasData): number; protected shouldIncludeVariable(autoSymbol: AutoImportSymbol, isStub: boolean): boolean; private _addToImportAliasMap; private _getImportPartsForSymbols; private _getImportParts; private _isSimilar; private _shouldExclude; private _containsName; private _getModuleNameAndTypeFromFilePath; private _getTextEditsForAutoImportByFilePath; private _addResult; } export declare function convertSymbolKindToCompletionItemKind(kind: SymbolKind | undefined): 2 | 22 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 13 | 17 | 19 | 20 | 21 | 23 | 24 | 25 | undefined;