use of com.jetbrains.python.psi.PyKnownDecoratorUtil.KnownDecorator in project intellij-community by JetBrains.
the class PyKnownDecoratorUtil method asKnownDecorator.
@Nullable
public static KnownDecorator asKnownDecorator(@NotNull PyDecorator decorator, @NotNull TypeEvalContext context) {
final QualifiedName qualifiedName = decorator.getQualifiedName();
if (qualifiedName == null) {
return null;
}
if (context.maySwitchToAST(decorator)) {
PyQualifiedNameOwner resolved = as(resolveDecorator(decorator), PyQualifiedNameOwner.class);
if (resolved instanceof PyFunction && PyNames.INIT.equals(resolved.getName())) {
resolved = ((PyFunction) resolved).getContainingClass();
}
if (resolved != null && resolved.getQualifiedName() != null) {
final QualifiedName resolvedName = QualifiedName.fromDottedString(resolved.getQualifiedName());
final KnownDecorator knownDecorator = ourByShortName.get(resolvedName.getLastComponent());
if (knownDecorator != null && resolvedName.equals(knownDecorator.getQualifiedName())) {
return knownDecorator;
}
}
} else {
return ourByShortName.get(qualifiedName.getLastComponent());
}
return null;
}
Aggregations