Refactoring: extract NONE_APPLICABLE renderer

This commit is contained in:
Natalia.Ukhorskaya
2013-04-16 16:01:34 +04:00
parent a9b4a342e7
commit b484ce711f
2 changed files with 83 additions and 83 deletions
@@ -91,12 +91,12 @@ public class IdeErrorMessages {
MAP.put(OVERLOAD_RESOLUTION_AMBIGUITY, "<html>Overload resolution ambiguity. All these functions match. <ul>{0}</ul></html>", HTML_AMBIGUOUS_CALLS); MAP.put(OVERLOAD_RESOLUTION_AMBIGUITY, "<html>Overload resolution ambiguity. All these functions match. <ul>{0}</ul></html>", HTML_AMBIGUOUS_CALLS);
MAP.put(NONE_APPLICABLE, "<html>None of the following functions can be called with the arguments supplied. <ul>{0}</ul></html>", MAP.put(NONE_APPLICABLE, "<html>None of the following functions can be called with the arguments supplied. <ul>{0}</ul></html>",
new NoneApplicableCallsRenderer()); HTML_NONE_APPLICABLE_CALLS);
MAP.put(CANNOT_COMPLETE_RESOLVE, "<html>Cannot choose among the following candidates without completing type inference: <ul>{0}</ul></html>", HTML_AMBIGUOUS_CALLS); MAP.put(CANNOT_COMPLETE_RESOLVE, "<html>Cannot choose among the following candidates without completing type inference: <ul>{0}</ul></html>", HTML_AMBIGUOUS_CALLS);
MAP.put(DELEGATE_SPECIAL_FUNCTION_AMBIGUITY, "<html>Overload resolution ambiguity on method ''{0}''. All these functions match. <ul>{1}</ul></html>", TO_STRING, HTML_AMBIGUOUS_CALLS); MAP.put(DELEGATE_SPECIAL_FUNCTION_AMBIGUITY, "<html>Overload resolution ambiguity on method ''{0}''. All these functions match. <ul>{1}</ul></html>", TO_STRING, HTML_AMBIGUOUS_CALLS);
MAP.put(DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, "<html>Property delegate must have a ''{0}'' method. None of the following functions is suitable. <ul>{1}</ul></html>", MAP.put(DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, "<html>Property delegate must have a ''{0}'' method. None of the following functions is suitable. <ul>{1}</ul></html>",
TO_STRING, new NoneApplicableCallsRenderer()); TO_STRING, HTML_NONE_APPLICABLE_CALLS);
MAP.setImmutable(); MAP.setImmutable();
} }
@@ -84,10 +84,10 @@ public class IdeRenderers {
} }
}; };
public static final Renderer<Collection<? extends ResolvedCall<?>>> HTML_NONE_APPLICABLE_CALLS =
public static class NoneApplicableCallsRenderer implements Renderer<Collection<? extends ResolvedCall<?>>> { new Renderer<Collection<? extends ResolvedCall<? extends CallableDescriptor>>>() {
@Nullable @Nullable
private static ValueParameterDescriptor findParameterByArgumentExpression( private ValueParameterDescriptor findParameterByArgumentExpression(
ResolvedCall<? extends CallableDescriptor> call, ResolvedCall<? extends CallableDescriptor> call,
JetValueArgument argument) { JetValueArgument argument) {
for (Map.Entry<ValueParameterDescriptor, ResolvedValueArgument> entry : call.getValueArguments().entrySet()) { for (Map.Entry<ValueParameterDescriptor, ResolvedValueArgument> entry : call.getValueArguments().entrySet()) {
@@ -100,7 +100,7 @@ public class IdeRenderers {
return null; return null;
} }
private static Set<ValueParameterDescriptor> getParametersToHighlight(ResolvedCall<? extends CallableDescriptor> call) { private Set<ValueParameterDescriptor> getParametersToHighlight(ResolvedCall<? extends CallableDescriptor> call) {
Set<ValueParameterDescriptor> parameters = new HashSet<ValueParameterDescriptor>(); Set<ValueParameterDescriptor> parameters = new HashSet<ValueParameterDescriptor>();
if (call instanceof ResolvedCallImpl) { if (call instanceof ResolvedCallImpl) {
Collection<Diagnostic> diagnostics = ((ResolvedCallImpl)call).getTrace().getBindingContext().getDiagnostics(); Collection<Diagnostic> diagnostics = ((ResolvedCallImpl)call).getTrace().getBindingContext().getDiagnostics();
@@ -172,7 +172,7 @@ public class IdeRenderers {
} }
return stringBuilder.toString(); return stringBuilder.toString();
} }
} };
public static final Renderer<ExtendedInferenceErrorData> HTML_TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS_RENDERER = public static final Renderer<ExtendedInferenceErrorData> HTML_TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS_RENDERER =
new Renderer<ExtendedInferenceErrorData>() { new Renderer<ExtendedInferenceErrorData>() {