Skip to content

Commit

Permalink
Optimized propagation of "fixes" keyword parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Nov 5, 2024
1 parent 1adb128 commit ab5aeb7
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/analysis/typepal/FailMessage.rsc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module analysis::typepal::FailMessage

/*
FailMessages provide a convenient variation on Rascal's standard Message datatype.
FailMessages provide a convenient variation on Rascal's standard Message datatype.
In the end, FailMessages are reduced to standard Messages.
*/
import Message;
Expand All @@ -13,13 +13,19 @@ data FailMessage(list[CodeAction] fixes = [])
| fm_warning(value src, str msg, list[value] args)
| fm_info(value src, str msg, list[value] args)
;

FailMessage error(value src, str msg, value args..., list[CodeAction] fixes=[]) = fm_error(src, msg, args, fixes=fixes);
FailMessage warning(value src, str msg, value args..., list[CodeAction] fixes=[]) = fm_warning(src, msg, args, fixes=fixes);
FailMessage info(value src, str msg, value args..., list[CodeAction] fixes=[]) = fm_info(src, msg, args, fixes=fixes);

FailMessage error(value src, str msg, value args..., list[CodeAction] fixes=[])
= fixes? ? fm_error(src, msg, args, fixes=fixes): fm_error(src, msg, args);
FailMessage warning(value src, str msg, value args..., list[CodeAction] fixes=[])
= fixes? ? fm_warning(src, msg, args, fixes=fixes) : fm_warning(src, msg, args);
FailMessage info(value src, str msg, value args..., list[CodeAction] fixes=[])
= fixes? ? fm_info(src, msg, args, fixes=fixes) : fm_info(src, msg, args);

str escapePercent(str s) = replaceAll(s, "%", "%%");

FailMessage convert(error(str msg, loc at, fixes=list[CodeAction] fixes)) = fm_error(at, escapePercent(msg), [], fixes=fixes);
FailMessage convert(warning(str msg, loc at, fixes=list[CodeAction] fixes)) = fm_warning(at, escapePercent(msg), [], fixes=fixes);
FailMessage convert(info(str msg, loc at, fixes=list[CodeAction] fixes)) = fm_info(at, escapePercent(msg), [], fixes=fixes);

FailMessage convert(error(str msg, loc at, fixes=list[CodeAction] fixes))
= fixes? ? fm_error(at, escapePercent(msg), [], fixes=fixes) : fm_error(src, msg, args);
FailMessage convert(warning(str msg, loc at, fixes=list[CodeAction] fixes))
= fixes? ? fm_warning(at, escapePercent(msg), [], fixes=fixes) : fm_warning(src, msg, args);
FailMessage convert(info(str msg, loc at, fixes=list[CodeAction] fixes))
= fixes? ? fm_info(at, escapePercent(msg), [], fixes=fixes) : fm_info(at, escapePercent(msg), []);

0 comments on commit ab5aeb7

Please sign in to comment.