function createDominoProjectBrowser(langClient, context) {
    // Read the configuration and see if we should do anything.
    const config = vscode_1.workspace.getConfiguration('dscript');
    vscode_1.commands.executeCommand('setContext', 'dscript.moduleBrowserEnabled', config.turnOnModuleBrowser);
    vscode_1.commands.executeCommand('setContext', 'dscript.solutionExplorerEnabled', config.turnOnSolutionExplorer);
    if (!config.turnOnModuleBrowser && !config.turnOnSolutionExplorer) {
        return;
    }
    // If we've already created ourselves, then just bail out.
    // This can happen if we get multiple calls because the
    // user is changing their configuration settings.
    if (createdProjectBrowser) {
        return;
    }
    createdProjectBrowser = true;
    languageClient = langClient;
    extensionContext = context;
    // Register the command to be able to open spec documents when they are clicked on.
    context.subscriptions.push(vscode_1.commands.registerCommand('dscript.openSpecData', (spec) => {
        var textDocument = vscode_1.workspace.openTextDocument(spec.uri()).then((document) => {
            vscode_1.window.showTextDocument(document);
        });
    }));
    // Register the add source file command.
    addSourceFileRequest_1.configureAddSourceFile(languageClient, context);
    // Register the add project command.
    addProjectRequest_1.configureAddProject(languageClient, context);
    // Register for the workspace loading event so we know when the workspace
    // has successfully been loaded so we can start filling out the project browser
    workspaceLoadingNotification_1.WorkspaceLoadingNotification.WorkspaceLoadingEvent.event((state) => {
        if (state == 2 /* Success */) {
            moduleTreeItems = [];
            modulePathToDominoModuleMap = new Map();
            // Send the add source notification to the language server
            addSourceFileConfigurationNotification_1.sendAddSourceFileConfigurationToLanguageServer(languageClient, context);
            languageClient.sendRequest(modulesForWorkspaceRequest_1.ModulesForWorkspaceRequest, { includeSpecialConfigurationModules: false }).then((m) => {
                m.modules.sort((a, b) => {
                    return a.name.localeCompare(b.name);
                });
                m.modules.forEach((mod, index) => {
                    const moduleConfigDirname = path.dirname(mod.configFilename);
                    // Update the project module browser
                    const dominoModuleTreeItem = new DominoModuleTreeItem(mod, dominoModuleTreeEventEmitter);
                    modulePathToDominoModuleMap.set(moduleConfigDirname.toLowerCase(), dominoModuleTreeItem);
                    moduleTreeItems.push(dominoModuleTreeItem);
                    // Update the project directory browser.
                    const moduleDirectoryItem = directoryTreeItems.getOrAddChild(moduleConfigDirname);
                    moduleDirectoryItem.addModule(mod);
                });
                dominoDirectoryTreeEventEmitter.fire();
                dominoModuleTreeEventEmitter.fire();
            });
        }
    });
    // Set up the BuildXL DScript project module browser.
    vscode_1.window.registerTreeDataProvider("dscriptBuildScope", createModuleTreeDataProvider());
    // Set up the BuildXL DScript project directory browser.
    vscode_1.window.registerTreeDataProvider("buildxlProjectDirectoryBrowser", createDirectoryTreeDataProvider());
    // Register for open document notifications so we can select the write module in the
    // tree view.
    vscode_1.workspace.onDidOpenTextDocument((document) => {
        // Note: Due to issue https://github.com/Microsoft/vscode/issues/30288 we cannot currently
        // do this.
        // I believe we would do something like this..
        // As the user opens different documents we would find the closest
        // module configuration file for the open document.
        // If we find it, we would select the document in the BuildXL project browser.
        // We should be able to optimize this loop.
        if (modulePathToDominoModuleMap) {
            let docDirName = path.dirname(document.fileName).toLowerCase();
            ;
            while (docDirName && docDirName.length > 0) {
                if (modulePathToDominoModuleMap.has(docDirName)) {
                    modulePathToDominoModuleMap.get(docDirName).expand();
                    break;
                }
                // When we walk all the way to the root, stop.
                const newDirName = path.dirname(docDirName).toLowerCase();
                if (newDirName === undefined || newDirName === docDirName) {
                    break;
                }
                docDirName = newDirName;
            }
        }
    });
}
/**
 * Creates the BuildXL Project browser view
 * @param langClient The JSON-RPC language client, used to send requests to the language server
 * @param context The context the extennsion is running in, needed to register commands.
 */
Creates the BuildXL Project browser view
@param langClient The JSON-RPC language client, used to send requests to the language server
@param context The context the extennsion is running in, needed to register commands.
Creates the BuildXL Project browser view @param langClient The JSON - RPC language client used to send requests to the language server @param context The context the extennsion is running in needed to register commands .
function createDominoProjectBrowser(langClient, context) {
    const config = vscode_1.workspace.getConfiguration('dscript');
    vscode_1.commands.executeCommand('setContext', 'dscript.moduleBrowserEnabled', config.turnOnModuleBrowser);
    vscode_1.commands.executeCommand('setContext', 'dscript.solutionExplorerEnabled', config.turnOnSolutionExplorer);
    if (!config.turnOnModuleBrowser && !config.turnOnSolutionExplorer) {
        return;
    }
    if (createdProjectBrowser) {
        return;
    }
    createdProjectBrowser = true;
    languageClient = langClient;
    extensionContext = context;
    context.subscriptions.push(vscode_1.commands.registerCommand('dscript.openSpecData', (spec) => {
        var textDocument = vscode_1.workspace.openTextDocument(spec.uri()).then((document) => {
            vscode_1.window.showTextDocument(document);
        });
    }));
    addSourceFileRequest_1.configureAddSourceFile(languageClient, context);
    addProjectRequest_1.configureAddProject(languageClient, context);
    workspaceLoadingNotification_1.WorkspaceLoadingNotification.WorkspaceLoadingEvent.event((state) => {
        if (state == 2 ) {
            moduleTreeItems = [];
            modulePathToDominoModuleMap = new Map();
            addSourceFileConfigurationNotification_1.sendAddSourceFileConfigurationToLanguageServer(languageClient, context);
            languageClient.sendRequest(modulesForWorkspaceRequest_1.ModulesForWorkspaceRequest, { includeSpecialConfigurationModules: false }).then((m) => {
                m.modules.sort((a, b) => {
                    return a.name.localeCompare(b.name);
                });
                m.modules.forEach((mod, index) => {
                    const moduleConfigDirname = path.dirname(mod.configFilename);
                    const dominoModuleTreeItem = new DominoModuleTreeItem(mod, dominoModuleTreeEventEmitter);
                    modulePathToDominoModuleMap.set(moduleConfigDirname.toLowerCase(), dominoModuleTreeItem);
                    moduleTreeItems.push(dominoModuleTreeItem);
                    const moduleDirectoryItem = directoryTreeItems.getOrAddChild(moduleConfigDirname);
                    moduleDirectoryItem.addModule(mod);
                });
                dominoDirectoryTreeEventEmitter.fire();
                dominoModuleTreeEventEmitter.fire();
            });
        }
    });
    vscode_1.window.registerTreeDataProvider("dscriptBuildScope", createModuleTreeDataProvider());
    vscode_1.window.registerTreeDataProvider("buildxlProjectDirectoryBrowser", createDirectoryTreeDataProvider());
    vscode_1.workspace.onDidOpenTextDocument((document) => {
        if (modulePathToDominoModuleMap) {
            let docDirName = path.dirname(document.fileName).toLowerCase();
            ;
            while (docDirName && docDirName.length > 0) {
                if (modulePathToDominoModuleMap.has(docDirName)) {
                    modulePathToDominoModuleMap.get(docDirName).expand();
                    break;
                }
                const newDirName = path.dirname(docDirName).toLowerCase();
                if (newDirName === undefined || newDirName === docDirName) {
                    break;
                }
                docDirName = newDirName;
            }
        }
    });
}
function createDominoProjectBrowser ( langClient , context ) { const config = vscode_1 . workspace . getConfiguration ( 'dscript' ) ; vscode_1 . commands . executeCommand ( 'setContext' , 'dscript.moduleBrowserEnabled' , config . turnOnModuleBrowser ) ; vscode_1 . commands . executeCommand ( 'setContext' , 'dscript.solutionExplorerEnabled' , config . turnOnSolutionExplorer ) ; if ( ! config . turnOnModuleBrowser && ! config . turnOnSolutionExplorer ) { return ; } if ( createdProjectBrowser ) { return ; } createdProjectBrowser = true ; languageClient = langClient ; extensionContext = context ; context . subscriptions . push ( vscode_1 . commands . registerCommand ( 'dscript.openSpecData' , ( spec ) => { var textDocument = vscode_1 . workspace . openTextDocument ( spec . uri ( ) ) . then ( ( document ) => { vscode_1 . window . showTextDocument ( document ) ; } ) ; } ) ) ; addSourceFileRequest_1 . configureAddSourceFile ( languageClient , context ) ; addProjectRequest_1 . configureAddProject ( languageClient , context ) ; workspaceLoadingNotification_1 . WorkspaceLoadingNotification . WorkspaceLoadingEvent . event ( ( state ) => { if ( state == 2 ) { moduleTreeItems = [ ] ; modulePathToDominoModuleMap = new Map ( ) ; addSourceFileConfigurationNotification_1 . sendAddSourceFileConfigurationToLanguageServer ( languageClient , context ) ; languageClient . sendRequest ( modulesForWorkspaceRequest_1 . ModulesForWorkspaceRequest , { includeSpecialConfigurationModules : false } ) . then ( ( m ) => { m . modules . sort ( ( a , b ) => { return a . name . localeCompare ( b . name ) ; } ) ; m . modules . forEach ( ( mod , index ) => { const moduleConfigDirname = path . dirname ( mod . configFilename ) ; const dominoModuleTreeItem = new DominoModuleTreeItem ( mod , dominoModuleTreeEventEmitter ) ; modulePathToDominoModuleMap . set ( moduleConfigDirname . toLowerCase ( ) , dominoModuleTreeItem ) ; moduleTreeItems . push ( dominoModuleTreeItem ) ; const moduleDirectoryItem = directoryTreeItems . getOrAddChild ( moduleConfigDirname ) ; moduleDirectoryItem . addModule ( mod ) ; } ) ; dominoDirectoryTreeEventEmitter . fire ( ) ; dominoModuleTreeEventEmitter . fire ( ) ; } ) ; } } ) ; vscode_1 . window . registerTreeDataProvider ( "dscriptBuildScope" , createModuleTreeDataProvider ( ) ) ; vscode_1 . window . registerTreeDataProvider ( "buildxlProjectDirectoryBrowser" , createDirectoryTreeDataProvider ( ) ) ; vscode_1 . workspace . onDidOpenTextDocument ( ( document ) => { if ( modulePathToDominoModuleMap ) { let docDirName = path . dirname ( document . fileName ) . toLowerCase ( ) ; ; while ( docDirName && docDirName . length > 0 ) { if ( modulePathToDominoModuleMap . has ( docDirName ) ) { modulePathToDominoModuleMap . get ( docDirName ) . expand ( ) ; break ; } const newDirName = path . dirname ( docDirName ) . toLowerCase ( ) ; if ( newDirName === undefined || newDirName === docDirName ) { break ; } docDirName = newDirName ; } } } ) ; }
Creates the BuildXL Project browser view
 @param langClient The JSON-RPC language client, used to send requests to the language server
 @param context The context the extennsion is running in, needed to register commands.
Creates the BuildXL Project browser view @param langClient The JSON - RPC language client used to send requests to the language server @param context The context the extennsion is running in needed to register commands .
// Read the configuration and see if we should do anything.
 // If we've already created ourselves, then just bail out.
 // This can happen if we get multiple calls because the
 // user is changing their configuration settings.
 // Register the command to be able to open spec documents when they are clicked on.
 // Register the add source file command.
 // Register the add project command.
 // Register for the workspace loading event so we know when the workspace
 // has successfully been loaded so we can start filling out the project browser
 /* Success */ // Send the add source notification to the language server
 // Update the project module browser
 // Update the project directory browser.
 // Set up the BuildXL DScript project module browser.
 // Set up the BuildXL DScript project directory browser.
 // Register for open document notifications so we can select the write module in the
 // tree view.
 // Note: Due to issue https://github.com/Microsoft/vscode/issues/30288 we cannot currently
 // do this.
 // I believe we would do something like this..
 // As the user opens different documents we would find the closest
 // module configuration file for the open document.
 // If we find it, we would select the document in the BuildXL project browser.
 // We should be able to optimize this loop.
 // When we walk all the way to the root, stop.
