From 7e6b40153758ce06d872b1b95ca68f1c33f992f1 Mon Sep 17 00:00:00 2001 From: Princeton Ferro Date: Thu, 24 Nov 2022 22:50:21 -0500 Subject: [PATCH] fix codeactions for switch statements Fix handling nulls and associating with diagnostic messages. --- src/codeaction/adddefaulttoswitchaction.vala | 4 ++-- src/codeaction/addotherconstantstoswitchaction.vala | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/codeaction/adddefaulttoswitchaction.vala b/src/codeaction/adddefaulttoswitchaction.vala index f3c4ca97..d494012f 100644 --- a/src/codeaction/adddefaulttoswitchaction.vala +++ b/src/codeaction/adddefaulttoswitchaction.vala @@ -70,9 +70,9 @@ class Vls.AddDefaultToSwitchAction : CodeAction { // now, include all relevant diagnostics foreach (var diag in context.diagnostics) - if (diag.message.contains ("does not handle")) + if (diag.message.contains ("Switch does not handle")) add_diagnostic (diag); - if (!diagnostics.is_empty) + if (diagnostics != null && !diagnostics.is_empty) this.kind = "quickfix"; else this.kind = "refactor.rewrite"; diff --git a/src/codeaction/addotherconstantstoswitchaction.vala b/src/codeaction/addotherconstantstoswitchaction.vala index 7e7b7e56..3a834d95 100644 --- a/src/codeaction/addotherconstantstoswitchaction.vala +++ b/src/codeaction/addotherconstantstoswitchaction.vala @@ -81,9 +81,9 @@ class Vls.AddOtherConstantsToSwitchAction : CodeAction { this.edit.documentChanges = new ArrayList.wrap ({document_edit}); // now, include all relevant diagnostics foreach (var diag in context.diagnostics) - if (/does not implement|some prerequisites .*are not met/.match (diag.message)) + if (diag.message.contains ("Switch does not handle")) add_diagnostic (diag); - if (!diagnostics.is_empty) + if (diagnostics != null && !diagnostics.is_empty) this.kind = "quickfix"; else this.kind = "refactor.rewrite";