Skip to content

Commit

Permalink
feat(vscode): status bar info
Browse files Browse the repository at this point in the history
  • Loading branch information
marabesi committed Aug 11, 2024
1 parent cef9c33 commit 7971ffd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions vscode/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"type": "extensionHost",
"request": "launch",
"args": [
"--disable-extensions",
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
Expand Down
19 changes: 18 additions & 1 deletion vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) || {};
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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[] => {
Expand Down

0 comments on commit 7971ffd

Please sign in to comment.