/// <inheritdoc /> public async Task <bool?> TryConvertModuleToEvaluationAsync(IModuleRegistry moduleRegistry, ParsedModule module, IWorkspace workspace) { if (!string.Equals(module.Descriptor.ResolverName, Name, StringComparison.Ordinal)) { return(null); } var package = CreatePackage(module.Definition); Contract.Assert(module.Specs.Count == 1, "This resolver generated the module, so we expect a single spec."); var sourceKv = module.Specs.First(); // The in-memory generated spec is a regular DScript one, so run regular AST conversion var result = await FrontEndUtilities.RunAstConversionAsync(m_frontEndHost, m_context, m_logger, m_frontEndStatistics, package, sourceKv.Key); if (!result.Success) { return(false); } // Register the uninstantiated module var moduleData = new UninstantiatedModuleInfo( result.SourceFile, result.Module, result.QualifierSpaceId.IsValid ? result.QualifierSpaceId : m_context.QualifierTable.EmptyQualifierSpaceId); m_frontEndHost.ModuleRegistry.AddUninstantiatedModuleInfo(moduleData); return(true); }
private async Task RunAstConverstionForFileAsync(Package package, AbsolutePath file) { var conversionResult = await FrontEndUtilities.RunAstConversionAsync(m_host, Context, m_logger, new FrontEndStatistics(), package, file); Contract.Assert(conversionResult.Success); var moduleData = new UninstantiatedModuleInfo( conversionResult.SourceFile, conversionResult.Module, conversionResult.QualifierSpaceId.IsValid ? conversionResult.QualifierSpaceId : Context.QualifierTable.EmptyQualifierSpaceId); m_host.ModuleRegistry.AddUninstantiatedModuleInfo(moduleData); }
private async Task ConvertImportsFileAsync(Package package) { if (m_javaScriptWorkspaceResolver.CustomSchedulingCallback != null) { // The imports file does not need any special callbacks and it is regular DScript. Run the normal AST conversion process on it. var conversionResult = await FrontEndUtilities.RunAstConversionAsync(m_host, Context, m_logger, new FrontEndStatistics(), package, m_javaScriptWorkspaceResolver.ImportsFile); Contract.Assert(conversionResult.Success); var moduleData = new UninstantiatedModuleInfo( conversionResult.SourceFile, conversionResult.Module, conversionResult.QualifierSpaceId.IsValid ? conversionResult.QualifierSpaceId : Context.QualifierTable.EmptyQualifierSpaceId); m_host.ModuleRegistry.AddUninstantiatedModuleInfo(moduleData); } }