Skip to content

Commit

Permalink
fix codeactions for switch statements
Browse files Browse the repository at this point in the history
Fix handling nulls and associating with diagnostic messages.
  • Loading branch information
Prince781 committed Nov 25, 2022
1 parent 23b6397 commit 7e6b401
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/codeaction/adddefaulttoswitchaction.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
4 changes: 2 additions & 2 deletions src/codeaction/addotherconstantstoswitchaction.vala
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ class Vls.AddOtherConstantsToSwitchAction : CodeAction {
this.edit.documentChanges = new ArrayList<TextDocumentEdit>.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";
Expand Down

0 comments on commit 7e6b401

Please sign in to comment.