diff --git a/src/analysis/typepal/FailMessage.rsc b/src/analysis/typepal/FailMessage.rsc index 65bc4d9..e7a12cb 100644 --- a/src/analysis/typepal/FailMessage.rsc +++ b/src/analysis/typepal/FailMessage.rsc @@ -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; @@ -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), []);