From 59a2a804a3901055d05a213c417b4f7a319f06cc Mon Sep 17 00:00:00 2001 From: Juanra GM Date: Thu, 22 Sep 2022 01:54:17 +0200 Subject: [PATCH] feat: add `initialAnalysis` setting --- .changeset/unlucky-camels-jam.md | 5 +++++ package.json | 5 +++++ src/extension.ts | 9 +++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 .changeset/unlucky-camels-jam.md diff --git a/.changeset/unlucky-camels-jam.md b/.changeset/unlucky-camels-jam.md new file mode 100644 index 0000000..0861152 --- /dev/null +++ b/.changeset/unlucky-camels-jam.md @@ -0,0 +1,5 @@ +--- +"phpstan-vscode": minor +--- + +Add `initialAnalysis` setting diff --git a/package.json b/package.json index 0cc81a8..d2e094b 100644 --- a/package.json +++ b/package.json @@ -122,6 +122,11 @@ "type": "integer", "description": "Milliseconds delay between file changes before run analyse", "default": 200 + }, + "phpstan.initialAnalysis": { + "type": "boolean", + "description": "Runs the analyse command on startup", + "default": true } } }, diff --git a/src/extension.ts b/src/extension.ts index ebd5b06..7c1873c 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -33,6 +33,7 @@ export type ExtSettings = { configFileWatcher: boolean; analysedDelay: number; memoryLimit: string; + initialAnalysis: boolean; }; export type ExtStore = { @@ -66,6 +67,7 @@ export class Ext< readonly statusBarItem: StatusBarItem; readonly commandListeners: Disposable[] = []; protected fileWatchers = createFileWatcherManager(); + protected activations = 0; constructor( readonly options: { @@ -150,6 +152,7 @@ export class Ext< configFileWatcher: get("configFileWatcher"), analysedDelay: get("analysedDelay"), memoryLimit: get("memoryLimit"), + initialAnalysis: get("initialAnalysis"), }; } @@ -183,10 +186,11 @@ export class Ext< } async activate() { + this.activations++; await this.call(async () => await this.activateRutine(), "activate"); } - protected async activateRutine(analyse = true) { + protected async activateRutine() { cmd.executeCommand( "setContext", `${this.options.name}:enabled`, @@ -229,7 +233,8 @@ export class Ext< }); } - if (analyse) this.options.commands.analyse(this); + if (this.settings.initialAnalysis || this.activations > 1) + this.options.commands.analyse(this); } deactivate() {