RefactoringRope/RefactoringServer.py

branch
server_client_variant
changeset 203
c38750e1bafd
parent 202
a111134b5dc7
child 208
df77c3a4976d
equal deleted inserted replaced
202:a111134b5dc7 203:c38750e1bafd
12 str = unicode # __IGNORE_WARNING__ 12 str = unicode # __IGNORE_WARNING__
13 except NameError: 13 except NameError:
14 pass 14 pass
15 15
16 import os 16 import os
17 import sys
18
19 # TODO: eliminate this
20 sys.path.insert(0, os.path.dirname(__file__))
21 17
22 from PyQt5.QtCore import pyqtSlot 18 from PyQt5.QtCore import pyqtSlot
23 from PyQt5.QtWidgets import QMenu, QApplication, QAction 19 from PyQt5.QtWidgets import QMenu, QApplication, QAction
24 from PyQt5.Qsci import QsciScintilla 20 from PyQt5.Qsci import QsciScintilla
25 21
26 from E5Gui.E5Application import e5App 22 from E5Gui.E5Application import e5App
27 from E5Gui import E5MessageBox 23 from E5Gui import E5MessageBox
28 from E5Gui.E5Action import E5Action 24 from E5Gui.E5Action import E5Action
29 25
30 from JsonServer import JsonServer 26 from .JsonServer import JsonServer
31 from RopeProgressDialog import RopeProgressDialog 27 from .RopeProgressDialog import RopeProgressDialog
32 28
33 import Utilities 29 import Utilities
34 import Preferences 30 import Preferences
35 31
36 from Preferences.Shortcuts import readShortcuts 32 from Preferences.Shortcuts import readShortcuts
66 self.__progressDialog = None 62 self.__progressDialog = None
67 self.__helpDialog = None 63 self.__helpDialog = None
68 self.__historyDialog = None 64 self.__historyDialog = None
69 self.__refactoringDialogs = {} 65 self.__refactoringDialogs = {}
70 66
71 from FileSystemCommands import E5FileSystemCommands 67 from .FileSystemCommands import E5FileSystemCommands
72 self.__fsCommands = E5FileSystemCommands(self.__e5project) 68 self.__fsCommands = E5FileSystemCommands(self.__e5project)
73 69
74 self.__methodMapping = { 70 self.__methodMapping = {
75 "Config": self.__setConfig, 71 "Config": self.__setConfig,
76 "Progress": self.__processProgress, 72 "Progress": self.__processProgress,
736 732
737 def __initMenu(self): 733 def __initMenu(self):
738 """ 734 """
739 Private slot to initialize the refactoring menu. 735 Private slot to initialize the refactoring menu.
740 736
741 @return the menu generated (QMenu) 737 @return the menu generated
738 @rtype QMenu
742 """ 739 """
743 menu = QMenu(self.tr('&Refactoring'), self.__ui) 740 menu = QMenu(self.tr('&Refactoring'), self.__ui)
744 menu.setTearOffEnabled(True) 741 menu.setTearOffEnabled(True)
745 742
746 act = menu.addAction('rope', self.__ropeInfo) 743 act = menu.addAction('rope', self.__ropeInfo)
882 Private method to get the offset into the text treating CRLF as ONE 879 Private method to get the offset into the text treating CRLF as ONE
883 character. 880 character.
884 881
885 Note: rope seems to convert all EOL styles to just \n. 882 Note: rope seems to convert all EOL styles to just \n.
886 883
887 @param editor reference to the editor (Editor) 884 @param editor reference to the editor
888 @param line line for the offset (integer) 885 @type QScintilla.Editor
889 @param index index into line for the offset (integer) 886 @param line line for the offset
890 @return rope compliant offset into the file (integer) 887 @type int
888 @param index index into line for the offset
889 @type int
890 @return rope compliant offset into the file
891 @rtype int
891 """ 892 """
892 source = editor.text() 893 source = editor.text()
893 offset = len("".join(source.splitlines(True)[:line])) + index 894 offset = len("".join(source.splitlines(True)[:line])) + index
894 if editor.eolMode() == QsciScintilla.EolWindows: 895 if editor.eolMode() == QsciScintilla.EolWindows:
895 offset -= line 896 offset -= line
909 """ 910 """
910 if self.handleRopeError(result): 911 if self.handleRopeError(result):
911 changeGroup = result["ChangeGroup"] 912 changeGroup = result["ChangeGroup"]
912 try: 913 try:
913 self.__refactoringDialogs[changeGroup]\ 914 self.__refactoringDialogs[changeGroup]\
914 .processChangeData(result) 915 .processChangeData(result)
915 except KeyError: 916 except KeyError:
916 # ignore data for non-existing dialogs 917 # ignore data for non-existing dialogs
917 pass 918 pass
918 919
919 def __refactoringDialogClosed(self, changeGroup): 920 def __refactoringDialogClosed(self, changeGroup):
955 956
956 def __doRename(self, title, isLocal=False, renameModule=False): 957 def __doRename(self, title, isLocal=False, renameModule=False):
957 """ 958 """
958 Private method to perform the various renaming refactorings. 959 Private method to perform the various renaming refactorings.
959 960
960 @param title title of the refactoring (string) 961 @param title title of the refactoring
962 @type str
961 @param isLocal flag indicating to restrict refactoring to 963 @param isLocal flag indicating to restrict refactoring to
962 the local file (boolean) 964 the local file
965 @type bool
963 @param renameModule flag indicating a module rename refactoring 966 @param renameModule flag indicating a module rename refactoring
964 (boolean) 967 @type bool
965 """ 968 """
966 aw = e5App().getObject("ViewManager").activeWindow() 969 aw = e5App().getObject("ViewManager").activeWindow()
967 970
968 if aw is None: 971 if aw is None:
969 return 972 return
999 index = int(index + (index1 - index) / 2) 1002 index = int(index + (index1 - index) / 2)
1000 # keep it inside the object 1003 # keep it inside the object
1001 offset = self.__getOffset(aw, line, index) 1004 offset = self.__getOffset(aw, line, index)
1002 selectedText = aw.selectedText() 1005 selectedText = aw.selectedText()
1003 1006
1004 from RenameDialog import RenameDialog 1007 from .RenameDialog import RenameDialog
1005 dlg = RenameDialog(self, title, filename, offset, isLocal, 1008 dlg = RenameDialog(self, title, filename, offset, isLocal,
1006 selectedText=selectedText, parent=self.__ui) 1009 selectedText=selectedText, parent=self.__ui)
1007 changeGroup = dlg.getChangeGroupName() 1010 changeGroup = dlg.getChangeGroupName()
1008 self.__refactoringDialogs[changeGroup] = dlg 1011 self.__refactoringDialogs[changeGroup] = dlg
1009 dlg.finished.connect( 1012 dlg.finished.connect(
1033 1036
1034 filename = aw.getFileName() 1037 filename = aw.getFileName()
1035 line, index, line1, index1 = aw.getSelection() 1038 line, index, line1, index1 = aw.getSelection()
1036 offset = self.__getOffset(aw, line, index) 1039 offset = self.__getOffset(aw, line, index)
1037 1040
1038 from ChangeOccurrencesDialog import ChangeOccurrencesDialog 1041 from .ChangeOccurrencesDialog import ChangeOccurrencesDialog
1039 dlg = ChangeOccurrencesDialog(self, title, filename, offset, 1042 dlg = ChangeOccurrencesDialog(self, title, filename, offset,
1040 parent=self.__ui) 1043 parent=self.__ui)
1041 changeGroup = dlg.getChangeGroupName() 1044 changeGroup = dlg.getChangeGroupName()
1042 self.__refactoringDialogs[changeGroup] = dlg 1045 self.__refactoringDialogs[changeGroup] = dlg
1043 dlg.finished.connect( 1046 dlg.finished.connect(
1090 filename = aw.getFileName() 1093 filename = aw.getFileName()
1091 startline, startcolumn, endline, endcolumn = aw.getSelection() 1094 startline, startcolumn, endline, endcolumn = aw.getSelection()
1092 startOffset = self.__getOffset(aw, startline, startcolumn) 1095 startOffset = self.__getOffset(aw, startline, startcolumn)
1093 endOffset = self.__getOffset(aw, endline, endcolumn) 1096 endOffset = self.__getOffset(aw, endline, endcolumn)
1094 1097
1095 from ExtractDialog import ExtractDialog 1098 from .ExtractDialog import ExtractDialog
1096 dlg = ExtractDialog(self, title, filename, startOffset, endOffset, 1099 dlg = ExtractDialog(self, title, filename, startOffset, endOffset,
1097 kind, parent=self.__ui) 1100 kind, parent=self.__ui)
1098 changeGroup = dlg.getChangeGroupName() 1101 changeGroup = dlg.getChangeGroupName()
1099 self.__refactoringDialogs[changeGroup] = dlg 1102 self.__refactoringDialogs[changeGroup] = dlg
1100 dlg.finished.connect( 1103 dlg.finished.connect(
1128 1131
1129 filename = aw.getFileName() 1132 filename = aw.getFileName()
1130 line, index, line1, index1 = aw.getSelection() 1133 line, index, line1, index1 = aw.getSelection()
1131 offset = self.__getOffset(aw, line, index) 1134 offset = self.__getOffset(aw, line, index)
1132 1135
1133 from InlineDialog import InlineDialog 1136 from .InlineDialog import InlineDialog
1134 dlg = InlineDialog(self, title, filename, offset, parent=self.__ui) 1137 dlg = InlineDialog(self, title, filename, offset, parent=self.__ui)
1135 changeGroup = dlg.getChangeGroupName() 1138 changeGroup = dlg.getChangeGroupName()
1136 self.__refactoringDialogs[changeGroup] = dlg 1139 self.__refactoringDialogs[changeGroup] = dlg
1137 dlg.finished.connect( 1140 dlg.finished.connect(
1138 lambda: self.__refactoringDialogClosed(changeGroup)) 1141 lambda: self.__refactoringDialogClosed(changeGroup))
1174 line, index, line1, index1 = aw.getSelection() 1177 line, index, line1, index1 = aw.getSelection()
1175 offset = self.__getOffset(aw, line, index) 1178 offset = self.__getOffset(aw, line, index)
1176 else: 1179 else:
1177 offset = None 1180 offset = None
1178 1181
1179 from MoveDialog import MoveDialog 1182 from .MoveDialog import MoveDialog
1180 dlg = MoveDialog(self, title, filename, offset, parent=self.__ui) 1183 dlg = MoveDialog(self, title, filename, offset, parent=self.__ui)
1181 changeGroup = dlg.getChangeGroupName() 1184 changeGroup = dlg.getChangeGroupName()
1182 self.__refactoringDialogs[changeGroup] = dlg 1185 self.__refactoringDialogs[changeGroup] = dlg
1183 dlg.finished.connect( 1186 dlg.finished.connect(
1184 lambda: self.__refactoringDialogClosed(changeGroup)) 1187 lambda: self.__refactoringDialogClosed(changeGroup))
1210 1213
1211 filename = aw.getFileName() 1214 filename = aw.getFileName()
1212 line, index, line1, index1 = aw.getSelection() 1215 line, index, line1, index1 = aw.getSelection()
1213 offset = self.__getOffset(aw, line, index) 1216 offset = self.__getOffset(aw, line, index)
1214 1217
1215 from UseFunctionDialog import UseFunctionDialog 1218 from .UseFunctionDialog import UseFunctionDialog
1216 dlg = UseFunctionDialog(self, title, filename, offset, 1219 dlg = UseFunctionDialog(self, title, filename, offset,
1217 parent=self.__ui) 1220 parent=self.__ui)
1218 changeGroup = dlg.getChangeGroupName() 1221 changeGroup = dlg.getChangeGroupName()
1219 self.__refactoringDialogs[changeGroup] = dlg 1222 self.__refactoringDialogs[changeGroup] = dlg
1220 dlg.finished.connect( 1223 dlg.finished.connect(
1248 1251
1249 filename = aw.getFileName() 1252 filename = aw.getFileName()
1250 line, index, line1, index1 = aw.getSelection() 1253 line, index, line1, index1 = aw.getSelection()
1251 offset = self.__getOffset(aw, line, index) 1254 offset = self.__getOffset(aw, line, index)
1252 1255
1253 from IntroduceFactoryDialog import IntroduceFactoryDialog 1256 from .IntroduceFactoryDialog import IntroduceFactoryDialog
1254 dlg = IntroduceFactoryDialog(self, title, filename, offset, 1257 dlg = IntroduceFactoryDialog(self, title, filename, offset,
1255 parent=self.__ui) 1258 parent=self.__ui)
1256 changeGroup = dlg.getChangeGroupName() 1259 changeGroup = dlg.getChangeGroupName()
1257 self.__refactoringDialogs[changeGroup] = dlg 1260 self.__refactoringDialogs[changeGroup] = dlg
1258 dlg.finished.connect( 1261 dlg.finished.connect(
1282 1285
1283 filename = aw.getFileName() 1286 filename = aw.getFileName()
1284 line, index, line1, index1 = aw.getSelection() 1287 line, index, line1, index1 = aw.getSelection()
1285 offset = self.__getOffset(aw, line, index) 1288 offset = self.__getOffset(aw, line, index)
1286 1289
1287 from IntroduceParameterDialog import IntroduceParameterDialog 1290 from .IntroduceParameterDialog import IntroduceParameterDialog
1288 dlg = IntroduceParameterDialog(self, title, filename, offset, 1291 dlg = IntroduceParameterDialog(self, title, filename, offset,
1289 parent=self.__ui) 1292 parent=self.__ui)
1290 changeGroup = dlg.getChangeGroupName() 1293 changeGroup = dlg.getChangeGroupName()
1291 self.__refactoringDialogs[changeGroup] = dlg 1294 self.__refactoringDialogs[changeGroup] = dlg
1292 dlg.finished.connect( 1295 dlg.finished.connect(
1359 line, index, line1, index1 = aw.getSelection() 1362 line, index, line1, index1 = aw.getSelection()
1360 offset = self.__getOffset(aw, line, index) 1363 offset = self.__getOffset(aw, line, index)
1361 else: 1364 else:
1362 offset = None 1365 offset = None
1363 1366
1364 from ConfirmationDialog import ConfirmationDialog 1367 from .ConfirmationDialog import ConfirmationDialog
1365 dlg = ConfirmationDialog( 1368 dlg = ConfirmationDialog(
1366 self, title, "Imports", "CalculateImportsChanges", { 1369 self, title, "Imports", "CalculateImportsChanges", {
1367 "MethodName": methodName, 1370 "MethodName": methodName,
1368 "FileName": filename, 1371 "FileName": filename,
1369 "Offset": offset, 1372 "Offset": offset,
1381 1384
1382 def __restructure(self): 1385 def __restructure(self):
1383 """ 1386 """
1384 Private slot to restructure code. 1387 Private slot to restructure code.
1385 """ 1388 """
1386 from RestructureDialog import RestructureDialog 1389 from .RestructureDialog import RestructureDialog
1387 title = self.tr("Restructure") 1390 title = self.tr("Restructure")
1388 dlg = RestructureDialog(self, title, parent=self.__ui) 1391 dlg = RestructureDialog(self, title, parent=self.__ui)
1389 changeGroup = dlg.getChangeGroupName() 1392 changeGroup = dlg.getChangeGroupName()
1390 self.__refactoringDialogs[changeGroup] = dlg 1393 self.__refactoringDialogs[changeGroup] = dlg
1391 dlg.finished.connect( 1394 dlg.finished.connect(
1415 1418
1416 filename = aw.getFileName() 1419 filename = aw.getFileName()
1417 line, index, line1, index1 = aw.getSelection() 1420 line, index, line1, index1 = aw.getSelection()
1418 offset = self.__getOffset(aw, line, index) 1421 offset = self.__getOffset(aw, line, index)
1419 1422
1420 from ChangeSignatureDialog import ChangeSignatureDialog 1423 from .ChangeSignatureDialog import ChangeSignatureDialog
1421 dlg = ChangeSignatureDialog(self, title, filename, offset, 1424 dlg = ChangeSignatureDialog(self, title, filename, offset,
1422 parent=self.__ui) 1425 parent=self.__ui)
1423 changeGroup = dlg.getChangeGroupName() 1426 changeGroup = dlg.getChangeGroupName()
1424 self.__refactoringDialogs[changeGroup] = dlg 1427 self.__refactoringDialogs[changeGroup] = dlg
1425 dlg.finished.connect( 1428 dlg.finished.connect(
1450 1453
1451 filename = aw.getFileName() 1454 filename = aw.getFileName()
1452 line, index, line1, index1 = aw.getSelection() 1455 line, index, line1, index1 = aw.getSelection()
1453 offset = self.__getOffset(aw, line, index) 1456 offset = self.__getOffset(aw, line, index)
1454 1457
1455 from InlineArgumentDefaultDialog import InlineArgumentDefaultDialog 1458 from .InlineArgumentDefaultDialog import InlineArgumentDefaultDialog
1456 dlg = InlineArgumentDefaultDialog(self, title, filename, offset, 1459 dlg = InlineArgumentDefaultDialog(self, title, filename, offset,
1457 parent=self.__ui) 1460 parent=self.__ui)
1458 changeGroup = dlg.getChangeGroupName() 1461 changeGroup = dlg.getChangeGroupName()
1459 self.__refactoringDialogs[changeGroup] = dlg 1462 self.__refactoringDialogs[changeGroup] = dlg
1460 dlg.finished.connect( 1463 dlg.finished.connect(
1475 if not self.confirmAllBuffersSaved(): 1478 if not self.confirmAllBuffersSaved():
1476 return 1479 return
1477 1480
1478 filename = aw.getFileName() 1481 filename = aw.getFileName()
1479 1482
1480 from ConfirmationDialog import ConfirmationDialog 1483 from .ConfirmationDialog import ConfirmationDialog
1481 dlg = ConfirmationDialog( 1484 dlg = ConfirmationDialog(
1482 self, title, "ModuleToPackage", "CalculateModuleToPackageChanges", 1485 self, title, "ModuleToPackage", "CalculateModuleToPackageChanges",
1483 { 1486 {
1484 "FileName": filename, 1487 "FileName": filename,
1485 }, 1488 },
1513 1516
1514 filename = aw.getFileName() 1517 filename = aw.getFileName()
1515 line, index, line1, index1 = aw.getSelection() 1518 line, index, line1, index1 = aw.getSelection()
1516 offset = self.__getOffset(aw, line, index) 1519 offset = self.__getOffset(aw, line, index)
1517 1520
1518 from GetterSetterDialog import GetterSetterDialog 1521 from .GetterSetterDialog import GetterSetterDialog
1519 dlg = GetterSetterDialog(self, title, filename, offset, 1522 dlg = GetterSetterDialog(self, title, filename, offset,
1520 parent=self.__ui) 1523 parent=self.__ui)
1521 changeGroup = dlg.getChangeGroupName() 1524 changeGroup = dlg.getChangeGroupName()
1522 self.__refactoringDialogs[changeGroup] = dlg 1525 self.__refactoringDialogs[changeGroup] = dlg
1523 dlg.finished.connect( 1526 dlg.finished.connect(
1547 1550
1548 filename = aw.getFileName() 1551 filename = aw.getFileName()
1549 line, index, line1, index1 = aw.getSelection() 1552 line, index, line1, index1 = aw.getSelection()
1550 offset = self.__getOffset(aw, line, index) 1553 offset = self.__getOffset(aw, line, index)
1551 1554
1552 from ConfirmationDialog import ConfirmationDialog 1555 from .ConfirmationDialog import ConfirmationDialog
1553 dlg = ConfirmationDialog( 1556 dlg = ConfirmationDialog(
1554 self, title, "LocalToAttribute", 1557 self, title, "LocalToAttribute",
1555 "CalculateLocalToAttributeChanges", { 1558 "CalculateLocalToAttributeChanges", {
1556 "FileName": filename, 1559 "FileName": filename,
1557 "Offset": offset, 1560 "Offset": offset,
1586 1589
1587 filename = aw.getFileName() 1590 filename = aw.getFileName()
1588 line, index, line1, index1 = aw.getSelection() 1591 line, index, line1, index1 = aw.getSelection()
1589 offset = self.__getOffset(aw, line, index) 1592 offset = self.__getOffset(aw, line, index)
1590 1593
1591 from MethodToMethodObjectDialog import MethodToMethodObjectDialog 1594 from .MethodToMethodObjectDialog import MethodToMethodObjectDialog
1592 dlg = MethodToMethodObjectDialog(self, title, filename, offset, 1595 dlg = MethodToMethodObjectDialog(self, title, filename, offset,
1593 parent=self.__ui) 1596 parent=self.__ui)
1594 changeGroup = dlg.getChangeGroupName() 1597 changeGroup = dlg.getChangeGroupName()
1595 self.__refactoringDialogs[changeGroup] = dlg 1598 self.__refactoringDialogs[changeGroup] = dlg
1596 dlg.finished.connect( 1599 dlg.finished.connect(
1606 Private method to show the project refactoring history. 1609 Private method to show the project refactoring history.
1607 """ 1610 """
1608 if self.__historyDialog is not None: 1611 if self.__historyDialog is not None:
1609 self.__historyDialog.close() 1612 self.__historyDialog.close()
1610 1613
1611 from HistoryDialog import HistoryDialog 1614 from .HistoryDialog import HistoryDialog
1612 self.__historyDialog = HistoryDialog(self, parent=self.__ui) 1615 self.__historyDialog = HistoryDialog(self, parent=self.__ui)
1613 self.__historyDialog.finished.connect(self.__historyDialogClosed) 1616 self.__historyDialog.finished.connect(self.__historyDialogClosed)
1614 self.__historyDialog.show() 1617 self.__historyDialog.show()
1615 1618
1616 def __showFileHistory(self): 1619 def __showFileHistory(self):
1623 return 1626 return
1624 1627
1625 if self.__historyDialog is not None: 1628 if self.__historyDialog is not None:
1626 self.__historyDialog.close() 1629 self.__historyDialog.close()
1627 1630
1628 from HistoryDialog import HistoryDialog 1631 from .HistoryDialog import HistoryDialog
1629 filename = aw.getFileName() 1632 filename = aw.getFileName()
1630 if filename: 1633 if filename:
1631 self.__historyDialog = HistoryDialog( 1634 self.__historyDialog = HistoryDialog(
1632 self, filename=filename, parent=self.__ui) 1635 self, filename=filename, parent=self.__ui)
1633 self.__historyDialog.show() 1636 self.__historyDialog.show()
1702 @type dict 1705 @type dict
1703 """ 1706 """
1704 if self.handleRopeError(result): 1707 if self.handleRopeError(result):
1705 title = result["Title"] 1708 title = result["Title"]
1706 if result["EntriesCount"] > 0: 1709 if result["EntriesCount"] > 0:
1707 from MatchesDialog import MatchesDialog 1710 from .MatchesDialog import MatchesDialog
1708 self.dlg = MatchesDialog(self.__ui, True) 1711 self.dlg = MatchesDialog(self.__ui, True)
1709 self.dlg.show() 1712 self.dlg.show()
1710 for occurrence in result["Entries"]: 1713 for occurrence in result["Entries"]:
1711 self.dlg.addEntry( 1714 self.dlg.addEntry(
1712 # file name, lineno, unsure 1715 # file name, lineno, unsure
1747 Public slot to find the definition for the word at the cursor position 1750 Public slot to find the definition for the word at the cursor position
1748 and go to it. 1751 and go to it.
1749 1752
1750 Note: This is executed upon a mouse click sequence. 1753 Note: This is executed upon a mouse click sequence.
1751 1754
1752 @param editor reference to the calling editor (Editor) 1755 @param editor reference to the calling editor
1756 @type QScintilla.Editor
1753 """ 1757 """
1754 filename = editor.getFileName() 1758 filename = editor.getFileName()
1755 line, index = editor.getCursorPosition() 1759 line, index = editor.getCursorPosition()
1756 offset = self.__getOffset(editor, line, index) 1760 offset = self.__getOffset(editor, line, index)
1757 1761
1775 if self.handleRopeError(result): 1779 if self.handleRopeError(result):
1776 title = result["Title"] 1780 title = result["Title"]
1777 if "Location" in result: 1781 if "Location" in result:
1778 location = result["Location"] 1782 location = result["Location"]
1779 1783
1780 from MatchesDialog import MatchesDialog 1784 from .MatchesDialog import MatchesDialog
1781 self.dlg = MatchesDialog(self.__ui, False) 1785 self.dlg = MatchesDialog(self.__ui, False)
1782 self.dlg.show() 1786 self.dlg.show()
1783 self.dlg.addEntry(location[0], location[1]) 1787 self.dlg.addEntry(location[0], location[1])
1784 # file name, lineno 1788 # file name, lineno
1785 else: 1789 else:
1835 @type dict 1839 @type dict
1836 """ 1840 """
1837 if self.handleRopeError(result): 1841 if self.handleRopeError(result):
1838 title = result["Title"] 1842 title = result["Title"]
1839 if result["EntriesCount"] > 0: 1843 if result["EntriesCount"] > 0:
1840 from MatchesDialog import MatchesDialog 1844 from .MatchesDialog import MatchesDialog
1841 self.dlg = MatchesDialog(self.__ui, True) 1845 self.dlg = MatchesDialog(self.__ui, True)
1842 self.dlg.show() 1846 self.dlg.show()
1843 for occurrence in result["Entries"]: 1847 for occurrence in result["Entries"]:
1844 self.dlg.addEntry( 1848 self.dlg.addEntry(
1845 # file name, lineno, unsure 1849 # file name, lineno, unsure
1907 def __showRopeHelp(self): 1911 def __showRopeHelp(self):
1908 """ 1912 """
1909 Private slot to show help about the refactorings offered by Rope. 1913 Private slot to show help about the refactorings offered by Rope.
1910 """ 1914 """
1911 if self.__helpDialog is None: 1915 if self.__helpDialog is None:
1912 from HelpDialog import HelpDialog 1916 from .HelpDialog import HelpDialog
1913 self.__helpDialog = \ 1917 self.__helpDialog = \
1914 HelpDialog(self.tr("Help about rope refactorings"), 1918 HelpDialog(self.tr("Help about rope refactorings"),
1915 self.__ropeConfig["RopeHelpFile"]) 1919 self.__ropeConfig["RopeHelpFile"])
1916 self.__helpDialog.show() 1920 self.__helpDialog.show()
1917 1921
1993 1997
1994 def __ropeConfigFile(self): 1998 def __ropeConfigFile(self):
1995 """ 1999 """
1996 Private method to get the name of the rope configuration file. 2000 Private method to get the name of the rope configuration file.
1997 2001
1998 @return name of the rope configuration file (string) 2002 @return name of the rope configuration file
2003 @rtype str
1999 """ 2004 """
2000 configfile = None 2005 configfile = None
2001 if self.__ropeConfig: 2006 if self.__ropeConfig:
2002 ropedir = self.__ropeConfig["RopeFolderName"] 2007 ropedir = self.__ropeConfig["RopeFolderName"]
2003 if ropedir: 2008 if ropedir:
2015 def __defaultConfig(self): 2020 def __defaultConfig(self):
2016 """ 2021 """
2017 Private slot to return the contents of rope's default configuration. 2022 Private slot to return the contents of rope's default configuration.
2018 2023
2019 @return string containing the source of rope's default 2024 @return string containing the source of rope's default
2020 configuration (string) 2025 configuration
2026 @rtype str
2021 """ 2027 """
2022 if self.__ropeConfig and "DefaultConfig" in self.__ropeConfig: 2028 if self.__ropeConfig and "DefaultConfig" in self.__ropeConfig:
2023 return self.__ropeConfig["DefaultConfig"] 2029 return self.__ropeConfig["DefaultConfig"]
2024 else: 2030 else:
2025 return "" 2031 return ""
2030 2036
2031 def getActions(self): 2037 def getActions(self):
2032 """ 2038 """
2033 Public method to get a list of all actions. 2039 Public method to get a list of all actions.
2034 2040
2035 @return list of all actions (list of E5Action) 2041 @return list of all actions
2042 @rtype list of E5Action
2036 """ 2043 """
2037 return self.actions[:] 2044 return self.actions[:]
2038 2045
2039 def projectOpened(self): 2046 def projectOpened(self):
2040 """ 2047 """
2114 def confirmBufferIsSaved(self, editor): 2121 def confirmBufferIsSaved(self, editor):
2115 """ 2122 """
2116 Public method to check, if an editor has unsaved changes. 2123 Public method to check, if an editor has unsaved changes.
2117 2124
2118 @param editor reference to the editor to be checked 2125 @param editor reference to the editor to be checked
2126 @type QScintilla.Editor
2119 @return flag indicating, that the editor doesn't contain 2127 @return flag indicating, that the editor doesn't contain
2120 unsaved edits (boolean) 2128 unsaved edits
2129 @rtype bool
2121 """ 2130 """
2122 res = editor.checkDirty() 2131 res = editor.checkDirty()
2123 self.sendJson("Validate", {}) 2132 self.sendJson("Validate", {})
2124 return res 2133 return res
2125 2134
2126 def confirmAllBuffersSaved(self): 2135 def confirmAllBuffersSaved(self):
2127 """ 2136 """
2128 Public method to check, if any editor has unsaved changes. 2137 Public method to check, if any editor has unsaved changes.
2129 2138
2130 @return flag indicating, that no editor contains unsaved edits 2139 @return flag indicating, that no editor contains unsaved edits
2131 (boolean) 2140 @rtype bool
2132 """ 2141 """
2133 res = e5App().getObject("ViewManager").checkAllDirty() 2142 res = e5App().getObject("ViewManager").checkAllDirty()
2134 self.sendJson("Validate", {}) 2143 self.sendJson("Validate", {})
2135 return res 2144 return res
2136 2145

eric ide

mercurial