MCPcopy Create free account
hub / github.com/zenstackhq/zenstack / resolveImport

Function resolveImport

packages/language/src/utils.ts:488–506  ·  view source on GitHub ↗
(documents: LangiumDocuments, imp: ModelImport)

Source from the content-addressed store, hash-verified

486 * if the import cannot be resolved.
487 */
488export 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.

Callers 5

loadImportsFunction · 0.90
collectLocationLinksMethod · 0.90
validateImportsMethod · 0.90
eagerLoadAllImportsFunction · 0.90

Calls 2

isModelFunction · 0.90
resolveImportUriFunction · 0.85

Tested by

no test coverage detected