diff --git a/src/common/commands.ts b/src/common/commands.ts index bdb4539..01229cf 100644 --- a/src/common/commands.ts +++ b/src/common/commands.ts @@ -1,6 +1,7 @@ -import { QuickPickItem, window } from 'vscode'; import * as fs from 'fs'; +import { QuickPickItem, window } from 'vscode'; import * as vscode from 'vscode'; + import { getWorkspaceFolders } from './vscodeapi'; import { LanguageClient, LanguageClientOptions, ServerOptions, State, integer } from 'vscode-languageclient/node'; export async function selectEnvironment() { @@ -97,3 +98,4 @@ export async function executeServerDefinitionCommand(lsClient: LanguageClient | }); } } + diff --git a/src/common/status_bar.ts b/src/common/status_bar.ts new file mode 100644 index 0000000..c52ed41 --- /dev/null +++ b/src/common/status_bar.ts @@ -0,0 +1,23 @@ +import * as vscode from 'vscode'; +import { + getWorkspaceSettings, +} from './settings'; +import { getProjectRoot } from './utilities'; + +export async function createStatusBar(commandName: string, serverId:string): Promise{ + // Create a status bar item + const statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100); + statusBarItem.command = commandName; + // https://code.visualstudio.com/api/references/vscode-api#WorkspaceConfiguration + const projectRoot = await getProjectRoot(); + const workspaceSetting = await getWorkspaceSettings(serverId, projectRoot, true); + let environment = 'base'; // todo: Assume base, better to take this from server as it could be changed in project settings. + + if (workspaceSetting.environment) { + environment = workspaceSetting.environment; + } + + statusBarItem.text = `$(kedro-logo) ${environment}`; + statusBarItem.show(); + return statusBarItem; +} diff --git a/src/extension.ts b/src/extension.ts index fd47b75..4d85062 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { selectEnvironment, executeServerCommand, executeServerDefinitionCommand } from './common/commands'; import * as vscode from 'vscode'; +import { selectEnvironment, executeServerCommand, executeServerDefinitionCommand } from './common/commands'; import { LanguageClient } from 'vscode-languageclient/node'; import { registerLogger, traceError, traceLog, traceVerbose } from './common/log/logging'; import { @@ -12,15 +12,10 @@ import { resolveInterpreter, } from './common/python'; import { restartServer } from './common/server'; -import { - checkIfConfigurationChanged, - getExtensionSettings, - getGlobalSettings, - getInterpreterFromSetting, - getWorkspaceSettings, -} from './common/settings'; +import { checkIfConfigurationChanged, getInterpreterFromSetting } from './common/settings'; import { loadServerDefaults } from './common/setup'; -import { getLSClientTraceLevel, getProjectRoot } from './common/utilities'; +import { createStatusBar } from './common/status_bar'; +import { getLSClientTraceLevel } from './common/utilities'; import { createOutputChannel, onDidChangeConfiguration, registerCommand } from './common/vscodeapi'; import KedroVizPanel from './webview/vizWebView'; import { runKedroVizServer } from './webview/vizServer'; @@ -35,10 +30,19 @@ export async function activate(context: vscode.ExtensionContext): Promise const serverName = serverInfo.name; const serverId = serverInfo.module; + // Log Server information + traceLog(`Name: ${serverInfo.name}`); + traceLog(`Module: ${serverInfo.module}`); + traceVerbose(`Full Server Info: ${JSON.stringify(serverInfo)}`); + // List of commands const CMD_RESTART_SERVER = `${serverId}.restart`; const CMD_SELECT_ENV = `${serverId}.selectEnvironment`; + // Status Bar + const statusBarItem = await createStatusBar(CMD_SELECT_ENV, serverId); + context.subscriptions.push(statusBarItem); + // Setup logging const outputChannel = createOutputChannel(serverName); context.subscriptions.push(outputChannel, registerLogger(outputChannel)); @@ -108,22 +112,6 @@ export async function activate(context: vscode.ExtensionContext): Promise ); }; - // Create a status bar item - const statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100); - statusBarItem.command = CMD_SELECT_ENV; - // https://code.visualstudio.com/api/references/vscode-api#WorkspaceConfiguration - const projectRoot = await getProjectRoot(); - const workspaceSetting = await getWorkspaceSettings(serverId, projectRoot, true); - let environment = 'base'; // todo: Assume base, better to take this from server as it could be changed in project settings. - - if (workspaceSetting.environment) { - environment = workspaceSetting.environment; - } - - statusBarItem.text = `$(kedro-logo) ${environment}`; - statusBarItem.show(); - context.subscriptions.push(statusBarItem); - context.subscriptions.push( onDidChangePythonInterpreter(async () => { await runServer();