'Go to definition from cursor instance (QTextCursor)'

@Slot()
def go_to_definition_from_cursor(self, cursor=None):

    if (not self.go_to_definition_enabled):
        return
    if (cursor is None):
        cursor = self.textCursor()
    if self.in_comment_or_string():
        return
    position = cursor.position()
    text = to_text_string(cursor.selectedText())
    if (len(text) == 0):
        cursor.select(QTextCursor.WordUnderCursor)
        text = to_text_string(cursor.selectedText())
    if (not (text is None)):
        self.go_to_definition.emit(position)
