mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Don't split untyped usages into signature match / mismatch groups
We cannot reliably match arguments against parameters in case of unknown qualifier type of a call expression, so there is no point in splitting these usages into two different groups.
This commit is contained in:
@@ -23,11 +23,10 @@ import com.intellij.usages.impl.rules.UsageTypeProviderEx;
|
||||
import com.jetbrains.python.PyNames;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.impl.PyPsiUtils;
|
||||
import com.jetbrains.python.psi.resolve.PyResolveContext;
|
||||
import com.jetbrains.python.psi.types.PyStructuralType;
|
||||
import com.jetbrains.python.psi.types.PyType;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -37,7 +36,6 @@ public class PyUsageTypeProvider implements UsageTypeProviderEx {
|
||||
private static final UsageType UNTYPED = new UsageType("Untyped (probable) usage");
|
||||
private static final UsageType USAGE_IN_ISINSTANCE = new UsageType("Usage in isinstance()");
|
||||
private static final UsageType USAGE_IN_SUPERCLASS = new UsageType("Usage in superclass list");
|
||||
private static final UsageType SIGNATURE_MISMATCH = new UsageType("Untyped (probable) usage, signature mismatch");
|
||||
|
||||
@Override
|
||||
public UsageType getUsageType(PsiElement element) {
|
||||
@@ -54,11 +52,7 @@ public class PyUsageTypeProvider implements UsageTypeProviderEx {
|
||||
if (qualifier != null) {
|
||||
final TypeEvalContext context = TypeEvalContext.userInitiated(element.getProject(), element.getContainingFile());
|
||||
final PyType type = context.getType(qualifier);
|
||||
if (type == null) {
|
||||
final PyCallExpression call = PsiTreeUtil.getParentOfType(element, PyCallExpression.class);
|
||||
if (call != null && element == call.getCallee()) {
|
||||
return checkMatchingSignatureGroup(call, context);
|
||||
}
|
||||
if (type == null || type instanceof PyStructuralType) {
|
||||
return UNTYPED;
|
||||
}
|
||||
}
|
||||
@@ -86,18 +80,4 @@ public class PyUsageTypeProvider implements UsageTypeProviderEx {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static UsageType checkMatchingSignatureGroup(@NotNull PyCallExpression call, @NotNull TypeEvalContext context) {
|
||||
final PyResolveContext resolveContext = PyResolveContext.noImplicits().withTypeEvalContext(context);
|
||||
final PyArgumentList argumentList = call.getArgumentList();
|
||||
final PyCallExpression.PyMarkedCallee callee = call.resolveCallee(resolveContext);
|
||||
if (callee != null && argumentList != null) {
|
||||
final CallArgumentsMapping mapping = argumentList.analyzeCall(resolveContext);
|
||||
if (mapping.hasProblems()) {
|
||||
return SIGNATURE_MISMATCH;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user