Introduce HTML redenred version for compatibility warning

This commit is contained in:
Mikhail Zarechenskiy
2020-06-01 10:00:48 +03:00
parent 569b6eaff2
commit 7ec8716d65
11 changed files with 40 additions and 12 deletions
@@ -761,7 +761,7 @@ public interface Errors {
DiagnosticFactory1<PsiElement, KotlinType> REIFIED_TYPE_UNSAFE_SUBSTITUTION = DiagnosticFactory1.create(WARNING);
DiagnosticFactory0<KtElement> CANDIDATE_CHOSEN_USING_OVERLOAD_RESOLUTION_BY_LAMBDA_ANNOTATION = DiagnosticFactory0.create(WARNING);
DiagnosticFactory0<KtElement> COMPATIBILITY_WARNING = DiagnosticFactory0.create(WARNING);
DiagnosticFactory1<KtElement, CallableDescriptor> COMPATIBILITY_WARNING = DiagnosticFactory1.create(WARNING);
DiagnosticFactory3<KtReferenceExpression, ClassifierDescriptor, WrongResolutionToClassifier, String> RESOLUTION_TO_CLASSIFIER =
DiagnosticFactory3.create(ERROR);
@@ -896,9 +896,9 @@ public class DefaultErrorMessages {
MAP.put(REIFIED_TYPE_FORBIDDEN_SUBSTITUTION, "Cannot use ''{0}'' as reified type parameter", RENDER_TYPE);
MAP.put(REIFIED_TYPE_UNSAFE_SUBSTITUTION, "It may be not safe to use ''{0}'' as an argument for a reified type parameter. Use a non-generic type or * if possible", RENDER_TYPE);
MAP.put(TYPE_PARAMETERS_NOT_ALLOWED, "Type parameters are not allowed here");
MAP.put(CANDIDATE_CHOSEN_USING_OVERLOAD_RESOLUTION_BY_LAMBDA_ANNOTATION, "Candidate was choosen only by @OverloadResolutionByLambdaReturnType annotation");
MAP.put(CANDIDATE_CHOSEN_USING_OVERLOAD_RESOLUTION_BY_LAMBDA_ANNOTATION, "Candidate was chosen only by @OverloadResolutionByLambdaReturnType annotation");
MAP.put(COMPATIBILITY_WARNING, "Candidate was chosen to preserve compatibility");
MAP.put(COMPATIBILITY_WARNING, "Candidate resolution will be changed, please invoke explicitly ''{0}''", COMPATIBILITY_CANDIDATE);
MAP.put(TYPE_PARAMETER_OF_PROPERTY_NOT_USED_IN_RECEIVER, "Type parameter of a property must be used in its receiver type");
@@ -197,6 +197,11 @@ object Renderers {
renderAmbiguousDescriptors(descriptors)
}
@JvmField
val COMPATIBILITY_CANDIDATE = Renderer { call: CallableDescriptor ->
renderAmbiguousDescriptors(listOf(call))
}
@JvmField
val AMBIGUOUS_CALLABLE_REFERENCES = Renderer { references: Collection<CallableDescriptor> ->
renderAmbiguousDescriptors(references)
@@ -81,7 +81,12 @@ class DiagnosticReporterByTrackingStrategy(
trace.report(CANDIDATE_CHOSEN_USING_OVERLOAD_RESOLUTION_BY_LAMBDA_ANNOTATION.on(psiKotlinCall.psiCall.callElement))
}
CompatibilityWarning::class.java -> {
trace.report(COMPATIBILITY_WARNING.on(psiKotlinCall.psiCall.callElement))
trace.report(
COMPATIBILITY_WARNING.on(
psiKotlinCall.psiCall.callElement,
(diagnostic as CompatibilityWarning).candidate
)
)
}
}
}
@@ -220,7 +225,12 @@ class DiagnosticReporterByTrackingStrategy(
}
CompatibilityWarningOnArgument::class.java -> {
trace.report(COMPATIBILITY_WARNING.on(callArgument.psiCallArgument.valueArgument.asElement()))
trace.report(
COMPATIBILITY_WARNING.on(
callArgument.psiCallArgument.valueArgument.asElement(),
(diagnostic as CompatibilityWarningOnArgument).candidate
)
)
}
}
}