From 0de584d1b789448ebc7aad66c43eeb2ad8edf5d1 Mon Sep 17 00:00:00 2001 From: John Steele Date: Wed, 28 Aug 2024 14:35:52 -0700 Subject: [PATCH] Integrate new preference item to enable/disable analysis upon open or save manifest documents. --- src/config.ts | 6 ++++++ src/server.ts | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/config.ts b/src/config.ts index 86285447..9dcd4584 100644 --- a/src/config.ts +++ b/src/config.ts @@ -10,6 +10,8 @@ */ class Config { + analyzeOnOpenDocument: string; + analyzeOnSaveDocument: string; stackAnalysisCommand: string; trackRecommendationAcceptanceCommand: string; telemetryId: string; @@ -59,6 +61,8 @@ class Config } load() { + this.analyzeOnOpenDocument = process.env.VSCEXT_ANALYZE_ON_OPEN_DOCUMENT || 'false'; + this.analyzeOnSaveDocument = process.env.VSCEXT_ANALYZE_ON_SAVE_DOCUMENT || 'false'; this.stackAnalysisCommand = process.env.VSCEXT_STACK_ANALYSIS_COMMAND || ''; this.trackRecommendationAcceptanceCommand = process.env.VSCEXT_TRACK_RECOMMENDATION_ACCEPTANCE_COMMAND || ''; this.telemetryId = process.env.VSCEXT_TELEMETRY_ID || ''; @@ -92,6 +96,8 @@ class Config * @param data - The data from extension workspace settings to update the global configuration with. */ updateConfig( rhdaConfig: any ) { + this.analyzeOnOpenDocument = rhdaConfig.analyzeOnOpenDocument ? 'true' : 'false'; + this.analyzeOnSaveDocument = rhdaConfig.analyzeOnSaveDocument ? 'true' : 'false'; this.matchManifestVersions = rhdaConfig.matchManifestVersions ? 'true' : 'false'; this.usePythonVirtualEnvironment = rhdaConfig.usePythonVirtualEnvironment ? 'true' : 'false'; this.useGoMVS = rhdaConfig.useGoMVS ? 'true' : 'false'; diff --git a/src/server.ts b/src/server.ts index d0f0088e..17a97dfc 100644 --- a/src/server.ts +++ b/src/server.ts @@ -63,6 +63,9 @@ const server = new AnalysisLSPServer(connection); * On open document trigger event handler */ connection.onDidOpenTextDocument((params) => { + if (!globalConfig.analyzeOnOpenDocument) { + return; + } server.handleFileEvent(params.textDocument.uri, params.textDocument.text); }); @@ -77,6 +80,9 @@ connection.onDidChangeTextDocument((params) => { * On save document trigger event handler */ connection.onDidSaveTextDocument((params) => { + if (!globalConfig.analyzeOnSaveDocument) { + return; + } server.handleFileEvent(params.textDocument.uri, server.files.fileData[params.textDocument.uri]); });