void (@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) { final PsiFile originalFile = parameters.getOriginalFile(); final PsiElement element = parameters.getPosition(); final PsiElement parent = element.getParent(); final ScopeOwner originalScope = ScopeUtil.getScopeOwner(parameters.getOriginalPosition()); final Condition<PsiElement> fromAnotherScope = e -> ScopeUtil.getScopeOwner(e) != originalScope; addVariantsFromIndex(result, originalFile, PyClassNameIndex.KEY, parent instanceof PyStringLiteralExpression ? getStringLiteralInsertHandler() : getImportingInsertHandler(), // TODO: implement autocompletion for inner classes Conditions.and(fromAnotherScope, PyUtil::isTopLevel), PyClass.class, createClassElementHandler(originalFile)); addVariantsFromIndex(result, originalFile, PyFunctionNameIndex.KEY, getFunctionInsertHandler(parent), Conditions.and(fromAnotherScope, PyUtil::isTopLevel), PyFunction.class, Function.identity()); addVariantsFromIndex(result, originalFile, PyVariableNameIndex.KEY, parent instanceof PyStringLiteralExpression ? getStringLiteralInsertHandler() : getImportingInsertHandler(), Conditions.and(fromAnotherScope, PyUtil::isTopLevel), PyTargetExpression.class, Function.identity()); }