/** * Package Boundary Detector * * Determines package boundaries for import scoping. * Per ADR-003, package boundaries are defined by: * - External packages: Files within .dlang/packages/ sharing the same model.yaml * - Local files: Each file is its own boundary (non-transitive) * * Used by DomainLangScopeProvider to enable transitive imports within * package boundaries while keeping local file imports non-transitive. */ import { URI } from 'langium'; /** * Detects and caches package boundaries for efficient scope resolution. */ export declare class PackageBoundaryDetector { /** * Cache mapping document URI to its package root path. * - External packages: path to directory containing model.yaml * - Local files: null (no package boundary) */ private readonly packageRootCache; /** * Determines if a document is part of an external package. * * External packages are stored in .dlang/packages/owner/repo/commit/ * * @param documentUri - The URI of the document to check * @returns true if document is in an external package */ isExternalPackage(documentUri: URI | string): boolean; /** * Gets the package root for a document. * * For external packages (.dlang/packages/), walks up from the document * to find the nearest model.yaml file within the package structure. * * For local files, returns null (no package boundary). * * @param documentUri - The URI of the document * @returns Absolute path to package root, or null if not in a package */ getPackageRoot(documentUri: URI | string): Promise; /** * Checks if two documents are in the same package (synchronous heuristic). * * This is a fast, synchronous check that compares package commit directories * without filesystem access. Documents are in the same package if: * - Both are in .dlang/packages/ AND * - They share the same owner/repo/commit path * * This is used by the scope provider which needs synchronous access. * * Structure: .dlang/packages/owner/repo/commit/... * * @param doc1Uri - URI of first document * @param doc2Uri - URI of second document * @returns true if both are in the same package commit directory */ areInSamePackageSync(doc1Uri: URI | string, doc2Uri: URI | string): boolean; /** * Gets the package commit directory (owner/repo/commit) from a path. * * @param fsPath - Filesystem path * @returns Commit directory path or null */ private getPackageCommitDirectory; /** * Checks if two documents are in the same package. * * Documents are in the same package if: * - Both are external packages AND * - They share the same package root (model.yaml location) * * Local files are never in the same package (each is isolated). * * @param doc1Uri - URI of first document * @param doc2Uri - URI of second document * @returns true if both documents are in the same package */ areInSamePackage(doc1Uri: URI | string, doc2Uri: URI | string): Promise; /** * Finds the package root for an external package by walking up to find model.yaml. * * External packages have structure: .dlang/packages/owner/repo/commit/... * The model.yaml should be at the commit level or just below it. * * @param fsPath - Filesystem path of the document * @returns Path to directory containing model.yaml, or null */ private findPackageRootForExternal; /** * Converts a URI to a filesystem path. */ private toFsPath; /** * Clears the package root cache. * Call this when packages are installed/removed. */ clearCache(): void; }