Don't write "ResolvedCall<? extends CallableDescriptor>"

ResolvedCall has a type parameter D which extends CallableDescriptor.
Hence in Java "ResolvedCall<? extends CallableDescriptor>" = "ResolvedCall<?>"

The same story with these classes:
- ResolutionTask
- CallCandidateResolutionContext
- OverloadResolutionResults
This commit is contained in:
Alexander Udalov
2014-03-17 18:39:04 +04:00
parent 7d6423fcf1
commit 8b18309b01
38 changed files with 131 additions and 194 deletions
@@ -19,7 +19,10 @@ package org.jetbrains.jet.plugin.highlighter;
import com.intellij.lang.annotation.AnnotationHolder;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.descriptors.ConstructorDescriptor;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
@@ -64,8 +67,7 @@ public class FunctionsHighlightingVisitor extends AfterAnalysisHighlightingVisit
public void visitCallExpression(@NotNull JetCallExpression expression) {
JetExpression callee = expression.getCalleeExpression();
if (callee instanceof JetReferenceExpression) {
ResolvedCall<? extends CallableDescriptor> resolvedCall =
bindingContext.get(BindingContext.RESOLVED_CALL, (JetReferenceExpression) callee);
ResolvedCall<?> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, (JetReferenceExpression) callee);
if (resolvedCall != null) {
DeclarationDescriptor calleeDescriptor = resolvedCall.getResultingDescriptor();
if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
@@ -61,12 +61,12 @@ public class IdeRenderers {
}
public static final Renderer<Collection<? extends ResolvedCall<?>>> HTML_AMBIGUOUS_CALLS =
new Renderer<Collection<? extends ResolvedCall<? extends CallableDescriptor>>>() {
new Renderer<Collection<? extends ResolvedCall<?>>>() {
@NotNull
@Override
public String render(@NotNull Collection<? extends ResolvedCall<? extends CallableDescriptor>> calls) {
public String render(@NotNull Collection<? extends ResolvedCall<?>> calls) {
StringBuilder stringBuilder = new StringBuilder("");
for (ResolvedCall<? extends CallableDescriptor> call : calls) {
for (ResolvedCall<?> call : calls) {
stringBuilder.append("<li>");
stringBuilder.append(DescriptorRenderer.HTML.render(call.getResultingDescriptor()));
stringBuilder.append("</li>");
@@ -84,11 +84,9 @@ public class IdeRenderers {
};
public static final Renderer<Collection<? extends ResolvedCall<?>>> HTML_NONE_APPLICABLE_CALLS =
new Renderer<Collection<? extends ResolvedCall<? extends CallableDescriptor>>>() {
new Renderer<Collection<? extends ResolvedCall<?>>>() {
@Nullable
private ValueParameterDescriptor findParameterByArgumentExpression(
ResolvedCall<? extends CallableDescriptor> call,
JetValueArgument argument) {
private ValueParameterDescriptor findParameterByArgumentExpression(ResolvedCall<?> call, JetValueArgument argument) {
for (Map.Entry<ValueParameterDescriptor, ResolvedValueArgument> entry : call.getValueArguments().entrySet()) {
for (ValueArgument va : entry.getValue().getArguments()) {
if (va == argument) {
@@ -99,7 +97,7 @@ public class IdeRenderers {
return null;
}
private Set<ValueParameterDescriptor> getParametersToHighlight(ResolvedCall<? extends CallableDescriptor> call) {
private Set<ValueParameterDescriptor> getParametersToHighlight(ResolvedCall<?> call) {
Set<ValueParameterDescriptor> parameters = new HashSet<ValueParameterDescriptor>();
if (call instanceof ResolvedCallImpl) {
Iterable<Diagnostic> diagnostics = ((ResolvedCallImpl)call).getTrace().getBindingContext().getDiagnostics();
@@ -126,9 +124,9 @@ public class IdeRenderers {
@NotNull
@Override
public String render(@NotNull Collection<? extends ResolvedCall<? extends CallableDescriptor>> calls) {
public String render(@NotNull Collection<? extends ResolvedCall<?>> calls) {
StringBuilder stringBuilder = new StringBuilder("");
for (ResolvedCall<? extends CallableDescriptor> call : calls) {
for (ResolvedCall<?> call : calls) {
stringBuilder.append("<li>");
CallableDescriptor funDescriptor = call.getResultingDescriptor();
Set<ValueParameterDescriptor> parametersToHighlight = getParametersToHighlight(call);
@@ -55,7 +55,6 @@ import org.jetbrains.jet.util.slicedmap.ReadOnlySlice;
import javax.swing.*;
import java.awt.*;
import java.util.List;
import java.util.Map;
import static org.jetbrains.jet.lang.resolve.BindingContext.*;
@@ -200,14 +199,13 @@ public class ResolveToolWindow extends JPanel implements Disposable {
private static String renderDebugInfo(
PsiElement currentElement,
@Nullable ResolutionDebugInfo.Data debugInfo,
@Nullable ResolvedCall<? extends CallableDescriptor> call
@Nullable ResolvedCall<?> call
) {
StringBuilder result = new StringBuilder();
if (debugInfo != null) {
List<? extends ResolutionTask<? extends CallableDescriptor, ?>> resolutionTasks = debugInfo.get(TASKS);
for (ResolutionTask<? extends CallableDescriptor, ?> resolutionTask : resolutionTasks) {
for (ResolvedCallWithTrace<? extends CallableDescriptor> resolvedCall : resolutionTask.getResolvedCalls()) {
for (ResolutionTask<?, ?> resolutionTask : debugInfo.get(TASKS)) {
for (ResolvedCallWithTrace<?> resolvedCall : resolutionTask.getResolvedCalls()) {
renderResolutionLogForCall(debugInfo, resolvedCall, result);
}
}
@@ -225,11 +223,7 @@ public class ResolveToolWindow extends JPanel implements Disposable {
return result.toString();
}
private static void renderResolutionLogForCall(
Data debugInfo,
ResolvedCallWithTrace<? extends CallableDescriptor> resolvedCall,
StringBuilder result
) {
private static void renderResolutionLogForCall(Data debugInfo, ResolvedCallWithTrace<?> resolvedCall, StringBuilder result) {
result.append("Trying to call ").append(resolvedCall.getCandidateDescriptor()).append("\n");
StringBuilder errors = debugInfo.getByKey(ERRORS, resolvedCall);
if (errors != null) {
@@ -265,7 +259,7 @@ public class ResolveToolWindow extends JPanel implements Disposable {
}
}
private static String renderCall(StringBuilder builder, ResolvedCall<? extends CallableDescriptor> resolvedCall) {
private static String renderCall(StringBuilder builder, ResolvedCall<?> resolvedCall) {
CallableDescriptor resultingDescriptor = resolvedCall.getResultingDescriptor();
ReceiverValue receiverArgument = resolvedCall.getReceiverArgument();
ReceiverValue thisObject = resolvedCall.getThisObject();
@@ -67,7 +67,7 @@ public class AddNameToArgumentFix extends JetIntentionAction<JetValueArgument> {
if (!(callee instanceof JetReferenceExpression)) return Collections.emptyList();
BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) argument.getContainingFile()).getBindingContext();
ResolvedCall<? extends CallableDescriptor> resolvedCall = context.get(BindingContext.RESOLVED_CALL, (JetReferenceExpression) callee);
ResolvedCall<?> resolvedCall = context.get(BindingContext.RESOLVED_CALL, (JetReferenceExpression) callee);
if (resolvedCall == null) return Collections.emptyList();
CallableDescriptor callableDescriptor = resolvedCall.getResultingDescriptor();
@@ -19,7 +19,6 @@ package org.jetbrains.jet.plugin.quickfix;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiErrorElement;
import com.intellij.psi.PsiFile;
@@ -27,7 +26,6 @@ import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
@@ -187,8 +185,7 @@ public class ChangeFunctionReturnTypeFix extends JetIntentionAction<JetFunction>
JetBinaryExpression expression = QuickFixUtil.getParentElementOfType(diagnostic, JetBinaryExpression.class);
assert expression != null : "COMPARE_TO_TYPE_MISMATCH reported on element that is not within any expression";
BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) expression.getContainingFile()).getBindingContext();
ResolvedCall<? extends CallableDescriptor> resolvedCall = context.get(BindingContext.RESOLVED_CALL,
expression.getOperationReference());
ResolvedCall<?> resolvedCall = context.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
if (resolvedCall == null) return null;
PsiElement compareTo = BindingContextUtils.descriptorToDeclaration(context, resolvedCall.getCandidateDescriptor());
if (!(compareTo instanceof JetFunction)) return null;
@@ -20,7 +20,6 @@ import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
import org.jetbrains.jet.lang.diagnostics.DiagnosticWithParameters2;
import org.jetbrains.jet.lang.diagnostics.Errors;
@@ -72,7 +71,7 @@ public class QuickFixFactoryForTypeMismatchError implements JetIntentionActionsF
// Fixing overloaded operators:
if (expression instanceof JetOperationExpression) {
ResolvedCall<? extends CallableDescriptor> resolvedCall =
ResolvedCall<?> resolvedCall =
context.get(BindingContext.RESOLVED_CALL, ((JetOperationExpression) expression).getOperationReference());
if (resolvedCall != null) {
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context, resolvedCall.getResultingDescriptor());
@@ -84,7 +83,7 @@ public class QuickFixFactoryForTypeMismatchError implements JetIntentionActionsF
if (expression.getParent() instanceof JetBinaryExpression) {
JetBinaryExpression parentBinary = (JetBinaryExpression) expression.getParent();
if (parentBinary.getRight() == expression) {
ResolvedCall<? extends CallableDescriptor> resolvedCall = context.get(BindingContext.RESOLVED_CALL, parentBinary.getOperationReference());
ResolvedCall<?> resolvedCall = context.get(BindingContext.RESOLVED_CALL, parentBinary.getOperationReference());
if (resolvedCall != null) {
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context, resolvedCall.getResultingDescriptor());
if (declaration instanceof JetFunction) {
@@ -97,7 +96,7 @@ public class QuickFixFactoryForTypeMismatchError implements JetIntentionActionsF
// Change function return type when TYPE_MISMATCH is reported on call expression:
if (expression instanceof JetCallExpression) {
ResolvedCall<? extends CallableDescriptor> resolvedCall =
ResolvedCall<?> resolvedCall =
context.get(BindingContext.RESOLVED_CALL, ((JetCallExpression) expression).getCalleeExpression());
if (resolvedCall != null) {
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context, resolvedCall.getResultingDescriptor());
@@ -99,7 +99,7 @@ public class QuickFixUtil {
@Nullable
public static JetParameterList getParameterListOfCallee(@NotNull JetCallExpression callExpression) {
BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) callExpression.getContainingFile()).getBindingContext();
ResolvedCall<? extends CallableDescriptor> resolvedCall = context.get(BindingContext.RESOLVED_CALL, callExpression.getCalleeExpression());
ResolvedCall<?> resolvedCall = context.get(BindingContext.RESOLVED_CALL, callExpression.getCalleeExpression());
if (resolvedCall == null) return null;
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context, resolvedCall.getCandidateDescriptor());
if (declaration instanceof JetFunction) {
@@ -45,12 +45,11 @@ import com.intellij.refactoring.util.RefactoringMessageDialog;
import com.intellij.util.Function;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory;
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory;
import org.jetbrains.jet.lang.diagnostics.Errors;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
@@ -344,7 +343,7 @@ public class KotlinInlineValHandler extends InlineActionHandler {
JetExpression callee = callExpression.getCalleeExpression();
BindingContext context = AnalyzerFacadeWithCache.getContextForElement(initializer);
ResolvedCall<? extends CallableDescriptor> call = context.get(BindingContext.RESOLVED_CALL, callee);
ResolvedCall<?> call = context.get(BindingContext.RESOLVED_CALL, callee);
if (call == null) {
return null;
}
@@ -20,7 +20,6 @@ import com.intellij.lang.ASTNode;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.MultiRangeReference;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
@@ -49,7 +48,7 @@ class JetInvokeFunctionReference extends JetSimpleReference<JetCallExpression> i
@Override
@NotNull
protected Collection<DeclarationDescriptor> getTargetDescriptors(@NotNull BindingContext context) {
ResolvedCall<? extends CallableDescriptor> resolvedCall = context.get(RESOLVED_CALL, getExpression().getCalleeExpression());
ResolvedCall<?> resolvedCall = context.get(RESOLVED_CALL, getExpression().getCalleeExpression());
if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
return Collections.<DeclarationDescriptor>singleton(((VariableAsFunctionResolvedCall) resolvedCall).getCandidateDescriptor());
}