コード例 #1
0
        private async Task <Workspace> CreateWorkspaceAsync(AbsolutePath configPath, IReadOnlyDictionary <AbsolutePath, ISourceFile> specFileMap, bool typecheck)
        {
            var moduleDefinition = ModuleDefinition.CreateConfigModuleDefinition(Context.PathTable, configPath, specFileMap.Keys);
            var parsedModule     = new ParsedModule(moduleDefinition, specFileMap);

            // if type checking is not requested --> directly create a workspace from the given source file map
            if (!typecheck)
            {
                return(Workspace.CreateConfigurationWorkspace(WorkspaceConfiguration, parsedModule, preludeModule: null));
            }

            // otherwise, request a prelude module from the PreludeManager and proceed to type checking
            var maybePrelude = await GetPreludeParsedModule(configPath);

            if (!maybePrelude.Succeeded)
            {
                return(Workspace.Failure(null, WorkspaceConfiguration, maybePrelude.Failure));
            }

            var preludeModule = (ParsedModule)maybePrelude.Result;
            var workspace     = Workspace.CreateConfigurationWorkspace(WorkspaceConfiguration, parsedModule, preludeModule);

            return(await TypeCheckWorkspaceAsync(workspace));
        }