void (@NotNull PsiElement sourcePsi, @NotNull UExpression ref, PsiModifierListOwner target) { PsiType type = ref.getExpressionType(); if (!TypeUtils.isJavaLangString(type) && !TypeUtils.typeEquals(CommonClassNames.JAVA_LANG_CHAR_SEQUENCE, type)) return; if (target instanceof PsiMethod && (StringFlowUtil.isStringProcessingMethod((PsiMethod)target, NlsInfo.factory()) || StringFlowUtil.isPassthroughMethod((PsiMethod)target, null, null, NlsInfo.factory()))) { return; } if (NlsInfo.forModifierListOwner(target).canBeUsedInLocalizedContext()) return; if (NlsInfo.forType(type).canBeUsedInLocalizedContext()) return; String value = target instanceof PsiVariable ? ObjectUtils.tryCast(((PsiVariable)target).computeConstantValue(), String.class) : null; NlsInfo targetInfo = getExpectedNlsInfo(myHolder.getProject(), ref, value, new HashSet<>(), myOnTheFly, true); if (targetInfo instanceof NlsInfo.Localized) { List<LocalQuickFix> fixes = new ArrayList<>(); String fqn = ((NlsInfo.Localized)targetInfo).suggestAnnotation(target); ExternalAnnotationsManager.AnnotationPlace annotationPlace = AddAnnotationPsiFix.choosePlace(fqn, target); boolean addNullSafe = JavaPsiFacade.getInstance(target.getProject()).findClass(NlsInfo.NLS_SAFE, target.getResolveScope()) != null; if (annotationPlace == ExternalAnnotationsManager.AnnotationPlace.IN_CODE && target instanceof JvmModifiersOwner) { fixes.addAll(IntentionWrapper.wrapToQuickFixes(JvmElementActionFactories.createAddAnnotationActions((JvmModifiersOwner)target, AnnotationRequestsKt.annotationRequest(fqn)), sourcePsi.getContainingFile())); if (addNullSafe) { for (IntentionAction action : JvmElementActionFactories.createAddAnnotationActions((JvmModifiersOwner)target, AnnotationRequestsKt.annotationRequest(NlsInfo.NLS_SAFE))) { fixes.add(new IntentionWrapper(action) { @Override public @NotNull String getFamilyName() { return JavaI18nBundle.message("intention.family.name.mark.as.nlssafe"); } }); } } } else { fixes.add(new AddAnnotationFix(fqn, target, AnnotationUtil.NON_NLS)); if (addNullSafe) { fixes.add(new MarkAsSafeFix(target)); } } String description = JavaI18nBundle.message("inspection.i18n.message.non.localized.passed.to.localized"); myHolder.registerProblem(sourcePsi, description, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, fixes.toArray(LocalQuickFix.EMPTY_ARRAY)); } }