(
documents: LangiumDocuments,
model: Model,
initialModel = model,
visited: Set<string> = new Set(),
models: Set<Model> = new Set(),
)
| 455 | } |
| 456 | |
| 457 | function resolveTransitiveImportsInternal( |
| 458 | documents: LangiumDocuments, |
| 459 | model: Model, |
| 460 | initialModel = model, |
| 461 | visited: Set<string> = new Set(), |
| 462 | models: Set<Model> = new Set(), |
| 463 | ) { |
| 464 | const doc = AstUtils.getDocument(model); |
| 465 | const initialDoc = AstUtils.getDocument(initialModel); |
| 466 | |
| 467 | if (initialDoc.uri.fsPath.toLowerCase() !== doc.uri.fsPath.toLowerCase()) { |
| 468 | models.add(model); |
| 469 | } |
| 470 | |
| 471 | const normalizedPath = doc.uri.fsPath.toLowerCase(); |
| 472 | if (!visited.has(normalizedPath)) { |
| 473 | visited.add(normalizedPath); |
| 474 | for (const imp of model.imports) { |
| 475 | const importedModel = resolveImport(documents, imp); |
| 476 | if (importedModel) { |
| 477 | resolveTransitiveImportsInternal(documents, importedModel, initialModel, visited, models); |
| 478 | } |
| 479 | } |
| 480 | } |
| 481 | return Array.from(models); |
| 482 | } |
| 483 | |
| 484 | /** |
| 485 | * Resolves the given import and returns the imported model. Returns `undefined` |
no test coverage detected