use of com.github.anba.es6draft.runtime.modules.ResolutionException in project es6draft by anba.
the class ModuleOperations method resolveImportOrThrow.
/**
* 15.2.1.16.4.2 ModuleDeclarationEnvironmentSetup( module )
*
* @param module
* the module record
* @param moduleRequest
* the module specifier string
* @param importName
* the import name
* @return the resolved module import
* @throws IOException
* if there was any I/O error
* @throws MalformedNameException
* if the module specifier cannot be normalized
* @throws ResolutionException
* if the export cannot be resolved
*/
public static ResolvedBinding resolveImportOrThrow(SourceTextModuleRecord module, String moduleRequest, String importName) throws IOException, MalformedNameException, ResolutionException {
/* steps 8.a-b */
ModuleRecord importedModule = HostResolveImportedModule(module, moduleRequest);
/* step 8.c (not applicable) */
/* step 8.d.i */
ResolvedBinding resolution = importedModule.resolveExport(importName, new HashMap<>());
/* step 8.d.ii */
if (resolution == null) {
throw new ResolutionException(Messages.Key.ModulesUnresolvedImport, importName, importedModule.getSourceCodeId().toString());
}
if (resolution.isAmbiguous()) {
throw new ResolutionException(Messages.Key.ModulesAmbiguousImport, importName, importedModule.getSourceCodeId().toString());
}
return resolution;
}
Aggregations