PluginRefactoringRope.py

branch
server_client_variant
changeset 202
a111134b5dc7
parent 201
e677d82706d4
child 203
c38750e1bafd
equal deleted inserted replaced
201:e677d82706d4 202:a111134b5dc7
291 291
292 def __editorOpened(self, editor): 292 def __editorOpened(self, editor):
293 """ 293 """
294 Private slot called, when a new editor was opened. 294 Private slot called, when a new editor was opened.
295 295
296 @param editor reference to the new editor (QScintilla.Editor) 296 @param editor reference to the new editor
297 @type QScintilla.Editor
297 """ 298 """
298 if self.__codeAssistServer.isSupportedLanguage(editor.getLanguage()): 299 if self.__codeAssistServer.isSupportedLanguage(editor.getLanguage()):
299 self.__connectEditor(editor) 300 self.__connectEditor(editor)
300 301
301 editor.languageChanged.connect(self.__editorLanguageChanged) 302 editor.languageChanged.connect(self.__editorLanguageChanged)
303 304
304 def __editorClosed(self, editor): 305 def __editorClosed(self, editor):
305 """ 306 """
306 Private slot called, when an editor was closed. 307 Private slot called, when an editor was closed.
307 308
308 @param editor reference to the editor (QScintilla.Editor) 309 @param editor reference to the editor
310 @type QScintilla.Editor
309 """ 311 """
310 if editor in self.__editors: 312 if editor in self.__editors:
311 editor.languageChanged.disconnect(self.__editorLanguageChanged) 313 editor.languageChanged.disconnect(self.__editorLanguageChanged)
312 self.__disconnectEditor(editor) 314 self.__disconnectEditor(editor)
313 self.__editors.remove(editor) 315 self.__editors.remove(editor)
314 316
315 def __editorLanguageChanged(self, language): 317 def __editorLanguageChanged(self, language):
316 """ 318 """
317 Private slot to handle the language change of an editor. 319 Private slot to handle the language change of an editor.
318 320
319 @param language programming language of the editor (string) 321 @param language programming language of the editor
322 @type str
320 """ 323 """
321 editor = self.sender() 324 editor = self.sender()
322 325
323 if self.__codeAssistServer.isSupportedLanguage(language): 326 if self.__codeAssistServer.isSupportedLanguage(language):
324 if editor.getCompletionListHook("rope") is None or \ 327 if editor.getCompletionListHook("rope") is None or \
329 332
330 def __connectEditor(self, editor): 333 def __connectEditor(self, editor):
331 """ 334 """
332 Private method to connect an editor. 335 Private method to connect an editor.
333 336
334 @param editor reference to the editor (QScintilla.Editor) 337 @param editor reference to the editor
338 @type QScintilla.Editor
335 """ 339 """
336 editor.editorAboutToBeSaved.connect(self.__editorAboutToBeSaved) 340 editor.editorAboutToBeSaved.connect(self.__editorAboutToBeSaved)
337 editor.editorSaved.connect(self.__editorSaved) 341 editor.editorSaved.connect(self.__editorSaved)
338 342
339 if self.getPreferences("CodeAssistEnabled"): 343 if self.getPreferences("CodeAssistEnabled"):
347 351
348 def __connectMouseClickHandler(self, editor): 352 def __connectMouseClickHandler(self, editor):
349 """ 353 """
350 Private method to connect the mouse click handler to an editor. 354 Private method to connect the mouse click handler to an editor.
351 355
352 @param editor reference to the editor (QScintilla.Editor) 356 @param editor reference to the editor
357 @type QScintilla.Editor
353 """ 358 """
354 if self.getPreferences("MouseClickGotoButton"): 359 if self.getPreferences("MouseClickGotoButton"):
355 editor.setMouseClickHandler( 360 editor.setMouseClickHandler(
356 "rope", 361 "rope",
357 self.getPreferences("MouseClickGotoModifiers"), 362 self.getPreferences("MouseClickGotoModifiers"),
361 366
362 def __disconnectEditor(self, editor): 367 def __disconnectEditor(self, editor):
363 """ 368 """
364 Private method to disconnect an editor. 369 Private method to disconnect an editor.
365 370
366 @param editor reference to the editor (QScintilla.Editor) 371 @param editor reference to the editor
372 @type QScintilla.Editor
367 """ 373 """
368 try: 374 try:
369 editor.editorAboutToBeSaved.disconnect(self.__editorAboutToBeSaved) 375 editor.editorAboutToBeSaved.disconnect(self.__editorAboutToBeSaved)
370 editor.editorSaved.disconnect(self.__editorSaved) 376 editor.editorSaved.disconnect(self.__editorSaved)
371 except TypeError: 377 except TypeError:
381 387
382 def __disconnectMouseClickHandler(self, editor): 388 def __disconnectMouseClickHandler(self, editor):
383 """ 389 """
384 Private method to disconnect the mouse click handler from an editor. 390 Private method to disconnect the mouse click handler from an editor.
385 391
386 @param editor reference to the editor (QScintilla.Editor) 392 @param editor reference to the editor
393 @type QScintilla.Editor
387 """ 394 """
388 editor.removeMouseClickHandlers("rope") 395 editor.removeMouseClickHandlers("rope")
389 396
390 def __setAutoCompletionHook(self, editor): 397 def __setAutoCompletionHook(self, editor):
391 """ 398 """
392 Private method to set the autocompletion hook. 399 Private method to set the autocompletion hook.
393 400
394 @param editor reference to the editor (QScintilla.Editor) 401 @param editor reference to the editor
402 @type QScintilla.Editor
395 """ 403 """
396 editor.addCompletionListHook("rope", self.getCompletionsList) 404 editor.addCompletionListHook("rope", self.getCompletionsList)
397 405
398 def __unsetAutoCompletionHook(self, editor): 406 def __unsetAutoCompletionHook(self, editor):
399 """ 407 """
400 Private method to unset the autocompletion hook. 408 Private method to unset the autocompletion hook.
401 409
402 @param editor reference to the editor (QScintilla.Editor) 410 @param editor reference to the editor
411 @type QScintilla.Editor
403 """ 412 """
404 editor.removeCompletionListHook("rope") 413 editor.removeCompletionListHook("rope")
405 414
406 def getCompletionsList(self, editor, context): 415 def getCompletionsList(self, editor, context):
407 """ 416 """
408 Public method to get a list of possible completions. 417 Public method to get a list of possible completions.
409 418
410 @param editor reference to the editor object, that called this method 419 @param editor reference to the editor object, that called this method
411 (QScintilla.Editor) 420 @type QScintilla.Editor
412 @param context flag indicating to autocomplete a context (boolean) 421 @param context flag indicating to autocomplete a context
413 @return list of possible completions (list of strings) 422 @type bool
423 @return list of possible completions
424 @rtype list of str
414 """ 425 """
415 completions = self.__codeAssistServer.getCompletions(editor) 426 completions = self.__codeAssistServer.getCompletions(editor)
416 return completions 427 return completions
417 428
418 def __editorAboutToBeSaved(self, filename): 429 def __editorAboutToBeSaved(self, filename):
419 """ 430 """
420 Private slot to get the old contents of the named file. 431 Private slot to get the old contents of the named file.
421 432
422 @param filename name of the file about to be saved (string) 433 @param filename name of the file about to be saved
434 @type str
423 """ 435 """
424 if filename and os.path.exists(filename): 436 if filename and os.path.exists(filename):
425 try: 437 try:
426 self.__oldEditorText = Utilities.readEncodedFile(filename)[0] 438 self.__oldEditorText = Utilities.readEncodedFile(filename)[0]
427 except IOError: 439 except IOError:
433 445
434 def __editorSaved(self, filename): 446 def __editorSaved(self, filename):
435 """ 447 """
436 Private slot to activate SOA. 448 Private slot to activate SOA.
437 449
438 @param filename name of the file that was saved (string) 450 @param filename name of the file that was saved
451 @type str
439 """ 452 """
440 if filename == self.__savedEditorName and self.__oldEditorText: 453 if filename == self.__savedEditorName and self.__oldEditorText:
441 self.__refactoringServer.reportChanged(self.__savedEditorName, 454 self.__refactoringServer.reportChanged(self.__savedEditorName,
442 self.__oldEditorText) 455 self.__oldEditorText)
443 self.__codeAssistServer.reportChanged(self.__savedEditorName, 456 self.__codeAssistServer.reportChanged(self.__savedEditorName,
448 461
449 def __setCalltipsHook(self, editor): 462 def __setCalltipsHook(self, editor):
450 """ 463 """
451 Private method to set the calltip hook. 464 Private method to set the calltip hook.
452 465
453 @param editor reference to the editor (QScintilla.Editor) 466 @param editor reference to the editor
467 @type QScintilla.Editor
454 """ 468 """
455 editor.addCallTipHook("rope", self.codeAssistCallTip) 469 editor.addCallTipHook("rope", self.codeAssistCallTip)
456 470
457 def __unsetCalltipsHook(self, editor): 471 def __unsetCalltipsHook(self, editor):
458 """ 472 """
459 Private method to unset the calltip hook. 473 Private method to unset the calltip hook.
460 474
461 @param editor reference to the editor (QScintilla.Editor) 475 @param editor reference to the editor
476 @type QScintilla.Editor
462 """ 477 """
463 editor.removeCallTipHook("rope") 478 editor.removeCallTipHook("rope")
464 479
465 def codeAssistCallTip(self, editor, pos, commas): 480 def codeAssistCallTip(self, editor, pos, commas):
466 """ 481 """
467 Public method to return a list of calltips. 482 Public method to return a list of calltips.
468 483
469 @param editor reference to the editor (QScintilla.Editor) 484 @param editor reference to the editor
470 @param pos position in the text for the calltip (integer) 485 @type QScintilla.Editor
486 @param pos position in the text for the calltip
487 @type int
471 @param commas minimum number of commas contained in the calltip 488 @param commas minimum number of commas contained in the calltip
472 (integer) 489 @type int
473 @return list of possible calltips (list of strings) 490 @return list of possible calltips
491 @rtype list of str
474 """ 492 """
475 cts = self.__codeAssistServer.getCallTips(pos, editor) 493 cts = self.__codeAssistServer.getCallTips(pos, editor)
476 return cts 494 return cts
477 495
478 # 496 #

eric ide

mercurial