diff --git a/vscode/.vscode/launch.json b/vscode/.vscode/launch.json index d4df9e9..f0a39d5 100644 --- a/vscode/.vscode/launch.json +++ b/vscode/.vscode/launch.json @@ -10,6 +10,7 @@ "type": "extensionHost", "request": "launch", "args": [ + "--disable-extensions", "--extensionDevelopmentPath=${workspaceFolder}" ], "outFiles": [ diff --git a/vscode/src/extension.ts b/vscode/src/extension.ts index 71f8efb..783e2d3 100644 --- a/vscode/src/extension.ts +++ b/vscode/src/extension.ts @@ -12,6 +12,7 @@ let currentDecoration: vscode.TextEditorDecorationType = warningDecorationType; let ranges: ComposedSmell[] = []; let hovers: vscode.Disposable[] = []; let collection: vscode.DiagnosticCollection; +let smellyStatusBar: vscode.StatusBarItem; function fetchConfiguration(): SmellyConfiguration { const configuration = vscode.workspace.getConfiguration().get(EXTENSION_IDENTIFIER) || {}; @@ -45,12 +46,17 @@ export function activate(context: vscode.ExtensionContext) { }, null, context.subscriptions) ); + const smellyCommandSignature = 'extension.smelly-test.find-smells'; context.subscriptions.push( - vscode.commands.registerCommand('extension.smelly-test.find-smells', () => { + vscode.commands.registerCommand(smellyCommandSignature, () => { generateHighlighting(context); })); context.subscriptions.push(reporter); + smellyStatusBar = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 100); + smellyStatusBar.command = smellyCommandSignature; + context.subscriptions.push(smellyStatusBar); + // is there a way to test drive this? generateHighlighting(context); @@ -106,6 +112,15 @@ function populateDiagnosticPanel() { } } +function populateStatusBar() { + if (ranges.length === 0) { + smellyStatusBar.text = "Your test is awesome 🚀"; + smellyStatusBar.show(); + } else { + smellyStatusBar.hide(); + } +} + function isFileNameTestFile(fileName: string): boolean { const fileNameOnly = path.basename(fileName); const fileTestIdentifier = fetchConfiguration().fileTestIdentifier; @@ -168,6 +183,8 @@ function generateHighlighting(context: vscode.ExtensionContext) { logger.debug(`highlight selection match done`); drawHover(context); + populateDiagnosticPanel(); + populateStatusBar(); } const findSmells = (text: string, language: string): Smell[] => {