diff --git a/src/config.ts b/src/config.ts index 8628544..9dcd458 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 d0f0088..17a97df 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]); });