Deprecate PyClassStub.getSubscriptedSuperClasses (PY-29929)

This commit is contained in:
Semyon Proshev
2019-02-05 18:14:59 +03:00
parent 0d4c296991
commit 77c047598b
3 changed files with 17 additions and 6 deletions
@@ -32,17 +32,21 @@ import java.util.Map;
public interface PyClassStub extends NamedStub<PyClass> {
/**
* @return a {@code Map} which contains imported class names as keys and their original names as values.
* <i>Note: the returned {@code Map} could contain nulls as keys and as values.</i>
*/
* @return a {@code Map} which contains imported class names as keys and their original names as values.
* <i>Note: the returned {@code Map} could contain nulls as keys and as values.</i>
*/
@NotNull
Map<QualifiedName, QualifiedName> getSuperClasses();
/**
* Returns literal text of the subscription expressions in the base classes list.
* It's intended to be used for resolving generic types and type parameters in PEP 484 notation.
*
* @deprecated Use {@link PyClassStub#getSuperClassesText()} instead.
* This method will be removed in 2019.2.
*/
@NotNull
@Deprecated
List<String> getSubscriptedSuperClasses();
@Nullable
@@ -54,6 +58,10 @@ public interface PyClassStub extends NamedStub<PyClass> {
@Nullable
String getDocString();
/**
* @return literal text of expressions in the base classes list.
* @apiNote This method will be marked as abstract in 2019.2.
*/
@NotNull
default List<String> getSuperClassesText() {
return Collections.emptyList();
@@ -83,8 +83,6 @@ public class PyClassElementType extends PyStubElementType<PyClassStub, PyClass>
* their saved text chunks into {@link PyExpressionCodeFragment} and extracting top-level expressions
* from them. Otherwise, get suitable expressions directly from AST, but process them in the same way as
* if they were going to be saved in the stub.
*
* @see PyClassStub#getSubscriptedSuperClasses()
*/
@NotNull
public static List<PySubscriptionExpression> getSubscriptedSuperClassesStubLike(@NotNull PyClass pyClass) {
@@ -92,7 +90,7 @@ public class PyClassElementType extends PyStubElementType<PyClassStub, PyClass>
if (classStub == null) {
return getSubscriptedSuperClasses(pyClass);
}
return ContainerUtil.mapNotNull(classStub.getSubscriptedSuperClasses(),
return ContainerUtil.mapNotNull(classStub.getSuperClassesText(),
x -> as(PyUtil.createExpressionFromFragment(x, pyClass.getContainingFile()),
PySubscriptionExpression.class));
}
@@ -38,6 +38,11 @@ public class PyClassStubImpl extends StubBase<PyClass> implements PyClassStub {
@NotNull
private final List<String> mySuperClassesText;
/**
* @deprecated Use {@link PyClassStubImpl#PyClassStubImpl(String, StubElement, Map, List, List, QualifiedName, List, String, IStubElementType)} instead.
* This constructor will be removed in 2019.2.
*/
@Deprecated
public PyClassStubImpl(@Nullable String name,
@Nullable StubElement parentStub,
@NotNull Map<QualifiedName, QualifiedName> superClasses,