Skip to content

Commit 93f2a1e

Browse files
authored
feat: Add enable/disable effects command (#146)
1 parent b31beb8 commit 93f2a1e

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,16 @@
198198
"command": "sourcery.rule.create",
199199
"title": "Create custom rule",
200200
"category": "Sourcery"
201+
},
202+
{
203+
"command": "sourcery.effects.enable",
204+
"title": "Show Effects",
205+
"category": "Sourcery"
206+
},
207+
{
208+
"command": "sourcery.effects.disable",
209+
"title": "Hide Effects",
210+
"category": "Sourcery"
201211
}
202212
],
203213
"submenus": [
@@ -289,6 +299,14 @@
289299
{
290300
"command": "sourcery.rule.create",
291301
"when": "false"
302+
},
303+
{
304+
"command": "sourcery.effects.enable",
305+
"when": "sourcery.features.code_understanding && !sourcery.effects.enabled"
306+
},
307+
{
308+
"command": "sourcery.effects.disable",
309+
"when": "sourcery.features.code_understanding && sourcery.effects.enabled"
292310
}
293311
]
294312
},

src/extension.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,22 @@ function registerCommands(context: ExtensionContext, riProvider: RuleInputProvid
171171

172172
}));
173173

174+
// Enable/disable effects
175+
context.subscriptions.push(
176+
commands.registerCommand('sourcery.effects.enable', () => effects_set_enabled(true))
177+
);
178+
context.subscriptions.push(
179+
commands.registerCommand('sourcery.effects.disable', () => effects_set_enabled(false))
180+
);
181+
function effects_set_enabled(enabled: boolean) {
182+
vscode.commands.executeCommand('setContext', 'sourcery.effects.enabled', enabled);
183+
let request: ExecuteCommandParams = {
184+
command: 'sourcery.effects.set_enabled',
185+
arguments: [enabled]
186+
};
187+
languageClient.sendRequest(ExecuteCommandRequest.type, request);
188+
}
189+
174190
context.subscriptions.push(commands.registerCommand('sourcery.scan.applyRule', (entry) => {
175191
workspace.openTextDocument(entry.resourceUri).then(doc => {
176192
window.showTextDocument(doc).then(e => {

src/rule-search-results.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,4 @@ export class ScanResultProvider implements vscode.TreeDataProvider<FileResults>
8585
this.data = [];
8686
this._onDidChangeTreeData.fire();
8787
}
88-
}
88+
}

0 commit comments

Comments
 (0)