815 """ |
815 """ |
816 Private slot to check, if there are changes to be undone. |
816 Private slot to check, if there are changes to be undone. |
817 |
817 |
818 @return flag indicating, that undoable changes are available (boolean) |
818 @return flag indicating, that undoable changes are available (boolean) |
819 """ |
819 """ |
|
820 return False |
820 return self.__project is not None and \ |
821 return self.__project is not None and \ |
821 len(self.__project.history.undo_list) > 0 |
822 len(self.__project.history.undo_list) > 0 |
822 |
823 |
823 def __canRedo(self): |
824 def __canRedo(self): |
824 """ |
825 """ |
825 Private slot to check, if there are changes to be redone. |
826 Private slot to check, if there are changes to be redone. |
826 |
827 |
827 @return flag indicating, that redoable changes are available (boolean) |
828 @return flag indicating, that redoable changes are available (boolean) |
828 """ |
829 """ |
|
830 return False |
829 return self.__project is not None and \ |
831 return self.__project is not None and \ |
830 len(self.__project.history.redo_list) > 0 |
832 len(self.__project.history.redo_list) > 0 |
831 |
833 |
832 def __getFileUndoList(self, resource): |
834 def __getFileUndoList(self, resource): |
833 """ |
835 """ |
901 resource is not None and self.__canUndoFile(resource)) |
903 resource is not None and self.__canUndoFile(resource)) |
902 self.refactoringRedoHistoryAct.setEnabled(self.__canRedo()) |
904 self.refactoringRedoHistoryAct.setEnabled(self.__canRedo()) |
903 self.refactoringRedoFileHistoryAct.setEnabled( |
905 self.refactoringRedoFileHistoryAct.setEnabled( |
904 resource is not None and self.__canRedoFile(resource)) |
906 resource is not None and self.__canRedoFile(resource)) |
905 |
907 |
906 def handleRopeError(self, err, title, handle=None): |
908 def __handleRopeError(self, result): |
907 """ |
909 """ |
908 Public slot to handle a rope error. |
910 Private method to handle a rope error. |
909 |
911 |
910 @param err rope exception object (Exception) |
912 @param result dictionary containing the error information |
911 @param title title to be displayed (string) |
913 @type dict |
912 @param handle reference to a taskhandle (ProgressHandle) |
914 """ |
913 """ |
915 if result["Error"] == 'ModuleSyntaxError': |
914 if handle is not None: |
|
915 handle.reset() |
|
916 ropeError = str(type(err)).split()[-1] |
|
917 ropeError = ropeError[1:-2].split('.')[-1] |
|
918 if ropeError == 'ModuleSyntaxError': |
|
919 res = E5MessageBox.warning( |
916 res = E5MessageBox.warning( |
920 self.__ui, title, |
917 self.__ui, result["Title"], |
921 self.tr("Rope error: {0}").format(str(err)), |
918 self.tr("Rope error: {0}").format( |
|
919 result["ErrorString"]), |
922 E5MessageBox.Ok | E5MessageBox.Open) |
920 E5MessageBox.Ok | E5MessageBox.Open) |
923 if res == E5MessageBox.Open: |
921 if res == E5MessageBox.Open: |
924 e5App().getObject("ViewManager").openSourceFile( |
922 e5App().getObject("ViewManager").openSourceFile( |
925 os.path.join(self.__e5project.getProjectPath(), |
923 os.path.join(self.__e5project.getProjectPath(), |
926 err.filename), |
924 result["ErrorFile"]), |
927 err.lineno) |
925 result["ErrorLine"]) |
928 else: |
926 else: |
929 E5MessageBox.warning( |
927 E5MessageBox.warning( |
930 self.__ui, title, |
928 self.__ui, result["Title"], |
931 self.tr("Rope error: {0}").format(str(err))) |
929 self.tr("Rope error: {0}").format( |
|
930 result["ErrorString"]) |
|
931 ) |
932 |
932 |
933 def __getOffset(self, editor, line, index): |
933 def __getOffset(self, editor, line, index): |
934 r""" |
934 r""" |
935 Private method to get the offset into the text treating CRLF as ONE |
935 Private method to get the offset into the text treating CRLF as ONE |
936 character. |
936 character. |
1902 |
1902 |
1903 filename = aw.getFileName() |
1903 filename = aw.getFileName() |
1904 line, index = aw.getCursorPosition() |
1904 line, index = aw.getCursorPosition() |
1905 offset = self.__getOffset(aw, line, index) |
1905 offset = self.__getOffset(aw, line, index) |
1906 |
1906 |
1907 import rope.contrib.findit |
1907 self.sendJson("QueryReferences", { |
1908 from ProgressHandle import ProgressHandle |
1908 "Title": title, |
1909 resource = rope.base.libutils.path_to_resource( |
1909 "FileName": filename, |
1910 self.__project, filename) |
1910 "Offset": offset, |
1911 handle = ProgressHandle(title, True, self.__ui) |
1911 }) |
1912 handle.show() |
1912 |
1913 QApplication.processEvents() |
1913 def __queryReferencesResult(self, result): |
1914 try: |
1914 """ |
1915 occurrences = rope.contrib.findit.find_occurrences( |
1915 Private method to handle the "Query References" result sent by |
1916 self.__project, resource, offset, |
1916 the client. |
1917 unsure=True, in_hierarchy=True, task_handle=handle) |
1917 |
1918 except Exception as err: |
1918 @param result dictionary containing the result data |
1919 self.handleRopeError(err, title, handle) |
1919 @type dict |
1920 return |
1920 """ |
1921 handle.reset() |
1921 if "Error" in result: |
1922 |
1922 self.__handleRopeError(result) |
1923 if occurrences: |
|
1924 from MatchesDialog import MatchesDialog |
|
1925 self.dlg = MatchesDialog(self.__ui, True) |
|
1926 self.dlg.show() |
|
1927 for occurrence in occurrences: |
|
1928 self.dlg.addEntry( |
|
1929 occurrence.resource, occurrence.lineno, occurrence.unsure) |
|
1930 else: |
1923 else: |
1931 E5MessageBox.warning( |
1924 title = result["Title"] |
1932 self.__ui, title, |
1925 if result["EntriesCount"] > 0: |
1933 self.tr("No occurrences found.")) |
1926 from MatchesDialog import MatchesDialog |
|
1927 self.dlg = MatchesDialog(self.__ui, True) |
|
1928 self.dlg.show() |
|
1929 for occurrence in result["Entries"]: |
|
1930 self.dlg.addEntry( |
|
1931 # resource, lineno, unsure |
|
1932 occurrence[0], occurrence[1], occurrence[2]) |
|
1933 else: |
|
1934 E5MessageBox.warning( |
|
1935 self.__ui, title, |
|
1936 self.tr("No occurrences found.")) |
1934 |
1937 |
1935 def __queryDefinition(self): |
1938 def __queryDefinition(self): |
1936 """ |
1939 """ |
1937 Private slot to handle the Find Definition action. |
1940 Private slot to handle the Find Definition action. |
1938 """ |
1941 """ |
2249 self.__projectopen = False |
2252 self.__projectopen = False |
2250 self.__projectpath = '' |
2253 self.__projectpath = '' |
2251 self.__projectLanguage = "" |
2254 self.__projectLanguage = "" |
2252 |
2255 |
2253 # TODO: delete this or move to client |
2256 # TODO: delete this or move to client |
2254 def getProject(self): |
2257 ## def getProject(self): |
2255 """ |
2258 ## """ |
2256 Public method to get a reference to the rope project object. |
2259 ## Public method to get a reference to the rope project object. |
2257 |
2260 ## |
2258 @return reference to the rope project object (RopeProject) |
2261 ## @return reference to the rope project object (RopeProject) |
2259 """ |
2262 ## """ |
2260 return self.__project |
2263 ## return self.__project |
2261 |
2264 ## |
2262 def confirmBufferIsSaved(self, editor): |
2265 def confirmBufferIsSaved(self, editor): |
2263 """ |
2266 """ |
2264 Public method to check, if an editor has unsaved changes. |
2267 Public method to check, if an editor has unsaved changes. |
2265 |
2268 |
2266 @param editor reference to the editor to be checked |
2269 @param editor reference to the editor to be checked |
2267 @return flag indicating, that the editor doesn't contain |
2270 @return flag indicating, that the editor doesn't contain |
2268 unsaved edits (boolean) |
2271 unsaved edits (boolean) |
2269 """ |
2272 """ |
2270 res = editor.checkDirty() |
2273 res = editor.checkDirty() |
2271 self.__project.validate(self.__project.root) |
2274 self.sendJson("Validate", {}) |
2272 return res |
2275 return res |
2273 |
2276 |
2274 def confirmAllBuffersSaved(self): |
2277 def confirmAllBuffersSaved(self): |
2275 """ |
2278 """ |
2276 Public method to check, if any editor has unsaved changes. |
2279 Public method to check, if any editor has unsaved changes. |
2277 |
2280 |
2278 @return flag indicating, that no editor contains unsaved edits |
2281 @return flag indicating, that no editor contains unsaved edits |
2279 (boolean) |
2282 (boolean) |
2280 """ |
2283 """ |
2281 res = e5App().getObject("ViewManager").checkAllDirty() |
2284 res = e5App().getObject("ViewManager").checkAllDirty() |
2282 self.__project.validate(self.__project.root) |
2285 self.sendJson("Validate", {}) |
2283 return res |
2286 return res |
2284 |
2287 |
2285 def refreshEditors(self, changes): |
2288 def refreshEditors(self, changes): |
2286 """ |
2289 """ |
2287 Public method to refresh modified editors. |
2290 Public method to refresh modified editors. |
2393 self.__progressDialog.updateProgress(params) |
2396 self.__progressDialog.updateProgress(params) |
2394 |
2397 |
2395 elif method == "ProgressReset": |
2398 elif method == "ProgressReset": |
2396 if self.__progressDialog is not None: |
2399 if self.__progressDialog is not None: |
2397 self.__progressDialog.reset() |
2400 self.__progressDialog.reset() |
|
2401 |
|
2402 elif method == "QueryReferencesResult": |
|
2403 self.__queryReferencesResult(params) |
2398 |
2404 |
2399 def __startRefactoringClient(self, interpreter): |
2405 def __startRefactoringClient(self, interpreter): |
2400 """ |
2406 """ |
2401 Private method to start the refactoring client. |
2407 Private method to start the refactoring client. |
2402 |
2408 |