def perform_completion(editor):
    """
    Performs the completion on given editor.

    :param editor: Document editor.
    :type editor: QWidget
    :return: Method success.
    :rtype: bool
    """

    completion_prefix = editor.get_partial_word_under_cursor()
    if not completion_prefix:
        return

    words = editor.get_words()
    completion_prefix in words and words.remove(completion_prefix)
    editor.completer.update_model(words)
    editor.completer.setCompletionPrefix(completion_prefix)
    if editor.completer.completionCount() == 1:
        completion = editor.completer.completionModel().data(
            editor.completer.completionModel().index(0, 0)).toString()
        cursor = editor.textCursor()
        cursor.insertText(completion[len(completion_prefix):])
        editor.setTextCursor(cursor)
    else:
        popup = editor.completer.popup()
        popup.setCurrentIndex(editor.completer.completionModel().index(0, 0))

        completer_rectangle = editor.cursorRect()
        hasattr(editor, "margin_area_LinesNumbers_widget") and completer_rectangle.moveTo(
            completer_rectangle.topLeft().x() + editor.margin_area_LinesNumbers_widget.get_width(),
            completer_rectangle.topLeft().y())
        completer_rectangle.setWidth(editor.completer.popup().sizeHintForColumn(0) +
                                     editor.completer.popup().verticalScrollBar().sizeHint().width())
        editor.completer.complete(completer_rectangle)
    return True
Performs the completion on given editor.

    :param editor: Document editor.
    :type editor: QWidget
    :return: Method success.
    :rtype: bool