1741 |
1741 |
1742 filename = aw.getFileName() |
1742 filename = aw.getFileName() |
1743 line, index = aw.getCursorPosition() |
1743 line, index = aw.getCursorPosition() |
1744 offset = self.__getOffset(aw, line, index) |
1744 offset = self.__getOffset(aw, line, index) |
1745 |
1745 |
|
1746 # TODO: remove Subcommand handling |
1746 self.sendJson("QueryDefinition", { |
1747 self.sendJson("QueryDefinition", { |
1747 "Title": title, |
1748 "Title": title, |
1748 "FileName": filename, |
1749 "FileName": filename, |
1749 "Offset": offset, |
1750 "Offset": offset, |
1750 "Source": aw.text(), |
1751 "Source": aw.text(), |
1751 "Subcommand": "Query", |
1752 "Subcommand": "Query", |
1752 }) |
1753 }) |
1753 |
1754 |
1754 def gotoDefinition(self, editor): |
1755 # TODO: move this to code assist |
1755 """ |
1756 ## def gotoDefinition(self, editor): |
1756 Public slot to find the definition for the word at the cursor position |
1757 ## """ |
1757 and go to it. |
1758 ## Public slot to find the definition for the word at the cursor position |
1758 |
1759 ## and go to it. |
1759 Note: This is executed upon a mouse click sequence. |
1760 ## |
1760 |
1761 ## Note: This is executed upon a mouse click sequence. |
1761 @param editor reference to the calling editor |
1762 ## |
1762 @type QScintilla.Editor.Editor |
1763 ## @param editor reference to the calling editor |
1763 """ |
1764 ## @type QScintilla.Editor.Editor |
1764 if self.__projectopen: |
1765 ## """ |
1765 filename = editor.getFileName() |
1766 ## if self.__projectopen: |
1766 line, index = editor.getCursorPosition() |
1767 ## filename = editor.getFileName() |
1767 offset = self.__getOffset(editor, line, index) |
1768 ## line, index = editor.getCursorPosition() |
1768 |
1769 ## offset = self.__getOffset(editor, line, index) |
1769 self.sendJson("QueryDefinition", { |
1770 ## |
1770 "Title": "", |
1771 ## self.sendJson("QueryDefinition", { |
1771 "FileName": filename, |
1772 ## "Title": "", |
1772 "Offset": offset, |
1773 ## "FileName": filename, |
1773 "Source": editor.text(), |
1774 ## "Offset": offset, |
1774 "Subcommand": "Goto", |
1775 ## "Source": editor.text(), |
1775 }) |
1776 ## "Subcommand": "Goto", |
1776 |
1777 ## }) |
|
1778 ## |
1777 def __queryDefinitionResult(self, result): |
1779 def __queryDefinitionResult(self, result): |
1778 """ |
1780 """ |
1779 Private method to handle the "Query Definition" result sent by |
1781 Private method to handle the "Query Definition" result sent by |
1780 the client. |
1782 the client. |
1781 |
1783 |
1782 @param result dictionary containing the result data |
1784 @param result dictionary containing the result data |
1783 @type dict |
1785 @type dict |
1784 """ |
1786 """ |
|
1787 # TODO: remove Subcommand handling |
1785 if result["Subcommand"] == "Query": |
1788 if result["Subcommand"] == "Query": |
1786 if self.handleRopeError(result): |
1789 if self.handleRopeError(result): |
1787 title = result["Title"] |
1790 title = result["Title"] |
1788 if "Location" in result: |
1791 if "Location" in result: |
1789 location = result["Location"] |
1792 location = result["Location"] |
1795 # file name, lineno |
1798 # file name, lineno |
1796 else: |
1799 else: |
1797 E5MessageBox.warning( |
1800 E5MessageBox.warning( |
1798 self.__ui, title, |
1801 self.__ui, title, |
1799 self.tr("No matching definition found.")) |
1802 self.tr("No matching definition found.")) |
1800 elif result["Subcommand"] == "Goto": |
1803 # TODO: move this to code assist |
1801 if "Error" not in result: |
1804 ## elif result["Subcommand"] == "Goto": |
1802 # ignore errors silently |
1805 ## if "Error" not in result: |
1803 if "Location" in result: |
1806 ## # ignore errors silently |
1804 location = result["Location"] |
1807 ## if "Location" in result: |
1805 try: |
1808 ## location = result["Location"] |
1806 self.__vm.openSourceFile( |
1809 ## try: |
1807 location[0], location[1], addNext=True) |
1810 ## self.__vm.openSourceFile( |
1808 except TypeError: |
1811 ## location[0], location[1], addNext=True) |
1809 # backward compatibility; <= 17.03 |
1812 ## except TypeError: |
1810 self.__vm.openSourceFile( |
1813 ## # backward compatibility; <= 17.03 |
1811 location[0], location[1], next=True) |
1814 ## self.__vm.openSourceFile( |
1812 else: |
1815 ## location[0], location[1], next=True) |
1813 e5App().getObject("UserInterface").statusBar().showMessage( |
1816 ## else: |
1814 self.tr('No definition found'), 5000) |
1817 ## e5App().getObject("UserInterface").statusBar().showMessage( |
|
1818 ## self.tr('No definition found'), 5000) |
1815 |
1819 |
1816 def __queryImplementations(self): |
1820 def __queryImplementations(self): |
1817 """ |
1821 """ |
1818 Private slot to handle the Find Implementations action. |
1822 Private slot to handle the Find Implementations action. |
1819 """ |
1823 """ |
2325 ok = self.startClient(interpreter, client, [self.__projectpath], |
2329 ok = self.startClient(interpreter, client, [self.__projectpath], |
2326 environment=clientEnv) |
2330 environment=clientEnv) |
2327 else: |
2331 else: |
2328 ok = False |
2332 ok = False |
2329 return ok |
2333 return ok |
2330 |
2334 ## |
2331 ######################################################################### |
2335 ## ######################################################################### |
2332 ## Methods below handle setting/unsetting the mouse click handler methods |
2336 ## ## Methods below handle setting/unsetting the mouse click handler methods |
2333 ######################################################################### |
2337 ## ######################################################################### |
2334 |
2338 ## |
2335 def connectEditor(self, editor): |
2339 ## # TODO: move this to code assist |
2336 """ |
2340 ## def connectEditor(self, editor): |
2337 Public method to connect an editor. |
2341 ## """ |
2338 |
2342 ## Public method to connect an editor. |
2339 @param editor reference to the editor |
2343 ## |
2340 @type QScintilla.Editor.Editor |
2344 ## @param editor reference to the editor |
2341 """ |
2345 ## @type QScintilla.Editor.Editor |
2342 if self.__plugin.getPreferences("MouseClickEnabled"): |
2346 ## """ |
2343 self.__disconnectMouseClickHandler(editor) |
2347 ## if self.__plugin.getPreferences("MouseClickEnabled"): |
2344 self.__connectMouseClickHandler(editor) |
2348 ## self.__disconnectMouseClickHandler(editor) |
2345 |
2349 ## self.__connectMouseClickHandler(editor) |
2346 def disconnectEditor(self, editor): |
2350 ## |
2347 """ |
2351 ## # TODO: move this to code assist |
2348 Public method to disconnect an editor. |
2352 ## def disconnectEditor(self, editor): |
2349 |
2353 ## """ |
2350 @param editor reference to the editor |
2354 ## Public method to disconnect an editor. |
2351 @type QScintilla.Editor.Editor |
2355 ## |
2352 """ |
2356 ## @param editor reference to the editor |
2353 self.__disconnectMouseClickHandler(editor) |
2357 ## @type QScintilla.Editor.Editor |
2354 |
2358 ## """ |
2355 def __connectMouseClickHandler(self, editor): |
2359 ## self.__disconnectMouseClickHandler(editor) |
2356 """ |
2360 ## |
2357 Private method to connect the mouse click handler to an editor. |
2361 ## # TODO: move this to code assist |
2358 |
2362 ## def __connectMouseClickHandler(self, editor): |
2359 @param editor reference to the editor |
2363 ## """ |
2360 @type QScintilla.Editor.Editor |
2364 ## Private method to connect the mouse click handler to an editor. |
2361 """ |
2365 ## |
2362 if self.__plugin.getPreferences("MouseClickGotoButton"): |
2366 ## @param editor reference to the editor |
2363 editor.setMouseClickHandler( |
2367 ## @type QScintilla.Editor.Editor |
2364 "rope", |
2368 ## """ |
2365 self.__plugin.getPreferences("MouseClickGotoModifiers"), |
2369 ## if self.__plugin.getPreferences("MouseClickGotoButton"): |
2366 self.__plugin.getPreferences("MouseClickGotoButton"), |
2370 ## editor.setMouseClickHandler( |
2367 self.gotoDefinition |
2371 ## "rope", |
2368 ) |
2372 ## self.__plugin.getPreferences("MouseClickGotoModifiers"), |
2369 |
2373 ## self.__plugin.getPreferences("MouseClickGotoButton"), |
2370 def __disconnectMouseClickHandler(self, editor): |
2374 ## self.gotoDefinition |
2371 """ |
2375 ## ) |
2372 Private method to disconnect the mouse click handler from an editor. |
2376 ## |
2373 |
2377 ## # TODO: move this to code assist |
2374 @param editor reference to the editor |
2378 ## def __disconnectMouseClickHandler(self, editor): |
2375 @type QScintilla.Editor.Editor |
2379 ## """ |
2376 """ |
2380 ## Private method to disconnect the mouse click handler from an editor. |
2377 editor.removeMouseClickHandlers("rope") |
2381 ## |
|
2382 ## @param editor reference to the editor |
|
2383 ## @type QScintilla.Editor.Editor |
|
2384 ## """ |
|
2385 ## editor.removeMouseClickHandlers("rope") |