From f46e9de8cf65ff3af1dd9a96db192636a5d8088f Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Tue, 8 Mar 2022 22:19:08 +0100 Subject: [PATCH 1/2] expose stop dead code analysis mode command --- package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package.json b/package.json index 5c636a639..637b453b1 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,10 @@ { "command": "rescript-vscode.start_dead_code_analysis", "title": "ReScript: Start dead code analysis." + }, + { + "command": "rescript-vscode.stop_dead_code_analysis", + "title": "ReScript: Stop dead code analysis." } ], "menus": { From bab39e01c1d1ea8b42ad23ae5187a112d09eab7e Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Tue, 8 Mar 2022 22:25:40 +0100 Subject: [PATCH 2/2] do not mark redundant optional argument warnings as unecessary/unused code --- client/src/commands/dead_code_analysis.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/client/src/commands/dead_code_analysis.ts b/client/src/commands/dead_code_analysis.ts index 4171aed47..346aef42e 100644 --- a/client/src/commands/dead_code_analysis.ts +++ b/client/src/commands/dead_code_analysis.ts @@ -132,15 +132,21 @@ let dceTextToDiagnostics = ( } let issueLocationRange = new Range(startPos, endPos); + let diagnosticText = text.trim(); let diagnostic = new Diagnostic( issueLocationRange, - text.trim(), + diagnosticText, DiagnosticSeverity.Warning ); - // This will render the part of the code as unused - diagnostic.tags = [DiagnosticTag.Unnecessary]; + // Everything reanalyze reports is about dead code, except for redundant + // optional arguments. This will ensure that everything but reduntant + // optional arguments is highlighted as unecessary/unused code in the + // editor. + if (!diagnosticText.toLowerCase().startsWith("optional argument")) { + diagnostic.tags = [DiagnosticTag.Unnecessary]; + } if (diagnosticsMap.has(processedFileInfo.filePath)) { diagnosticsMap.get(processedFileInfo.filePath).push(diagnostic);