From 8a1b6a9b906f69ba94783b869163c8d3726c50a7 Mon Sep 17 00:00:00 2001 From: Joseph Britton <85815005+JoeeBritton@users.noreply.github.com> Date: Tue, 17 Oct 2023 22:27:22 -0700 Subject: [PATCH 1/2] Stdio patch Do not log validation status on stdout, use connection logs instead. See #540, #541 --- src/providers/validationProvider.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/providers/validationProvider.ts b/src/providers/validationProvider.ts index 263d5bcb..7ba38096 100644 --- a/src/providers/validationProvider.ts +++ b/src/providers/validationProvider.ts @@ -36,7 +36,7 @@ export async function doValidate( const settings = await context.documentSettings.get(textDocument.uri); if (!settings.validation.enabled) { - console.log("Validation disabled"); + connection.console.log("Validation disabled"); // this is done to remove the cache as well const blankDiagnostics = new Map(); @@ -54,10 +54,10 @@ export async function doValidate( : settings.validation.lint.path; const lintAvailability = await commandRunner.getExecutablePath(lintExecutable); - console.debug("Path for lint: ", lintAvailability); + connection.console.log(`Path for lint: ${lintAvailability}`); if (lintAvailability) { - console.debug("Validating using ansible-lint"); + connection.console.log("Validating using ansible-lint"); diagnosticsByFile = await context.ansibleLint.doValidate(textDocument); } else { connection?.window.showErrorMessage( @@ -68,14 +68,14 @@ export async function doValidate( // validate using ansible-playbook --syntax-check else { - console.debug("Validating using ansible syntax-check"); + connection.console.log("Validating using ansible syntax-check"); if (isPlaybook(textDocument)) { - console.debug("playbook file"); + connection.console.log("playbook file"); diagnosticsByFile = await context.ansiblePlaybook.doValidate(textDocument); } else { - console.debug("non-playbook file"); + connection.console.log("non-playbook file"); diagnosticsByFile = new Map(); } } From cc2654adac2eec8e491b1b30779119740c6946f1 Mon Sep 17 00:00:00 2001 From: Joseph Britton <85815005+JoeeBritton@users.noreply.github.com> Date: Tue, 17 Oct 2023 23:15:29 -0700 Subject: [PATCH 2/2] Fix: use optional chaining for connection as it may not exist for purposes of testing. --- src/providers/validationProvider.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/providers/validationProvider.ts b/src/providers/validationProvider.ts index 7ba38096..09113cb3 100644 --- a/src/providers/validationProvider.ts +++ b/src/providers/validationProvider.ts @@ -36,7 +36,7 @@ export async function doValidate( const settings = await context.documentSettings.get(textDocument.uri); if (!settings.validation.enabled) { - connection.console.log("Validation disabled"); + connection?.console.log("Validation disabled"); // this is done to remove the cache as well const blankDiagnostics = new Map(); @@ -54,10 +54,10 @@ export async function doValidate( : settings.validation.lint.path; const lintAvailability = await commandRunner.getExecutablePath(lintExecutable); - connection.console.log(`Path for lint: ${lintAvailability}`); + connection?.console.log(`Path for lint: ${lintAvailability}`); if (lintAvailability) { - connection.console.log("Validating using ansible-lint"); + connection?.console.log("Validating using ansible-lint"); diagnosticsByFile = await context.ansibleLint.doValidate(textDocument); } else { connection?.window.showErrorMessage( @@ -68,14 +68,14 @@ export async function doValidate( // validate using ansible-playbook --syntax-check else { - connection.console.log("Validating using ansible syntax-check"); + connection?.console.log("Validating using ansible syntax-check"); if (isPlaybook(textDocument)) { - connection.console.log("playbook file"); + connection?.console.log("playbook file"); diagnosticsByFile = await context.ansiblePlaybook.doValidate(textDocument); } else { - connection.console.log("non-playbook file"); + connection?.console.log("non-playbook file"); diagnosticsByFile = new Map(); } }