RefactoringRope/RefactoringServer.py

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

eric ide

mercurial