Skip to content
This repository was archived by the owner on Jul 8, 2025. It is now read-only.

Commit 0de584d

Browse files
committed
Integrate new preference item to enable/disable analysis upon open or save manifest documents.
1 parent 956daab commit 0de584d

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
*/
1111
class Config
1212
{
13+
analyzeOnOpenDocument: string;
14+
analyzeOnSaveDocument: string;
1315
stackAnalysisCommand: string;
1416
trackRecommendationAcceptanceCommand: string;
1517
telemetryId: string;
@@ -59,6 +61,8 @@ class Config
5961
}
6062

6163
load() {
64+
this.analyzeOnOpenDocument = process.env.VSCEXT_ANALYZE_ON_OPEN_DOCUMENT || 'false';
65+
this.analyzeOnSaveDocument = process.env.VSCEXT_ANALYZE_ON_SAVE_DOCUMENT || 'false';
6266
this.stackAnalysisCommand = process.env.VSCEXT_STACK_ANALYSIS_COMMAND || '';
6367
this.trackRecommendationAcceptanceCommand = process.env.VSCEXT_TRACK_RECOMMENDATION_ACCEPTANCE_COMMAND || '';
6468
this.telemetryId = process.env.VSCEXT_TELEMETRY_ID || '';
@@ -92,6 +96,8 @@ class Config
9296
* @param data - The data from extension workspace settings to update the global configuration with.
9397
*/
9498
updateConfig( rhdaConfig: any ) {
99+
this.analyzeOnOpenDocument = rhdaConfig.analyzeOnOpenDocument ? 'true' : 'false';
100+
this.analyzeOnSaveDocument = rhdaConfig.analyzeOnSaveDocument ? 'true' : 'false';
95101
this.matchManifestVersions = rhdaConfig.matchManifestVersions ? 'true' : 'false';
96102
this.usePythonVirtualEnvironment = rhdaConfig.usePythonVirtualEnvironment ? 'true' : 'false';
97103
this.useGoMVS = rhdaConfig.useGoMVS ? 'true' : 'false';

src/server.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ const server = new AnalysisLSPServer(connection);
6363
* On open document trigger event handler
6464
*/
6565
connection.onDidOpenTextDocument((params) => {
66+
if (!globalConfig.analyzeOnOpenDocument) {
67+
return;
68+
}
6669
server.handleFileEvent(params.textDocument.uri, params.textDocument.text);
6770
});
6871

@@ -77,6 +80,9 @@ connection.onDidChangeTextDocument((params) => {
7780
* On save document trigger event handler
7881
*/
7982
connection.onDidSaveTextDocument((params) => {
83+
if (!globalConfig.analyzeOnSaveDocument) {
84+
return;
85+
}
8086
server.handleFileEvent(params.textDocument.uri, server.files.fileData[params.textDocument.uri]);
8187
});
8288

0 commit comments

Comments
 (0)