LookupElement (@NotNull LookupElementBuilder item) { final PsiElement element = item.getPsiElement(); if (!myPlainNamesOnly && element != null) { final Project project = element.getProject(); final TypeEvalContext context = TypeEvalContext.codeCompletion(project, myContext != null ? myContext.getContainingFile() : null); if (!mySuppressParentheses && element instanceof PyFunction && ((PyFunction)element).getProperty() == null && !PyKnownDecoratorUtil.hasUnknownDecorator((PyFunction)element, context) && !isSingleArgDecoratorCall(myContext, (PyFunction)element)) { item = item.withInsertHandler(PyFunctionInsertHandler.INSTANCE); final List<PyCallableParameter> parameters = ((PyFunction)element).getParameters(context); final String params = StringUtil.join(parameters, PyCallableParameter::getName, ", "); item = item.withTailText("(" + params + ")"); } else if (element instanceof PyClass) { item = item.withInsertHandler(PyClassInsertHandler.INSTANCE); } } String source = null; if (element != null) { PyClass cls = null; if (element instanceof PyFunction) { cls = ((PyFunction)element).getContainingClass(); } else if (element instanceof PyTargetExpression expr) { if (expr.isQualified() || ScopeUtil.getScopeOwner(expr) instanceof PyClass) { cls = expr.getContainingClass(); } } else if (element instanceof PyClass) { final ScopeOwner owner = ScopeUtil.getScopeOwner(element); if (owner instanceof PyClass) { cls = (PyClass)owner; } } if (cls != null) { source = cls.getName(); } else if (myContext == null || !PyUtil.inSameFile(myContext, element)) { final PsiFileSystemItem fileSystemItem = PyPsiUtils.getFileSystemItem(element); final QualifiedName path = QualifiedNameFinder.findShortestImportableQName(fileSystemItem); if (path != null) { source = ObjectUtils.chooseNotNull(QualifiedNameFinder.canonizeQualifiedName(fileSystemItem, path, null), path).toString(); } } } if (source != null) { item = item.withTypeText(source); } final PsiElement parent = myContext != null ? myContext.getParent() : null; if (parent instanceof PyKeywordArgument) { final String keyword = ((PyKeywordArgument)parent).getKeyword(); if (item.getLookupString().equals(keyword)) { return PrioritizedLookupElement.withPriority(item, PythonCompletionWeigher.PRIORITY_WEIGHT); } } PyCompletionMlElementInfo info = PyCompletionMlElementInfo.Companion.fromElement(element); item.putUserData(PyCompletionMlElementInfo.Companion.getKey(), info); return item; }