Skip to content

Commit 7e6b401

Browse files
committed
fix codeactions for switch statements
Fix handling nulls and associating with diagnostic messages.
1 parent 23b6397 commit 7e6b401

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/codeaction/adddefaulttoswitchaction.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ class Vls.AddDefaultToSwitchAction : CodeAction {
7070

7171
// now, include all relevant diagnostics
7272
foreach (var diag in context.diagnostics)
73-
if (diag.message.contains ("does not handle"))
73+
if (diag.message.contains ("Switch does not handle"))
7474
add_diagnostic (diag);
75-
if (!diagnostics.is_empty)
75+
if (diagnostics != null && !diagnostics.is_empty)
7676
this.kind = "quickfix";
7777
else
7878
this.kind = "refactor.rewrite";

src/codeaction/addotherconstantstoswitchaction.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ class Vls.AddOtherConstantsToSwitchAction : CodeAction {
8181
this.edit.documentChanges = new ArrayList<TextDocumentEdit>.wrap ({document_edit});
8282
// now, include all relevant diagnostics
8383
foreach (var diag in context.diagnostics)
84-
if (/does not implement|some prerequisites .*are not met/.match (diag.message))
84+
if (diag.message.contains ("Switch does not handle"))
8585
add_diagnostic (diag);
86-
if (!diagnostics.is_empty)
86+
if (diagnostics != null && !diagnostics.is_empty)
8787
this.kind = "quickfix";
8888
else
8989
this.kind = "refactor.rewrite";

0 commit comments

Comments
 (0)