import type { Diagnostic, Position, Range, Location, DocumentSymbol, WorkspaceSymbol, CodeAction, CompletionList, SelectionRange, TextEdit } from 'vscode-languageserver-protocol'; import type { Hover, MaybePromise, SemanticToken } from '../interfaces'; import type { DocumentAction, DocumentActionWithStatus } from './DocumentManager'; import type { FileTranspileResult, SignatureInfoObj } from '../Program'; import type { Logger, LogLevel } from '../logging'; /** * Defines the contract between the ProjectManager and the main or worker thread Project classes */ export interface LspProject { /** * Is this a standalone project? */ isStandaloneProject: boolean; /** * A logger instance used for logging in this project */ logger: Logger; /** * The config used to activate this project */ activateOptions: ProjectConfig; /** * A unique key to represent this project. The format of this key may change, but it will always be unique to this project and can be used for comparison purposes. * * For directory-only projects, this is the path to the dir. For bsconfig.json projects, this is the path to the config file (typically bsconfig.json). */ projectKey: string; /** * The directory for the root of this project (typically where the bsconfig.json or manifest is located) */ projectDir: string; /** * A unique number for this project, generated during this current language server session. Mostly used so we can identify which project is doing logging */ projectNumber: number; /** * The root directory of the project. * Only available after `.activate()` has completed */ rootDir: string; /** * The file patterns from bsconfig.json that were used to find all files for this project */ filePatterns: string[]; /** * Path to a bsconfig.json file that will be used for this project. * Only available after `.activate()` has completed */ bsconfigPath?: string; /** * The contents of the bsconfig.json file. This is used to detect when the bsconfig file has not actually been changed (even if the fs says it did). * * Only available after `.activate()` has completed. * @deprecated do not depend on this property. This will certainly be removed in a future release */ bsconfigFileContents?: string; /** * The contents of the manifest file. This is used to detect when the manifest file has not actually been changed (even if the fs says it did). * * Only available after `.activate()` has completed. * @deprecated do not depend on this property. This will certainly be removed in a future release */ manifestFileContents?: string; /** * The absolute source path to the manifest file (the file that maps to dest 'manifest'). * May differ from rootDir/manifest if the project uses a custom {src; dest} mapping. * * Only available after `.activate()` has completed. */ manifestSrcPath?: string; /** * Initialize and start running the project. This will scan for all files, and build a full project in memory, then validate the project * @param options */ activate(options: ProjectConfig): MaybePromise; /** * Get a promise that resolves when the project finishes activating */ whenActivated(): Promise; /** * Validate the project. This will trigger a full validation on any scopes that were changed since the last validation, * and will also eventually emit a new 'diagnostics' event that includes all diagnostics for the project */ validate(): Promise; /** * Cancel any active validation that's running */ cancelValidate(): MaybePromise; /** * Get the list of all diagnostics from this project */ getDiagnostics(): MaybePromise; /** * Get the full list of semantic tokens for the given file path * @param srcPath absolute path to the source file */ getSemanticTokens(options: { srcPath: string; }): MaybePromise; /** * Transpile the specified file * @param srcPath */ transpileFile(options: { srcPath: string; }): MaybePromise; /** * Get the hover information for the specified position in the specified file */ getHover(options: { srcPath: string; position: Position; }): MaybePromise; /** * Get the locations where the symbol at the specified position is defined * @param options the file path and position to get the definition for */ getDefinition(options: { srcPath: string; position: Position; }): MaybePromise; /** * Get the locations where the symbol at the specified position is defined * @param options the file path and position to get the definition for */ getSignatureHelp(options: { srcPath: string; position: Position; }): MaybePromise; /** * Get the list of symbols for the specified file */ getDocumentSymbol(options: { srcPath: string; }): MaybePromise; /** * Get the list of symbols for the entire workspace */ getWorkspaceSymbol(): Promise; /** * Get the list of references for the specified file and position */ getReferences(options: { srcPath: string; position: Position; }): MaybePromise; /** * Compute the text edits required to keep `import` statements and `