Skip to content

Commit 59a2a80

Browse files
committed
feat: add initialAnalysis setting
1 parent c4feb94 commit 59a2a80

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

.changeset/unlucky-camels-jam.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 `initialAnalysis` setting

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@
122122
"type": "integer",
123123
"description": "Milliseconds delay between file changes before run analyse",
124124
"default": 200
125+
},
126+
"phpstan.initialAnalysis": {
127+
"type": "boolean",
128+
"description": "Runs the analyse command on startup",
129+
"default": true
125130
}
126131
}
127132
},

src/extension.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export type ExtSettings = {
3333
configFileWatcher: boolean;
3434
analysedDelay: number;
3535
memoryLimit: string;
36+
initialAnalysis: boolean;
3637
};
3738

3839
export type ExtStore = {
@@ -66,6 +67,7 @@ export class Ext<
6667
readonly statusBarItem: StatusBarItem;
6768
readonly commandListeners: Disposable[] = [];
6869
protected fileWatchers = createFileWatcherManager();
70+
protected activations = 0;
6971

7072
constructor(
7173
readonly options: {
@@ -150,6 +152,7 @@ export class Ext<
150152
configFileWatcher: get("configFileWatcher"),
151153
analysedDelay: get("analysedDelay"),
152154
memoryLimit: get("memoryLimit"),
155+
initialAnalysis: get("initialAnalysis"),
153156
};
154157
}
155158

@@ -183,10 +186,11 @@ export class Ext<
183186
}
184187

185188
async activate() {
189+
this.activations++;
186190
await this.call(async () => await this.activateRutine(), "activate");
187191
}
188192

189-
protected async activateRutine(analyse = true) {
193+
protected async activateRutine() {
190194
cmd.executeCommand(
191195
"setContext",
192196
`${this.options.name}:enabled`,
@@ -229,7 +233,8 @@ export class Ext<
229233
});
230234
}
231235

232-
if (analyse) this.options.commands.analyse(this);
236+
if (this.settings.initialAnalysis || this.activations > 1)
237+
this.options.commands.analyse(this);
233238
}
234239

235240
deactivate() {

0 commit comments

Comments
 (0)