List<KnownDecorator> (@NotNull PyDecorator decorator, @NotNull TypeEvalContext context) { final QualifiedName qualifiedName = decorator.getQualifiedName(); if (qualifiedName == null) { return Collections.emptyList(); } if (context.maySwitchToAST(decorator)) { PsiFile containingFile = decorator.getContainingFile(); List<PsiElement> resolved; if (containingFile instanceof PyiFile) { // In .pyi files it's safe to resolve decorators such as "@overload" flow-insensitively. resolved = PyResolveUtil.resolveQualifiedNameInScope(qualifiedName, (ScopeOwner)containingFile, context); } else { resolved = PyUtil.multiResolveTopPriority(Objects.requireNonNull(decorator.getCallee()), PyResolveContext.defaultContext(context)); } return StreamEx.of(resolved) .select(PyQualifiedNameOwner.class) .map(PyQualifiedNameOwner::getQualifiedName) .nonNull() .map(QualifiedName::fromDottedString) .map(BY_QUALIFIED_NAME::get) .nonNull() .toImmutableList(); } else { // The method might have been called during building of PSI stub indexes. Thus, we can't leave this file's boundaries. // TODO Use proper local resolve to imported names here return Collections.unmodifiableList(BY_SHORT_NAME.getOrDefault(qualifiedName.getLastComponent(), Collections.emptyList())); } }