import type { ValidationAcceptor, ValidationChecks, LangiumDocument } from 'langium'; import { Cancellation } from 'langium'; import type { DomainLangAstType, ImportStatement } from '../generated/ast.js'; import type { DomainLangServices } from '../domain-lang-module.js'; /** * Validates import statements in DomainLang. * * Uses async validators (Langium 4.x supports MaybePromise) to leverage * the shared ManifestManager service with its cached manifest/lock file reading. * * Checks: * - All import URIs resolve to existing files * - External imports require manifest + alias * - Local path dependencies stay inside workspace * - Lock file exists for external dependencies * - Import cycles are detected and reported (PRS-017 R3) */ export declare class ImportValidator { private readonly manifestManager; private readonly importResolver; private readonly indexManager; constructor(services: DomainLangServices); /** * Validates an import statement asynchronously. * * Langium validators can return MaybePromise, enabling async operations * like reading manifests via the shared, cached ManifestManager. */ checkImportPath(imp: ImportStatement, accept: ValidationAcceptor, document: LangiumDocument, cancelToken: Cancellation.CancellationToken): Promise; /** * Validates that an import URI resolves to an existing file. * Returns true if there was an error (import doesn't resolve). */ private validateImportResolves; /** * Checks if a file exists (async). */ private fileExists; /** * Finds the dependency configuration that matches the import specifier. * * Dependencies can be keyed as: * - owner/package (recommended, matches "owner/package" or "owner/package/subpath") * - short-alias (matches "short-alias" or "short-alias/subpath") * * @returns The matching key and normalized dependency, or undefined if not found */ private findDependency; /** * Gets the normalized dependency configuration for a key. */ private getDependency; /** * Validates dependency configuration. * Returns false if a blocking error was found (caller should stop processing). */ private validateDependencyConfig; /** * Validates local path dependencies stay within workspace. */ private validateLocalPathDependency; /** * Validates that external dependency is in lock file and cached. */ private validateCachedPackage; /** * Gets the cache directory for a dependency. * Per PRS-010: Project-local cache at .dlang/packages/{owner}/{repo}/{commit}/ * The source field comes from user-controlled model.yaml, so validate the result stays within the cache dir. */ private getCacheDirectory; /** * Checks if a directory exists (async). */ private directoryExists; /** * Reports a warning if the current import statement points to a document in a cycle. * * Cycle data is populated during indexing by DomainLangIndexManager. * Only the import statement whose target is part of the cycle is annotated; * other imports in the same file are skipped to avoid duplicate diagnostics. */ private checkImportCycle; } /** * Creates validation checks for import statements. * * Returns async validators that leverage the shared ManifestManager * for cached manifest/lock file reading. */ export declare function createImportChecks(services: DomainLangServices): ValidationChecks;