* Open synchronously (without sync)
(projectRoot: string)
| 371 | * Open synchronously (without sync) |
| 372 | */ |
| 373 | static openSync(projectRoot: string): CodeGraph { |
| 374 | const resolvedRoot = path.resolve(projectRoot); |
| 375 | |
| 376 | // Check if initialized |
| 377 | if (!isInitialized(resolvedRoot)) { |
| 378 | throw new Error(`CodeGraph not initialized in ${resolvedRoot}. Run init() first.`); |
| 379 | } |
| 380 | |
| 381 | // Validate directory structure |
| 382 | const validation = validateDirectory(resolvedRoot); |
| 383 | if (!validation.valid) { |
| 384 | throw new Error(`Invalid CodeGraph directory: ${validation.errors.join(', ')}`); |
| 385 | } |
| 386 | |
| 387 | // Open database |
| 388 | const dbPath = getDatabasePath(resolvedRoot); |
| 389 | const db = DatabaseConnection.open(dbPath); |
| 390 | const queries = new QueryBuilder(db.getDb()); |
| 391 | |
| 392 | return new CodeGraph(db, queries, resolvedRoot); |
| 393 | } |
| 394 | |
| 395 | /** |
| 396 | * Check if a directory has been initialized as a CodeGraph project |