Skip to content

Commit

Permalink
feat: add initialAnalysis setting
Browse files Browse the repository at this point in the history
  • Loading branch information
juanrgm committed Sep 21, 2022
1 parent c4feb94 commit 59a2a80
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/unlucky-camels-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"phpstan-vscode": minor
---

Add `initialAnalysis` setting
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
},
Expand Down
9 changes: 7 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type ExtSettings = {
configFileWatcher: boolean;
analysedDelay: number;
memoryLimit: string;
initialAnalysis: boolean;
};

export type ExtStore = {
Expand Down Expand Up @@ -66,6 +67,7 @@ export class Ext<
readonly statusBarItem: StatusBarItem;
readonly commandListeners: Disposable[] = [];
protected fileWatchers = createFileWatcherManager();
protected activations = 0;

constructor(
readonly options: {
Expand Down Expand Up @@ -150,6 +152,7 @@ export class Ext<
configFileWatcher: get("configFileWatcher"),
analysedDelay: get("analysedDelay"),
memoryLimit: get("memoryLimit"),
initialAnalysis: get("initialAnalysis"),
};
}

Expand Down Expand Up @@ -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`,
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 59a2a80

Please sign in to comment.