def _check_word_cursor(self, tc=None):
        """
        Request a go to assignment.

        :param tc: Text cursor which contains the text that we must look for
                   its assignment. Can be None to go to the text that is under
                   the text cursor.
        :type tc: QtGui.QTextCursor
        """
        if not tc:
            tc = TextHelper(self.editor).word_under_cursor()

        request_data = {
            'code': self.editor.toPlainText(),
            'line': tc.blockNumber(),
            'column': tc.columnNumber(),
            'path': self.editor.file.path,
            'encoding': self.editor.file.encoding
        }
        try:
            self.editor.backend.send_request(
                workers.goto_assignments, request_data,
                on_receive=self._on_results_available)
        except NotRunning:
            pass
    def _check_word_cursor(self, tc=None):
        """
        Request a go to assignment.

        :param tc: Text cursor which contains the text that we must look for
                   its assignment. Can be None to go to the text that is under
                   the text cursor.
        :type tc: QtGui.QTextCursor
        """
        if not tc:
            tc = TextHelper(self.editor).word_under_cursor()

        request_data = {
            'code': self.editor.toPlainText(),
            'line': tc.blockNumber(),
            'column': tc.columnNumber(),
            'path': self.editor.file.path,
            'encoding': self.editor.file.encoding
        }
        try:
            self.editor.backend.send_request(
                workers.goto_assignments, request_data,
                on_receive=self._on_results_available)
        except NotRunning:
            pass
Exemple #3
0
 def _on_action_quick_doc_triggered(self):
     tc = TextHelper(self.editor).word_under_cursor(select_whole_word=True)
     request_data = {
         'code': self.editor.toPlainText(),
         'line': tc.blockNumber(),
         'column': tc.columnNumber(),
         'path': self.editor.file.path,
         'encoding': self.editor.file.encoding
     }
     self.editor.backend.send_request(
         quick_doc, request_data, on_receive=self._on_results_available)
    def get_word_under_cursor(self) -> Tuple[PySide2.QtGui.QTextCursor, dict]:
        """Returns the cursor to select word udner it and info.

        Returns:
            tuple: PySide2.QtGui.QTextCursor, dict
        """
        tc = TextHelper(self).word_under_cursor(
            select_whole_word=True)  # type: PySide2.QtGui.QTextCursor
        word_info = {
            'code': self.toPlainText(),
            'line': tc.blockNumber(),
            'column': tc.columnNumber(),
            'path': self.file.path,
            'encoding': self.file.encoding
        }
        # print(word_info)
        return tc, word_info
    def request_goto(self, tc=None):
        """
        Request a go to assignment.

        :param tc: Text cursor which contains the text that we must look for
                   its assignment. Can be None to go to the text that is under
                   the text cursor.
        :type tc: QtGui.QTextCursor
        """
        if not tc:
            tc = TextHelper(self.editor).word_under_cursor()
        if not self._pending:
            request_data = {
                'code': self.editor.toPlainText(),
                'line': tc.blockNumber() + 1,
                'column': tc.columnNumber(),
                'path': self.editor.file.path,
                'encoding': self.editor.file.encoding
            }
            self.editor.backend.send_request(
                workers.goto_assignments, request_data,
                on_receive=self._on_results_available)
            self._pending = True
        self.editor.set_mouse_cursor(QtCore.Qt.WaitCursor)