/// <summary> /// Creates a module from a module name and optionally a version using an id that it is guaranteed to be unique. /// </summary> public static ModuleDescriptor CreateWithUniqueId(string moduleName, IWorkspaceModuleResolver resolver, string version = null) { return(new ModuleDescriptor( id: ModuleIdProvider.GetNextId(), name: moduleName, displayName: moduleName, version: version, resolverKind: resolver.Kind, resolverName: resolver.Name)); }
private async Task <Possible <ParsedModule> > CreatePreludeModuleAsync() { var moduleName = FrontEndHost.PreludeModuleName; string preludeRootDir = GetPreludeRoot(); AbsolutePath preludeRootDirPath = AbsolutePath.Create(m_pathTable, preludeRootDir); if (!m_engine.DirectoryExists(preludeRootDirPath)) { return(new Failure <string>($"Prelude root folder '{preludeRootDir}' does not exist")); } var specs = DiscoverPreludeSpecs(preludeRootDirPath, out AbsolutePath mainSpec, out AbsolutePath moduleConfigSpec); if (!mainSpec.IsValid) { return(new Failure <string>($"Prelude main spec file ('{PreludeMainFile}') not found inside the '{preludeRootDir}' folder")); } if (!moduleConfigSpec.IsValid) { return(new Failure <string>($"Prelude module configuration spec file ('{PreludeModuleConfigName}') not found inside the '{preludeRootDir}' folder")); } ModuleDefinition preludeModuleDefinition = ModuleDefinition.CreateModuleDefinitionWithExplicitReferencesWithEmptyQualifierSpace( descriptor: new ModuleDescriptor( id: ModuleIdProvider.GetNextId(), name: moduleName, displayName: moduleName, version: "0", resolverKind: KnownResolverKind.DScriptResolverKind, resolverName: "DScriptPrelude"), main: mainSpec, moduleConfigFile: moduleConfigSpec, specs: specs, pathTable: PathTable); var parsedPreludeFiles = await Task.WhenAll(specs.Select(m_parser)); var failures = parsedPreludeFiles.Where(r => !r.Succeeded).ToList(); if (failures.Count > 0) { var separator = Environment.NewLine + " "; var message = "Parsing built-in prelude failed:" + separator + string.Join(separator, failures.Select(f => f.Failure.Describe())); return(new Failure <string>(message)); } Dictionary <AbsolutePath, ISourceFile> specFileMap = parsedPreludeFiles .ToDictionary( maybeSourceFile => AbsolutePath.Create(PathTable, maybeSourceFile.Result.FileName), maybeSourceFile => maybeSourceFile.Result); return(new ParsedModule(preludeModuleDefinition, specFileMap)); }