(documents: LangiumDocuments, imp: ModelImport)
| 486 | * if the import cannot be resolved. |
| 487 | */ |
| 488 | export function resolveImport(documents: LangiumDocuments, imp: ModelImport) { |
| 489 | const resolvedUri = resolveImportUri(imp); |
| 490 | try { |
| 491 | if (resolvedUri) { |
| 492 | let resolvedDocument = documents.getDocument(resolvedUri); |
| 493 | if (!resolvedDocument) { |
| 494 | const content = fs.readFileSync(resolvedUri.fsPath, 'utf-8'); |
| 495 | resolvedDocument = documents.createDocument(resolvedUri, content); |
| 496 | } |
| 497 | const node = resolvedDocument.parseResult.value; |
| 498 | if (isModel(node)) { |
| 499 | return node; |
| 500 | } |
| 501 | } |
| 502 | } catch { |
| 503 | // NOOP |
| 504 | } |
| 505 | return undefined; |
| 506 | } |
| 507 | |
| 508 | /** |
| 509 | * Resolves the given import and returns the URI of the imported model. |
no test coverage detected