Skip to content

Commit e857090

Browse files
committed
feat: add stopAnalyse command
1 parent 2819cd8 commit e857090

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

.changeset/brave-radios-matter.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"phpstan-vscode": minor
3+
---
4+
5+
Add the `stopAnalyse` command

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
"command": "phpstan.analyse",
4444
"title": "PHPStan: Analyse"
4545
},
46+
{
47+
"command": "phpstan.stopAnalyse",
48+
"title": "PHPStan: Stop analyse"
49+
},
4650
{
4751
"command": "phpstan.analyseCurrentPath",
4852
"title": "PHPStan: Analyse current path"

src/extension.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export function activate(context: vscode.ExtensionContext): void {
8181
const commands: ((...args: unknown[]) => void)[] = [
8282
showOutputCommand,
8383
analyseCommand,
84+
stopAnalyseCommand,
8485
analyseCurrentPathCommand,
8586
pauseFileWatcherCommand,
8687
resumeFileWatcherCommand,
@@ -280,6 +281,16 @@ async function analyseCommand(ms?: number, args?: string[]) {
280281
}, ms ?? settings.analysedDelay)
281282
}
282283

284+
async function stopAnalyseCommand() {
285+
$.outputChannel.appendLine("# Command: stop analyse")
286+
if (currentProcess) {
287+
currentProcessKilled = true
288+
await killProcess(currentProcess)
289+
clearStatusBar()
290+
currentProcess = currentProcessKilled = null
291+
}
292+
}
293+
283294
async function analyseCurrentPathCommand(uri: vscode.Uri) {
284295
const fsPath =
285296
uri?.fsPath || vscode.window.activeTextEditor?.document.uri.fsPath

0 commit comments

Comments
 (0)