Skip to content

Commit

Permalink
feat: Integrate new preference item to enable/disable analysis upon o…
Browse files Browse the repository at this point in the history
…pen or save manifest documents.
  • Loading branch information
johnsteele committed Sep 5, 2024
1 parent 956daab commit 0d125ec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
*/
class Config
{
analyzeOnOpenDocument: string;
analyzeOnSaveDocument: string;
stackAnalysisCommand: string;
trackRecommendationAcceptanceCommand: string;
telemetryId: string;
Expand Down Expand Up @@ -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 || '';
Expand Down Expand Up @@ -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';
Expand Down
6 changes: 6 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand All @@ -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]);
});

Expand Down

0 comments on commit 0d125ec

Please sign in to comment.