From 660127e54e8394e083ebcaa6fbca9e9dceef5a3e Mon Sep 17 00:00:00 2001 From: Mikhail Golubev Date: Mon, 17 Aug 2020 19:55:10 +0300 Subject: [PATCH] i18n: Annotate dynamically built messages in PyArgumentListInspection It would be better to switch to HtmlBuilder API, but the way it constructs the resulting messages is not that straightforward to migrate right now. GitOrigin-RevId: 1033c7a2ec6a9aa2490fb00bbd081dab85e0c5da --- .../inspections/PyArgumentListInspection.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/python/python-psi-impl/src/com/jetbrains/python/inspections/PyArgumentListInspection.java b/python/python-psi-impl/src/com/jetbrains/python/inspections/PyArgumentListInspection.java index 76831fc593be..2d5b67e4d8de 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/inspections/PyArgumentListInspection.java +++ b/python/python-psi-impl/src/com/jetbrains/python/inspections/PyArgumentListInspection.java @@ -6,8 +6,10 @@ import com.intellij.codeInspection.LocalInspectionToolSession; import com.intellij.codeInspection.LocalQuickFix; import com.intellij.codeInspection.ProblemHighlightType; import com.intellij.codeInspection.ProblemsHolder; +import com.intellij.codeInspection.util.InspectionMessage; import com.intellij.lang.ASTNode; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.NlsSafe; import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.PsiPolyVariantReference; import com.intellij.psi.ResolveResult; @@ -294,13 +296,14 @@ public class PyArgumentListInspection extends PyInspection { ); } + @NlsSafe @NotNull - private static String addPossibleCalleesRepresentation(@NotNull String prefix, + private static String addPossibleCalleesRepresentation(@NotNull @InspectionMessage String prefix, @NotNull List mappings, @NotNull TypeEvalContext context, boolean isOnTheFly) { - final String separator = isOnTheFly ? "
" : " "; - final String possibleCalleesRepresentation = calculatePossibleCalleesRepresentation(mappings, context, isOnTheFly); + final @NlsSafe String separator = isOnTheFly ? "
" : " "; + final @NlsSafe String possibleCalleesRepresentation = calculatePossibleCalleesRepresentation(mappings, context, isOnTheFly); if (isOnTheFly) { return XmlStringUtil.wrapInHtml( @@ -316,10 +319,11 @@ public class PyArgumentListInspection extends PyInspection { } } + @NotNull - private static String calculatePossibleCalleesRepresentation(@NotNull List mappings, - @NotNull TypeEvalContext context, - boolean isOnTheFly) { + private static @NlsSafe String calculatePossibleCalleesRepresentation(@NotNull List mappings, + @NotNull TypeEvalContext context, + boolean isOnTheFly) { return StreamEx .of(mappings) .map(PyCallExpression.PyArgumentsMapping::getCallableType) @@ -330,8 +334,8 @@ public class PyArgumentListInspection extends PyInspection { } @Nullable - private static String calculatePossibleCalleeRepresentation(@NotNull PyCallableType callableType, - @NotNull TypeEvalContext context) { + private static @NlsSafe String calculatePossibleCalleeRepresentation(@NotNull PyCallableType callableType, + @NotNull TypeEvalContext context) { final String name = callableType.getCallable() != null ? callableType.getCallable().getName() : ""; final List callableParameters = callableType.getParameters(context); if (callableParameters == null) return null;