import { CompilerOptions, Diagnostic, JSDocParsingMode, LanguageServiceMode, Path, ScriptKind, TypeAcquisition, UserPreferences, WatchOptions } from "./_namespaces/lpc.js";
import { ConfiguredProject, HostCancellationToken, InferredProject, Logger, NormalizedPath, Project, ScriptInfo, ServerHost, Session } from "./_namespaces/lpc.server.js";
import * as protocol from "./protocol.js";
export declare const maxProgramSizeForNonTsFiles: number;
export declare const ProjectsUpdatedInBackgroundEvent = "projectsUpdatedInBackground";
export declare const ProjectLoadingStartEvent = "projectLoadingStart";
export declare const ProjectLoadingFinishEvent = "projectLoadingFinish";
export declare const LargeFileReferencedEvent = "largeFileReferenced";
export declare const ConfigFileDiagEvent = "configFileDiag";
export declare const ProjectLanguageServiceStateEvent = "projectLanguageServiceState";
export declare const ProjectInfoTelemetryEvent = "projectInfo";
export declare const OpenFileInfoTelemetryEvent = "openFileInfo";
export declare const CreateFileWatcherEvent: protocol.CreateFileWatcherEventName;
export declare const CreateDirectoryWatcherEvent: protocol.CreateDirectoryWatcherEventName;
export declare const CloseFileWatcherEvent: protocol.CloseFileWatcherEventName;
export interface ProjectsUpdatedInBackgroundEvent {
    eventName: typeof ProjectsUpdatedInBackgroundEvent;
    data: {
        openFiles: string[];
    };
}
export declare class ProjectService {
    /**
     * All the open script info that needs recalculation of the default project,
     * this also caches config file info before config file change was detected to use it in case projects are not updated yet
     */
    private pendingOpenFileProjectUpdates?;
    readonly currentDirectory: NormalizedPath;
    readonly toCanonicalFileName: (f: string) => string;
    private pendingProjectUpdates;
    readonly host: ServerHost;
    readonly logger: Logger;
    readonly cancellationToken: HostCancellationToken;
    readonly useInferredProjectPerProjectRoot: boolean;
    private readonly globalCacheLocationDirectoryPath;
    readonly serverMode: LanguageServiceMode;
    readonly throttleWaitMilliseconds?: number;
    private readonly hostConfiguration;
    private readonly suppressDiagnosticEvents?;
    readonly useSingleInferredProject: boolean;
    /**
     * Project size for configured or external projects
     */
    private readonly projectToSizeMap;
    private performanceEventHandler?;
    /**
     * projects specified by a lpc-config.json file
     */
    readonly configuredProjects: Map<string, ConfiguredProject>;
    /**
     * projects built from openFileRoots
     */
    readonly inferredProjects: InferredProject[];
    /**
     * Open files: with value being project root path, and key being Path of the file that is open
     */
    readonly openFiles: Map<Path, NormalizedPath | undefined>;
    /**
     * Files that have been opened or referenced by an open file and therefore
     * should be parsed as part of the program.
     */
    readonly shouldParse: Set<Path>;
    /** Config files looked up and cached config files for open script info */
    private readonly configFileForOpenFiles;
    /** Set of open script infos that are root of inferred project */
    private rootOfInferredProjects;
    /**
     * Contains all the deleted script info's version information so that
     * it does not reset when creating script info again
     * (and could have potentially collided with version where contents mismatch)
     */
    private readonly filenameToScriptInfoVersion;
    /**
     * Map of open files that are opened without complete path but have projectRoot as current directory
     */
    private readonly openFilesWithNonRootedDiskPath;
    private compilerOptionsForInferredProjects;
    private compilerOptionsForInferredProjectsPerProjectRoot;
    private watchOptionsForInferredProjects;
    private watchOptionsForInferredProjectsPerProjectRoot;
    private typeAcquisitionForInferredProjects;
    private typeAcquisitionForInferredProjectsPerProjectRoot;
    readonly jsDocParsingMode: JSDocParsingMode | undefined;
    constructor(opts: ProjectServiceOptions);
    private getOrCreateScriptInfoNotOpenedByClientForNormalizedPath;
    getScriptInfoEnsuringProjectsUptoDate(uncheckedFileName: string): ScriptInfo;
    getPreferences(file: NormalizedPath): UserPreferences;
    private ensureProjectChildren;
    private getOrCreateScriptInfoWorker;
    private stopWatchingScriptInfo;
    private watchClosedScriptInfo;
    private delayUpdateProjectGraph;
    getScriptInfoForPath(fileName: Path): ScriptInfo;
    toPath(fileName: string): Path;
    private delayUpdateProjectGraphs;
    private deleteScriptInfo;
    private handleDeletedFile;
    private getModifiedTime;
    private onSourceFileChanged;
    private handleSourceMapProjects;
    findAndOpenLpcConfig(projectRootPath: string): NormalizedPath | undefined;
    private cleanupConfiguredProjects;
    private removeProject;
    private cleanupProjectsAndScriptInfos;
    private printProjects;
    openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, projectRootPath?: NormalizedPath): OpenConfiguredProjectResult;
    /**
     * Finds the default configured project for given info
     * For any tsconfig found, it looks into that project, if not then all its references,
     * The search happens for all tsconfigs till projectRootPath
     */
    private tryFindDefaultConfiguredProjectForOpenScriptInfo;
    private updateRootAndOptionsOfNonInferredProject;
    private addFilesToNonInferredProject;
    private updateNonInferredProjectFiles;
    /**
     * Remove the root of inferred project if script info is part of another project
     */
    private removeRootOfInferredProjectIfNowPartOfOtherProject;
    /**
     * Finds the default configured project, if found, it creates the solution projects (does not load them right away)
     * with Find: finds the projects even if the project is deferredClosed
     */
    private tryFindDefaultConfiguredProjectAndLoadAncestorsForOpenScriptInfo;
    private assignProjectToOpenedScriptInfo;
    private getOrCreateInferredProjectForProjectRootPathIfEnabled;
    private getOrCreateSingleInferredProjectIfEnabled;
    private getOrCreateSingleInferredWithoutProjectRoot;
    setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.InferredProjectCompilerOptions, projectRootPath?: string): void;
    private createInferredProject;
    private getOrCreateOpenScriptInfo;
    private getConfiguredProjectByCanonicalConfigFilePath;
    findProject(projectName: string): Project | undefined;
    /**
     * This gets the script info for the normalized path. If the path is not rooted disk path then the open script info with project root context is preferred
     */
    getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo;
    private configFileExists;
    getScriptInfo(uncheckedFileName: string): ScriptInfo;
    /**
     * If there is default project calculation pending for this file,
     * then it completes that calculation so that correct default project is used for the project
     */
    private tryGetDefaultProjectForEnsuringConfiguredProjectForFile;
    /**
     * Ensures the project structures are upto date
     * This means,
     * - we go through all the projects and update them if they are dirty
     * - if updates reflect some change in structure or there was pending request to ensure projects for open files
     *   ensure that each open script info has project
     */
    private ensureProjectStructuresUptoDate;
    /**
     * This function is to update the project structure for every inferred project.
     * It is called on the premise that all the configured projects are
     * up to date.
     * This will go through open files and assign them to inferred project if open file is not part of any other project
     * After that all the inferred project graphs are updated
     */
    private ensureProjectForOpenFiles;
    private doEnsureDefaultProjectForFile;
    /**
     * This function tries to search for a tsconfig.json for the given file.
     * This is different from the method the compiler uses because
     * the compiler can assume it will always start searching in the
     * current directory (the directory in which tsc was invoked).
     * The server must start searching from the directory containing
     * the newly opened file.
     */
    private forEachConfigFileLocation;
    /** Caches the configFilename for script info or ancestor of open script info */
    private setConfigFileNameForFileInCache;
    /** Get cached configFileName for scriptInfo or ancestor of open script info */
    private getConfigFileNameForFileFromCache;
    getFormatCodeOptions(file: NormalizedPath): any;
    private createConfigFileWatcherForParsedConfig;
    getHostPreferences(): UserPreferences;
    /**
     * Close file whose contents is managed by the client
     * @param filename is absolute pathname
     */
    closeClientFile(uncheckedFileName: string): void;
    /**
     * Remove this file from the set of open, non-configured files.
     * @param info The file that has been closed or newly configured
     */
    private closeOpenFile;
    private assignOrphanScriptInfosToInferredProject;
}
export type ProjectServiceEventHandler = (event: ProjectServiceEvent) => void;
export interface LargeFileReferencedEvent {
    eventName: typeof LargeFileReferencedEvent;
    data: {
        file: string;
        fileSize: number;
        maxFileSize: number;
    };
}
export type ProjectServiceEvent = LargeFileReferencedEvent | ProjectsUpdatedInBackgroundEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent | CreateFileWatcherEvent | CreateDirectoryWatcherEvent | CloseFileWatcherEvent;
export interface ProjectServiceOptions {
    host: ServerHost;
    logger: Logger;
    cancellationToken: HostCancellationToken;
    useSingleInferredProject: boolean;
    useInferredProjectPerProjectRoot: boolean;
    eventHandler?: ProjectServiceEventHandler;
    canUseWatchEvents?: boolean;
    suppressDiagnosticEvents?: boolean;
    throttleWaitMilliseconds?: number;
    globalPlugins?: readonly string[];
    pluginProbeLocations?: readonly string[];
    allowLocalPluginLoads?: boolean;
    typesMapLocation?: string;
    serverMode?: LanguageServiceMode;
    session: Session<unknown> | undefined;
    projectRootFolder?: string;
    jsDocParsingMode?: JSDocParsingMode;
}
export interface OpenConfiguredProjectResult {
    configFileName?: NormalizedPath;
    configFileErrors?: readonly Diagnostic[];
}
export interface OpenFileArguments {
    fileName: string;
    content?: string;
    scriptKind?: ScriptKind;
    hasMixedContent?: boolean;
    projectRootPath?: string;
}
export interface ConfigFileDiagEvent {
    eventName: typeof ConfigFileDiagEvent;
    data: {
        triggerFile: string;
        configFileName: string;
        diagnostics: readonly Diagnostic[];
    };
}
export interface ProjectLanguageServiceStateEvent {
    eventName: typeof ProjectLanguageServiceStateEvent;
    data: {
        project: Project;
        languageServiceEnabled: boolean;
    };
}
export interface CreateFileWatcherEvent {
    readonly eventName: protocol.CreateFileWatcherEventName;
    readonly data: protocol.CreateFileWatcherEventBody;
}
export interface CreateDirectoryWatcherEvent {
    readonly eventName: protocol.CreateDirectoryWatcherEventName;
    readonly data: protocol.CreateDirectoryWatcherEventBody;
}
export interface CloseFileWatcherEvent {
    readonly eventName: protocol.CloseFileWatcherEventName;
    readonly data: protocol.CloseFileWatcherEventBody;
}
export declare function makeInferredProjectName(counter: number): string;
export interface WatchOptionsAndErrors {
    watchOptions: WatchOptions;
    errors: Diagnostic[] | undefined;
}
export declare function convertScriptKindName(scriptKindName: protocol.ScriptKindName): ScriptKind.Unknown | ScriptKind.LPC;
export declare function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin;
export declare function convertWatchOptions(protocolOptions: protocol.ExternalProjectCompilerOptions, currentDirectory?: string): WatchOptionsAndErrors | undefined;
export declare function convertTypeAcquisition(protocolOptions: protocol.InferredProjectCompilerOptions): TypeAcquisition | undefined;
//# sourceMappingURL=editorServices.d.ts.map