170 @return tuple of None and activation status (boolean) |
170 @return tuple of None and activation status (boolean) |
171 """ |
171 """ |
172 global refactoringRopePluginObject |
172 global refactoringRopePluginObject |
173 refactoringRopePluginObject = self |
173 refactoringRopePluginObject = self |
174 |
174 |
175 from RefactoringRope.CodeAssist import CodeAssist |
175 from RefactoringRope.CodeAssistServer import CodeAssistServer |
176 self.__codeAssist = CodeAssist(self, self) |
176 self.__codeAssistServer = CodeAssistServer(self, self.__ui) |
177 |
177 |
178 from RefactoringRope.RefactoringServer import RefactoringServer |
178 from RefactoringRope.RefactoringServer import RefactoringServer |
179 self.__refactoringServer = RefactoringServer(self, self.__ui) |
179 self.__refactoringServer = RefactoringServer(self, self.__ui) |
180 self.__refactoringServer.activate() |
180 self.__refactoringServer.activate() |
181 |
181 |
285 if interpreter and Utilities.isinpath(interpreter): |
285 if interpreter and Utilities.isinpath(interpreter): |
286 langs.extend(["Python3", "Pygments|Python 3"]) |
286 langs.extend(["Python3", "Pygments|Python 3"]) |
287 |
287 |
288 return langs |
288 return langs |
289 |
289 |
290 # TODO: move this to CodeAssist |
290 # TODO: move this to CodeAssistServer |
291 def __editorOpened(self, editor): |
291 def __editorOpened(self, editor): |
292 """ |
292 """ |
293 Private slot called, when a new editor was opened. |
293 Private slot called, when a new editor was opened. |
294 |
294 |
295 @param editor reference to the new editor (QScintilla.Editor) |
295 @param editor reference to the new editor (QScintilla.Editor) |
300 self.__connectEditor(editor) |
300 self.__connectEditor(editor) |
301 |
301 |
302 editor.languageChanged.connect(self.__editorLanguageChanged) |
302 editor.languageChanged.connect(self.__editorLanguageChanged) |
303 self.__editors.append(editor) |
303 self.__editors.append(editor) |
304 |
304 |
305 # TODO: move this to CodeAssist |
305 # TODO: move this to CodeAssistServer |
306 def __editorClosed(self, editor): |
306 def __editorClosed(self, editor): |
307 """ |
307 """ |
308 Private slot called, when an editor was closed. |
308 Private slot called, when an editor was closed. |
309 |
309 |
310 @param editor reference to the editor (QScintilla.Editor) |
310 @param editor reference to the editor (QScintilla.Editor) |
312 if editor in self.__editors: |
312 if editor in self.__editors: |
313 editor.languageChanged.disconnect(self.__editorLanguageChanged) |
313 editor.languageChanged.disconnect(self.__editorLanguageChanged) |
314 self.__disconnectEditor(editor) |
314 self.__disconnectEditor(editor) |
315 self.__editors.remove(editor) |
315 self.__editors.remove(editor) |
316 |
316 |
317 # TODO: move this to CodeAssist |
317 # TODO: move this to CodeAssistServer |
318 def __editorLanguageChanged(self, language): |
318 def __editorLanguageChanged(self, language): |
319 """ |
319 """ |
320 Private slot to handle the language change of an editor. |
320 Private slot to handle the language change of an editor. |
321 |
321 |
322 @param language programming language of the editor (string) |
322 @param language programming language of the editor (string) |
338 @param editor reference to the editor (QScintilla.Editor) |
338 @param editor reference to the editor (QScintilla.Editor) |
339 """ |
339 """ |
340 editor.editorAboutToBeSaved.connect(self.__editorAboutToBeSaved) |
340 editor.editorAboutToBeSaved.connect(self.__editorAboutToBeSaved) |
341 editor.editorSaved.connect(self.__editorSaved) |
341 editor.editorSaved.connect(self.__editorSaved) |
342 |
342 |
343 # TODO: move this to CodeAssist |
343 # TODO: move this to CodeAssistServer |
344 if self.getPreferences("CodeAssistEnabled"): |
344 if self.getPreferences("CodeAssistEnabled"): |
345 self.__setAutoCompletionHook(editor) |
345 self.__setAutoCompletionHook(editor) |
346 if self.getPreferences("CodeAssistCalltipsEnabled"): |
346 if self.getPreferences("CodeAssistCalltipsEnabled"): |
347 self.__setCalltipsHook(editor) |
347 self.__setCalltipsHook(editor) |
348 |
348 |
375 editor.editorSaved.disconnect(self.__editorSaved) |
375 editor.editorSaved.disconnect(self.__editorSaved) |
376 except TypeError: |
376 except TypeError: |
377 # just ignore it |
377 # just ignore it |
378 pass |
378 pass |
379 |
379 |
380 # TODO: move this to CodeAssist |
380 # TODO: move this to CodeAssistServer |
381 if editor.getCompletionListHook("rope"): |
381 if editor.getCompletionListHook("rope"): |
382 self.__unsetAutoCompletionHook(editor) |
382 self.__unsetAutoCompletionHook(editor) |
383 if editor.getCallTipHook("rope"): |
383 if editor.getCallTipHook("rope"): |
384 self.__unsetCalltipsHook(editor) |
384 self.__unsetCalltipsHook(editor) |
385 |
385 |
386 self.__disconnectMouseClickHandler(editor) |
386 self.__disconnectMouseClickHandler(editor) |
387 |
387 |
388 # TODO: move this to CodeAssist |
388 # TODO: move this to CodeAssistServer |
389 def __disconnectMouseClickHandler(self, editor): |
389 def __disconnectMouseClickHandler(self, editor): |
390 """ |
390 """ |
391 Private method to disconnect the mouse click handler from an editor. |
391 Private method to disconnect the mouse click handler from an editor. |
392 |
392 |
393 @param editor reference to the editor (QScintilla.Editor) |
393 @param editor reference to the editor (QScintilla.Editor) |
394 """ |
394 """ |
395 editor.removeMouseClickHandlers("rope") |
395 editor.removeMouseClickHandlers("rope") |
396 |
396 |
397 # TODO: move this to CodeAssist |
397 # TODO: move this to CodeAssistServer |
398 def __setAutoCompletionHook(self, editor): |
398 def __setAutoCompletionHook(self, editor): |
399 """ |
399 """ |
400 Private method to set the autocompletion hook. |
400 Private method to set the autocompletion hook. |
401 |
401 |
402 @param editor reference to the editor (QScintilla.Editor) |
402 @param editor reference to the editor (QScintilla.Editor) |
403 """ |
403 """ |
404 editor.addCompletionListHook("rope", self.getCompletionsList) |
404 editor.addCompletionListHook("rope", self.getCompletionsList) |
405 |
405 |
406 # TODO: move this to CodeAssist |
406 # TODO: move this to CodeAssistServer |
407 def __unsetAutoCompletionHook(self, editor): |
407 def __unsetAutoCompletionHook(self, editor): |
408 """ |
408 """ |
409 Private method to unset the autocompletion hook. |
409 Private method to unset the autocompletion hook. |
410 |
410 |
411 @param editor reference to the editor (QScintilla.Editor) |
411 @param editor reference to the editor (QScintilla.Editor) |
412 """ |
412 """ |
413 editor.removeCompletionListHook("rope") |
413 editor.removeCompletionListHook("rope") |
414 |
414 |
415 # TODO: move this to CodeAssist |
415 # TODO: move this to CodeAssistServer |
416 def getCompletionsList(self, editor, context): |
416 def getCompletionsList(self, editor, context): |
417 """ |
417 """ |
418 Public method to get a list of possible completions. |
418 Public method to get a list of possible completions. |
419 |
419 |
420 @param editor reference to the editor object, that called this method |
420 @param editor reference to the editor object, that called this method |
421 (QScintilla.Editor) |
421 (QScintilla.Editor) |
422 @param context flag indicating to autocomplete a context (boolean) |
422 @param context flag indicating to autocomplete a context (boolean) |
423 @return list of possible completions (list of strings) |
423 @return list of possible completions (list of strings) |
424 """ |
424 """ |
425 completions = self.__codeAssist.getCompletions(editor) |
425 completions = self.__codeAssistServer.getCompletions(editor) |
426 return completions |
426 return completions |
427 |
427 |
428 def __editorAboutToBeSaved(self, filename): |
428 def __editorAboutToBeSaved(self, filename): |
429 """ |
429 """ |
430 Private slot to get the old contents of the named file. |
430 Private slot to get the old contents of the named file. |
448 @param filename name of the file that was saved (string) |
448 @param filename name of the file that was saved (string) |
449 """ |
449 """ |
450 if filename == self.__savedEditorName and self.__oldEditorText: |
450 if filename == self.__savedEditorName and self.__oldEditorText: |
451 self.__refactoringServer.reportChanged(self.__savedEditorName, |
451 self.__refactoringServer.reportChanged(self.__savedEditorName, |
452 self.__oldEditorText) |
452 self.__oldEditorText) |
453 self.__codeAssist.reportChanged(self.__savedEditorName, |
453 self.__codeAssistServer.reportChanged(self.__savedEditorName, |
454 self.__oldEditorText) |
454 self.__oldEditorText) |
455 else: |
455 else: |
456 self.__refactoringServer.reportChanged(filename, "") |
456 self.__refactoringServer.reportChanged(filename, "") |
457 self.__codeAssist.reportChanged(filename, "") |
457 self.__codeAssistServer.reportChanged(filename, "") |
458 |
458 |
459 # TODO: move this to CodeAssist |
459 # TODO: move this to CodeAssistServer |
460 def __setCalltipsHook(self, editor): |
460 def __setCalltipsHook(self, editor): |
461 """ |
461 """ |
462 Private method to set the calltip hook. |
462 Private method to set the calltip hook. |
463 |
463 |
464 @param editor reference to the editor (QScintilla.Editor) |
464 @param editor reference to the editor (QScintilla.Editor) |
465 """ |
465 """ |
466 editor.addCallTipHook("rope", self.codeAssistCallTip) |
466 editor.addCallTipHook("rope", self.codeAssistCallTip) |
467 |
467 |
468 # TODO: move this to CodeAssist |
468 # TODO: move this to CodeAssistServer |
469 def __unsetCalltipsHook(self, editor): |
469 def __unsetCalltipsHook(self, editor): |
470 """ |
470 """ |
471 Private method to unset the calltip hook. |
471 Private method to unset the calltip hook. |
472 |
472 |
473 @param editor reference to the editor (QScintilla.Editor) |
473 @param editor reference to the editor (QScintilla.Editor) |
474 """ |
474 """ |
475 editor.removeCallTipHook("rope") |
475 editor.removeCallTipHook("rope") |
476 |
476 |
477 # TODO: move this to CodeAssist |
477 # TODO: move this to CodeAssistServer |
478 def codeAssistCallTip(self, editor, pos, commas): |
478 def codeAssistCallTip(self, editor, pos, commas): |
479 """ |
479 """ |
480 Public method to return a list of calltips. |
480 Public method to return a list of calltips. |
481 |
481 |
482 @param editor reference to the editor (QScintilla.Editor) |
482 @param editor reference to the editor (QScintilla.Editor) |
483 @param pos position in the text for the calltip (integer) |
483 @param pos position in the text for the calltip (integer) |
484 @param commas minimum number of commas contained in the calltip |
484 @param commas minimum number of commas contained in the calltip |
485 (integer) |
485 (integer) |
486 @return list of possible calltips (list of strings) |
486 @return list of possible calltips (list of strings) |
487 """ |
487 """ |
488 cts = self.__codeAssist.getCallTips(pos, editor) |
488 cts = self.__codeAssistServer.getCallTips(pos, editor) |
489 return cts |
489 return cts |
490 |
490 |
491 # |
491 # |
492 # eflag: noqa = M801 |
492 # eflag: noqa = M801 |