From 26fa9f46b0761b310ce680686a9707c68eaa21bf Mon Sep 17 00:00:00 2001 From: Semyon Proshev Date: Wed, 27 Sep 2017 19:42:06 +0300 Subject: [PATCH] Deprecate PyCallExpression.multiResolveCallee(PyResolveContext, int). --- .../python/psi/PyCallExpression.java | 9 +++++--- .../inspections/PyArgumentListInspection.java | 5 ++++- .../psi/impl/PyCallExpressionHelper.java | 22 +++++-------------- .../jetbrains/python/PyResolveCalleeTest.java | 4 ++-- 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/python/psi-api/src/com/jetbrains/python/psi/PyCallExpression.java b/python/psi-api/src/com/jetbrains/python/psi/PyCallExpression.java index 7efc594ed21f..69b26e720dc3 100644 --- a/python/psi-api/src/com/jetbrains/python/psi/PyCallExpression.java +++ b/python/psi-api/src/com/jetbrains/python/psi/PyCallExpression.java @@ -169,7 +169,7 @@ public interface PyCallExpression extends PyCallSiteExpression { * @param resolveContext resolve context * @return an object which contains callable, modifier, implicit offset and "implicitly resolved" flag. * Returns null if the callee cannot be resolved. - * @deprecated Use {@link PyCallExpression#multiResolveCallee(PyResolveContext, int)} instead. + * @deprecated Use {@link PyCallExpression#multiResolveRatedCallee(PyResolveContext)} instead. * This method will be removed in 2018.1. */ @Nullable @@ -186,7 +186,7 @@ public interface PyCallExpression extends PyCallSiteExpression { * @param implicitOffset implicit offset which is known from the context * @return an object which contains callable, modifier, implicit offset and "implicitly resolved" flag. * Returns null if the callee cannot be resolved. - * @deprecated Use {@link PyCallExpression#multiResolveCallee(PyResolveContext, int)} instead. + * @deprecated Use {@link PyCallExpression#multiResolveRatedCallee(PyResolveContext, int)} instead. * This method will be removed in 2018.1. */ @Nullable @@ -216,7 +216,7 @@ public interface PyCallExpression extends PyCallSiteExpression { * @param resolveContext resolve context * @return objects which contains callable, modifier, implicit offset and "implicitly resolved" flag. * Note: the returned list does not contain null values. - * @deprecated Use {@link PyCallExpression#multiResolveCallee(PyResolveContext, int)} instead. + * @deprecated Use {@link PyCallExpression#multiResolveRatedCallee(PyResolveContext)} instead. * This method will be removed in 2018.1. */ @NotNull @@ -232,8 +232,11 @@ public interface PyCallExpression extends PyCallSiteExpression { * @param implicitOffset implicit offset which is known from the context * @return objects which contains callable, modifier, implicit offset and "implicitly resolved" flag. * Note: the returned list does not contain null values. + * @deprecated Use {@link PyCallExpression#multiResolveRatedCallee(PyResolveContext, int)} instead. + * This method will be removed in 2018.1. */ @NotNull + @Deprecated default List multiResolveCallee(@NotNull PyResolveContext resolveContext, int implicitOffset) { return ContainerUtil.map(multiResolveRatedCallee(resolveContext, implicitOffset), PyRatedMarkedCallee::getMarkedCallee); } diff --git a/python/src/com/jetbrains/python/inspections/PyArgumentListInspection.java b/python/src/com/jetbrains/python/inspections/PyArgumentListInspection.java index b1bd3314ae08..f6bc081f04a8 100644 --- a/python/src/com/jetbrains/python/inspections/PyArgumentListInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyArgumentListInspection.java @@ -71,7 +71,10 @@ public class PyArgumentListInspection extends PyInspection { final PyDecorator[] decorators = node.getDecorators(); for (PyDecorator deco : decorators) { if (deco.hasArgumentList()) continue; - final PyCallExpression.PyMarkedCallee markedCallee = ContainerUtil.getFirstItem(deco.multiResolveCallee(getResolveContext(), 0)); + final List ratedMarkedCallees = deco.multiResolveRatedCallee(getResolveContext()); + final PyCallExpression.PyRatedMarkedCallee ratedMarkedCallee = ContainerUtil.getFirstItem(ratedMarkedCallees); + final PyCallExpression.PyMarkedCallee markedCallee = ratedMarkedCallee == null ? null : ratedMarkedCallee.getMarkedCallee(); + if (markedCallee != null && !markedCallee.isImplicitlyResolved()) { final PyCallable callable = markedCallee.getCallable(); if (callable == null) return; diff --git a/python/src/com/jetbrains/python/psi/impl/PyCallExpressionHelper.java b/python/src/com/jetbrains/python/psi/impl/PyCallExpressionHelper.java index 7a9dd4f7127e..3677a42cb098 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyCallExpressionHelper.java +++ b/python/src/com/jetbrains/python/psi/impl/PyCallExpressionHelper.java @@ -1,18 +1,6 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2017 JetBrains s.r.o. +// Use of this source code is governed by the Apache 2.0 license that can be +// found in the LICENSE file. package com.jetbrains.python.psi.impl; import com.intellij.codeInsight.completion.CompletionUtil; @@ -712,8 +700,8 @@ public class PyCallExpressionHelper { } final TypeEvalContext context = resolveContext.getTypeEvalContext(); - return ContainerUtil.map(callExpression.multiResolveCallee(resolveContext, implicitOffset), - markedCallee -> mapArguments(callExpression, argumentList, markedCallee, context)); + return ContainerUtil.map(callExpression.multiResolveRatedCallee(resolveContext, implicitOffset), + ratedMarkedCallee -> mapArguments(callExpression, argumentList, ratedMarkedCallee.getMarkedCallee(), context)); } @NotNull diff --git a/python/testSrc/com/jetbrains/python/PyResolveCalleeTest.java b/python/testSrc/com/jetbrains/python/PyResolveCalleeTest.java index 6d8321fcc484..0daa3ff07ff9 100644 --- a/python/testSrc/com/jetbrains/python/PyResolveCalleeTest.java +++ b/python/testSrc/com/jetbrains/python/PyResolveCalleeTest.java @@ -24,10 +24,10 @@ public class PyResolveCalleeTest extends PyTestCase { final TypeEvalContext context = TypeEvalContext.codeAnalysis(myFixture.getProject(), myFixture.getFile()); final PyResolveContext resolveContext = PyResolveContext.noImplicits().withTypeEvalContext(context); - final List callees = call.multiResolveCallee(resolveContext, 0); + final List callees = call.multiResolveRatedCallee(resolveContext); assertEquals(1, callees.size()); - return callees.get(0); + return callees.get(0).getMarkedCallee(); } public void testInstanceCall() {