--- a/RefactoringRope/RefactoringServer.py Wed Sep 27 19:50:44 2017 +0200 +++ b/RefactoringRope/RefactoringServer.py Fri Sep 29 10:23:35 2017 +0200 @@ -14,10 +14,6 @@ pass import os -import sys - -# TODO: eliminate this -sys.path.insert(0, os.path.dirname(__file__)) from PyQt5.QtCore import pyqtSlot from PyQt5.QtWidgets import QMenu, QApplication, QAction @@ -27,8 +23,8 @@ from E5Gui import E5MessageBox from E5Gui.E5Action import E5Action -from JsonServer import JsonServer -from RopeProgressDialog import RopeProgressDialog +from .JsonServer import JsonServer +from .RopeProgressDialog import RopeProgressDialog import Utilities import Preferences @@ -68,7 +64,7 @@ self.__historyDialog = None self.__refactoringDialogs = {} - from FileSystemCommands import E5FileSystemCommands + from .FileSystemCommands import E5FileSystemCommands self.__fsCommands = E5FileSystemCommands(self.__e5project) self.__methodMapping = { @@ -738,7 +734,8 @@ """ Private slot to initialize the refactoring menu. - @return the menu generated (QMenu) + @return the menu generated + @rtype QMenu """ menu = QMenu(self.tr('&Refactoring'), self.__ui) menu.setTearOffEnabled(True) @@ -884,10 +881,14 @@ Note: rope seems to convert all EOL styles to just \n. - @param editor reference to the editor (Editor) - @param line line for the offset (integer) - @param index index into line for the offset (integer) - @return rope compliant offset into the file (integer) + @param editor reference to the editor + @type QScintilla.Editor + @param line line for the offset + @type int + @param index index into line for the offset + @type int + @return rope compliant offset into the file + @rtype int """ source = editor.text() offset = len("".join(source.splitlines(True)[:line])) + index @@ -911,7 +912,7 @@ changeGroup = result["ChangeGroup"] try: self.__refactoringDialogs[changeGroup]\ - .processChangeData(result) + .processChangeData(result) except KeyError: # ignore data for non-existing dialogs pass @@ -957,11 +958,13 @@ """ Private method to perform the various renaming refactorings. - @param title title of the refactoring (string) + @param title title of the refactoring + @type str @param isLocal flag indicating to restrict refactoring to - the local file (boolean) + the local file + @type bool @param renameModule flag indicating a module rename refactoring - (boolean) + @type bool """ aw = e5App().getObject("ViewManager").activeWindow() @@ -1001,7 +1004,7 @@ offset = self.__getOffset(aw, line, index) selectedText = aw.selectedText() - from RenameDialog import RenameDialog + from .RenameDialog import RenameDialog dlg = RenameDialog(self, title, filename, offset, isLocal, selectedText=selectedText, parent=self.__ui) changeGroup = dlg.getChangeGroupName() @@ -1035,7 +1038,7 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) - from ChangeOccurrencesDialog import ChangeOccurrencesDialog + from .ChangeOccurrencesDialog import ChangeOccurrencesDialog dlg = ChangeOccurrencesDialog(self, title, filename, offset, parent=self.__ui) changeGroup = dlg.getChangeGroupName() @@ -1092,7 +1095,7 @@ startOffset = self.__getOffset(aw, startline, startcolumn) endOffset = self.__getOffset(aw, endline, endcolumn) - from ExtractDialog import ExtractDialog + from .ExtractDialog import ExtractDialog dlg = ExtractDialog(self, title, filename, startOffset, endOffset, kind, parent=self.__ui) changeGroup = dlg.getChangeGroupName() @@ -1130,7 +1133,7 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) - from InlineDialog import InlineDialog + from .InlineDialog import InlineDialog dlg = InlineDialog(self, title, filename, offset, parent=self.__ui) changeGroup = dlg.getChangeGroupName() self.__refactoringDialogs[changeGroup] = dlg @@ -1176,7 +1179,7 @@ else: offset = None - from MoveDialog import MoveDialog + from .MoveDialog import MoveDialog dlg = MoveDialog(self, title, filename, offset, parent=self.__ui) changeGroup = dlg.getChangeGroupName() self.__refactoringDialogs[changeGroup] = dlg @@ -1212,7 +1215,7 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) - from UseFunctionDialog import UseFunctionDialog + from .UseFunctionDialog import UseFunctionDialog dlg = UseFunctionDialog(self, title, filename, offset, parent=self.__ui) changeGroup = dlg.getChangeGroupName() @@ -1250,7 +1253,7 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) - from IntroduceFactoryDialog import IntroduceFactoryDialog + from .IntroduceFactoryDialog import IntroduceFactoryDialog dlg = IntroduceFactoryDialog(self, title, filename, offset, parent=self.__ui) changeGroup = dlg.getChangeGroupName() @@ -1284,7 +1287,7 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) - from IntroduceParameterDialog import IntroduceParameterDialog + from .IntroduceParameterDialog import IntroduceParameterDialog dlg = IntroduceParameterDialog(self, title, filename, offset, parent=self.__ui) changeGroup = dlg.getChangeGroupName() @@ -1361,7 +1364,7 @@ else: offset = None - from ConfirmationDialog import ConfirmationDialog + from .ConfirmationDialog import ConfirmationDialog dlg = ConfirmationDialog( self, title, "Imports", "CalculateImportsChanges", { "MethodName": methodName, @@ -1383,7 +1386,7 @@ """ Private slot to restructure code. """ - from RestructureDialog import RestructureDialog + from .RestructureDialog import RestructureDialog title = self.tr("Restructure") dlg = RestructureDialog(self, title, parent=self.__ui) changeGroup = dlg.getChangeGroupName() @@ -1417,7 +1420,7 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) - from ChangeSignatureDialog import ChangeSignatureDialog + from .ChangeSignatureDialog import ChangeSignatureDialog dlg = ChangeSignatureDialog(self, title, filename, offset, parent=self.__ui) changeGroup = dlg.getChangeGroupName() @@ -1452,7 +1455,7 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) - from InlineArgumentDefaultDialog import InlineArgumentDefaultDialog + from .InlineArgumentDefaultDialog import InlineArgumentDefaultDialog dlg = InlineArgumentDefaultDialog(self, title, filename, offset, parent=self.__ui) changeGroup = dlg.getChangeGroupName() @@ -1477,7 +1480,7 @@ filename = aw.getFileName() - from ConfirmationDialog import ConfirmationDialog + from .ConfirmationDialog import ConfirmationDialog dlg = ConfirmationDialog( self, title, "ModuleToPackage", "CalculateModuleToPackageChanges", { @@ -1515,7 +1518,7 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) - from GetterSetterDialog import GetterSetterDialog + from .GetterSetterDialog import GetterSetterDialog dlg = GetterSetterDialog(self, title, filename, offset, parent=self.__ui) changeGroup = dlg.getChangeGroupName() @@ -1549,7 +1552,7 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) - from ConfirmationDialog import ConfirmationDialog + from .ConfirmationDialog import ConfirmationDialog dlg = ConfirmationDialog( self, title, "LocalToAttribute", "CalculateLocalToAttributeChanges", { @@ -1588,7 +1591,7 @@ line, index, line1, index1 = aw.getSelection() offset = self.__getOffset(aw, line, index) - from MethodToMethodObjectDialog import MethodToMethodObjectDialog + from .MethodToMethodObjectDialog import MethodToMethodObjectDialog dlg = MethodToMethodObjectDialog(self, title, filename, offset, parent=self.__ui) changeGroup = dlg.getChangeGroupName() @@ -1608,7 +1611,7 @@ if self.__historyDialog is not None: self.__historyDialog.close() - from HistoryDialog import HistoryDialog + from .HistoryDialog import HistoryDialog self.__historyDialog = HistoryDialog(self, parent=self.__ui) self.__historyDialog.finished.connect(self.__historyDialogClosed) self.__historyDialog.show() @@ -1625,7 +1628,7 @@ if self.__historyDialog is not None: self.__historyDialog.close() - from HistoryDialog import HistoryDialog + from .HistoryDialog import HistoryDialog filename = aw.getFileName() if filename: self.__historyDialog = HistoryDialog( @@ -1704,7 +1707,7 @@ if self.handleRopeError(result): title = result["Title"] if result["EntriesCount"] > 0: - from MatchesDialog import MatchesDialog + from .MatchesDialog import MatchesDialog self.dlg = MatchesDialog(self.__ui, True) self.dlg.show() for occurrence in result["Entries"]: @@ -1749,7 +1752,8 @@ Note: This is executed upon a mouse click sequence. - @param editor reference to the calling editor (Editor) + @param editor reference to the calling editor + @type QScintilla.Editor """ filename = editor.getFileName() line, index = editor.getCursorPosition() @@ -1777,7 +1781,7 @@ if "Location" in result: location = result["Location"] - from MatchesDialog import MatchesDialog + from .MatchesDialog import MatchesDialog self.dlg = MatchesDialog(self.__ui, False) self.dlg.show() self.dlg.addEntry(location[0], location[1]) @@ -1837,7 +1841,7 @@ if self.handleRopeError(result): title = result["Title"] if result["EntriesCount"] > 0: - from MatchesDialog import MatchesDialog + from .MatchesDialog import MatchesDialog self.dlg = MatchesDialog(self.__ui, True) self.dlg.show() for occurrence in result["Entries"]: @@ -1909,7 +1913,7 @@ Private slot to show help about the refactorings offered by Rope. """ if self.__helpDialog is None: - from HelpDialog import HelpDialog + from .HelpDialog import HelpDialog self.__helpDialog = \ HelpDialog(self.tr("Help about rope refactorings"), self.__ropeConfig["RopeHelpFile"]) @@ -1995,7 +1999,8 @@ """ Private method to get the name of the rope configuration file. - @return name of the rope configuration file (string) + @return name of the rope configuration file + @rtype str """ configfile = None if self.__ropeConfig: @@ -2017,7 +2022,8 @@ Private slot to return the contents of rope's default configuration. @return string containing the source of rope's default - configuration (string) + configuration + @rtype str """ if self.__ropeConfig and "DefaultConfig" in self.__ropeConfig: return self.__ropeConfig["DefaultConfig"] @@ -2032,7 +2038,8 @@ """ Public method to get a list of all actions. - @return list of all actions (list of E5Action) + @return list of all actions + @rtype list of E5Action """ return self.actions[:] @@ -2116,8 +2123,10 @@ Public method to check, if an editor has unsaved changes. @param editor reference to the editor to be checked + @type QScintilla.Editor @return flag indicating, that the editor doesn't contain - unsaved edits (boolean) + unsaved edits + @rtype bool """ res = editor.checkDirty() self.sendJson("Validate", {}) @@ -2128,7 +2137,7 @@ Public method to check, if any editor has unsaved changes. @return flag indicating, that no editor contains unsaved edits - (boolean) + @rtype bool """ res = e5App().getObject("ViewManager").checkAllDirty() self.sendJson("Validate", {})