diff --git a/python/psi-api/src/com/jetbrains/python/psi/PyAnnotationOwner.java b/python/psi-api/src/com/jetbrains/python/psi/PyAnnotationOwner.java
index fa96afd6a16a..f8d6d5d9f75b 100644
--- a/python/psi-api/src/com/jetbrains/python/psi/PyAnnotationOwner.java
+++ b/python/psi-api/src/com/jetbrains/python/psi/PyAnnotationOwner.java
@@ -24,6 +24,12 @@ public interface PyAnnotationOwner {
@Nullable
PyAnnotation getAnnotation();
+ /**
+ * Returns the text of the annotation with the leading colon and arrow stripped.
+ *
+ * It's supposed to be the same value as one can get by calling {@code elem.getAnnotation().getValue().getText()},
+ * but taken from the corresponding stub instead of AST.
+ */
@Nullable
- String getAnnotationContent();
+ String getAnnotationValue();
}
diff --git a/python/src/com/jetbrains/python/PyTypeDeclarationStatementImpl.java b/python/src/com/jetbrains/python/PyTypeDeclarationStatementImpl.java
index 106ad71b77e8..0103c0fb0971 100644
--- a/python/src/com/jetbrains/python/PyTypeDeclarationStatementImpl.java
+++ b/python/src/com/jetbrains/python/PyTypeDeclarationStatementImpl.java
@@ -46,7 +46,7 @@ public class PyTypeDeclarationStatementImpl extends PyElementImpl implements PyT
@Nullable
@Override
- public String getAnnotationContent() {
+ public String getAnnotationValue() {
return getAnnotationContentFromPsi(this);
}
diff --git a/python/src/com/jetbrains/python/codeInsight/typing/PyTypingTypeProvider.java b/python/src/com/jetbrains/python/codeInsight/typing/PyTypingTypeProvider.java
index f9b895986b6c..5dc7e5f700a9 100644
--- a/python/src/com/jetbrains/python/codeInsight/typing/PyTypingTypeProvider.java
+++ b/python/src/com/jetbrains/python/codeInsight/typing/PyTypingTypeProvider.java
@@ -201,7 +201,7 @@ public class PyTypingTypeProvider extends PyTypeProviderBase {
@Nullable
private static Ref getParameterTypeFromAnnotation(@NotNull PyNamedParameter parameter, @NotNull TypeEvalContext context) {
final Ref annotationValueTypeRef = Optional
- .ofNullable(parameter.getAnnotationContent())
+ .ofNullable(parameter.getAnnotationValue())
.map(text -> getStringBasedType(text, parameter, context))
.orElse(null);
@@ -258,7 +258,7 @@ public class PyTypingTypeProvider extends PyTypeProviderBase {
@Nullable
private static PyExpression getReturnTypeAnnotation(@NotNull PyFunction function) {
- final String annotation = function.getAnnotationContent();
+ final String annotation = function.getAnnotationValue();
if (annotation != null) {
return createExpressionFromFragment(annotation, function);
}
@@ -303,7 +303,7 @@ public class PyTypingTypeProvider extends PyTypeProviderBase {
if (GENERIC.equals(target.getQualifiedName())) {
return createTypingGenericType();
}
- final String annotation = target.getAnnotationContent();
+ final String annotation = target.getAnnotationValue();
if (annotation != null) {
return Ref.deref(getStringBasedType(annotation, target, context));
}
diff --git a/python/src/com/jetbrains/python/psi/impl/PyAssignmentStatementImpl.java b/python/src/com/jetbrains/python/psi/impl/PyAssignmentStatementImpl.java
index 238534a1d321..b4457cc58868 100644
--- a/python/src/com/jetbrains/python/psi/impl/PyAssignmentStatementImpl.java
+++ b/python/src/com/jetbrains/python/psi/impl/PyAssignmentStatementImpl.java
@@ -104,7 +104,7 @@ public class PyAssignmentStatementImpl extends PyElementImpl implements PyAssign
@Nullable
@Override
- public String getAnnotationContent() {
+ public String getAnnotationValue() {
return getAnnotationContentFromPsi(this);
}
diff --git a/python/src/com/jetbrains/python/psi/impl/PyFunctionImpl.java b/python/src/com/jetbrains/python/psi/impl/PyFunctionImpl.java
index ed054704cc21..95f663a7ebc7 100644
--- a/python/src/com/jetbrains/python/psi/impl/PyFunctionImpl.java
+++ b/python/src/com/jetbrains/python/psi/impl/PyFunctionImpl.java
@@ -601,7 +601,7 @@ public class PyFunctionImpl extends PyBaseElementImpl implements
@Nullable
@Override
- public String getAnnotationContent() {
+ public String getAnnotationValue() {
return getAnnotationContentFromStubOrPsi(this);
}
diff --git a/python/src/com/jetbrains/python/psi/impl/PyNamedParameterImpl.java b/python/src/com/jetbrains/python/psi/impl/PyNamedParameterImpl.java
index 928009dd724a..976161e54c95 100644
--- a/python/src/com/jetbrains/python/psi/impl/PyNamedParameterImpl.java
+++ b/python/src/com/jetbrains/python/psi/impl/PyNamedParameterImpl.java
@@ -193,7 +193,7 @@ public class PyNamedParameterImpl extends PyBaseElementImpl {
final PyFile file = getTestFile();
final PyFunction func = file.findTopLevelFunction("func");
- final String annotation = func.getAnnotationContent();
+ final String annotation = func.getAnnotationValue();
assertEquals("int", annotation);
assertNotParsed(file);
assertType("() -> int", func, TypeEvalContext.codeInsightFallback(myFixture.getProject()));
@@ -756,7 +756,7 @@ public class PyStubsTest extends PyTestCase {
runWithLanguageLevel(LanguageLevel.PYTHON36, () -> {
final PyFile file = getTestFile();
final PyTargetExpression var = file.findTopLevelAttribute("x");
- final String annotation = var.getAnnotationContent();
+ final String annotation = var.getAnnotationValue();
assertEquals("int", annotation);
assertNotParsed(file);
assertType("int", var, TypeEvalContext.codeInsightFallback(myFixture.getProject()));