mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 06:05:01 +07:00
PY-74012 Deprecation decorator stub resolves during indexing
Avoid using resolve when calculating deprecation messages GitOrigin-RevId: 813849bdaeb3819b445db600fc0efbcb014ed5c9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2f610dc4a8
commit
e6c66dfd5e
@@ -36,8 +36,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.jetbrains.python.ast.impl.PyDeprecationUtilKt.extractDeprecationMessageFromDecorator;
|
||||
|
||||
/**
|
||||
* Represents a class declaration in source.
|
||||
*/
|
||||
@@ -369,12 +367,6 @@ public interface PyClass extends PyAstClass, PsiNameIdentifierOwner, PyCompoundS
|
||||
@Nullable
|
||||
PyClassLikeType getType(@NotNull TypeEvalContext context);
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
default String getDeprecationMessage() {
|
||||
return extractDeprecationMessageFromDecorator(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
default PyStringLiteralExpression getDocStringExpression() {
|
||||
|
||||
@@ -5,5 +5,5 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface PyDeprecatable {
|
||||
@Nullable
|
||||
String getDeprecationMessage();
|
||||
default String getDeprecationMessage() { return null; }
|
||||
}
|
||||
|
||||
@@ -14,10 +14,8 @@ import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static com.jetbrains.python.ast.impl.PyDeprecationUtilKt.extractDeprecationMessageFromDecorator;
|
||||
|
||||
/**
|
||||
* Function declaration in source (the {@code def} and everything within).
|
||||
@@ -72,27 +70,6 @@ public interface PyFunction extends PyAstFunction, StubBasedPsiElement<PyFunctio
|
||||
return (PyStringLiteralExpression)PyAstFunction.super.getDocStringExpression();
|
||||
}
|
||||
|
||||
/**
|
||||
* If the function raises a DeprecationWarning or a PendingDeprecationWarning, returns the explanation text provided for the warning..
|
||||
*
|
||||
* @return the deprecation message or null if the function is not deprecated.
|
||||
*/
|
||||
@Nullable
|
||||
@Override
|
||||
default String getDeprecationMessage() {
|
||||
return extractDeprecationMessage();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default String extractDeprecationMessage() {
|
||||
String deprecationMessageFromDecorator = extractDeprecationMessageFromDecorator(this);
|
||||
if (deprecationMessageFromDecorator != null) {
|
||||
return deprecationMessageFromDecorator;
|
||||
}
|
||||
PyAstStatementList statementList = getStatementList();
|
||||
return extractDeprecationMessage(Arrays.asList(statementList.getStatements()));
|
||||
}
|
||||
|
||||
static @Nullable String extractDeprecationMessage(List<? extends PyAstStatement> statements) {
|
||||
for (PyAstStatement statement : statements) {
|
||||
if (statement instanceof PyAstExpressionStatement expressionStatement) {
|
||||
|
||||
Reference in New Issue
Block a user