PluginRefactoringRope.py

Sun, 24 Sep 2017 13:56:36 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 24 Sep 2017 13:56:36 +0200
branch
server_client_variant
changeset 189
2711fdd91925
parent 167
3c8e875d0326
child 191
2af42804bca2
permissions
-rw-r--r--

Renamed the 'Refactoring' module and class 'RefactoringServer'.

1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
1 # -*- coding: utf-8 -*-
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
2
147
3f8a995f6e49 Updated copyright for 2017.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 145
diff changeset
3 # Copyright (c) 2010 - 2017 Detlev Offenbach <detlev@die-offenbachs.de>
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
4 #
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
5
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
6 """
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
7 Module implementing the Rope refactoring plugin.
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
8 """
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
9
76
936b2a98fe4e Merge with Py2 comp.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 74 63
diff changeset
10 from __future__ import unicode_literals
50
a29c3d2e6dc0 rope for Python2 projects enabled, if running on Python2
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
11
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
12 import os
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
13
129
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
14 from PyQt5.QtCore import Qt, QObject, QTranslator, QCoreApplication, QTimer
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
15
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
16 from E5Gui.E5Application import e5App
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
17
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
18 import Preferences
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
19 import Utilities
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
20
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
21 from Preferences.Shortcuts import readShortcuts
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
22
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
23 # Start-Of-Header
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
24 name = "Refactoring Rope Plugin"
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
25 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
26 autoactivate = True
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
27 deactivateable = True
160
989cd767992b Started implementing the client/server variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 156
diff changeset
28 version = "5.0.0"
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
29 className = "RefactoringRopePlugin"
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
30 packageName = "RefactoringRope"
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
31 internalPackages = "rope"
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
32 shortDescription = "Refactoring using the Rope library."
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
33 longDescription = """This plug-in implements refactoring functionality""" \
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
34 """ using the Rope refactoring library. Additonally it implements an """ \
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
35 """ alternative auto-completion and calltips provider. Only""" \
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
36 """ refactoring, completions and calltips in the same Python variant""" \
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
37 """ as Eric is running is allowed."""
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
38 pyqtApi = 2
52
abd297a94a55 Added the 'doNotCompile' plug-in module header entry to avoid attempting to compile the sources, which will raise errors due to the rope variants for both Python versions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 51
diff changeset
39 doNotCompile = True
76
936b2a98fe4e Merge with Py2 comp.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 74 63
diff changeset
40 python2Compatible = True
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
41 # End-Of-Header
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
42
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
43 error = ""
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
44
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
45 refactoringRopePluginObject = None
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
46
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
47
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
48 def createAutoCompletionPage(configDlg):
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
49 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
50 Module function to create the autocompletion configuration page.
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
51
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
52 @param configDlg reference to the configuration dialog
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
53 @return reference to the configuration page
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
54 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
55 global refactoringRopePluginObject
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
56 from RefactoringRope.ConfigurationPage.AutoCompletionRopePage \
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
57 import AutoCompletionRopePage
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
58 page = AutoCompletionRopePage(refactoringRopePluginObject)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
59 return page
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
60
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
61
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
62 def createCallTipsPage(configDlg):
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
63 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
64 Module function to create the calltips configuration page.
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
65
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
66 @param configDlg reference to the configuration dialog
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
67 @return reference to the configuration page
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
68 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
69 global refactoringRopePluginObject
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
70 from RefactoringRope.ConfigurationPage.CallTipsRopePage \
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
71 import CallTipsRopePage
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
72 page = CallTipsRopePage(refactoringRopePluginObject)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
73 return page
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
74
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
75
129
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
76 def createMouseClickHandlerPage(configDlg):
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
77 """
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
78 Module function to create the mouse click handler configuration page.
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
79
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
80 @param configDlg reference to the configuration dialog
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
81 @return reference to the configuration page
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
82 """
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
83 global refactoringRopePluginObject
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
84 from RefactoringRope.ConfigurationPage.MouseClickHandlerRopePage \
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
85 import MouseClickHandlerRopePage
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
86 page = MouseClickHandlerRopePage(refactoringRopePluginObject)
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
87 return page
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
88
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
89
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
90 def getConfigData():
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
91 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
92 Module function returning data as required by the configuration dialog.
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
93
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
94 @return dictionary containing the relevant data
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
95 """
129
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
96 data = {
118
d242ba11a04c Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 116
diff changeset
97 "ropeAutoCompletionPage": [
d242ba11a04c Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 116
diff changeset
98 QCoreApplication.translate("RefactoringRopePlugin", "Rope"),
d242ba11a04c Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 116
diff changeset
99 os.path.join("RefactoringRope", "ConfigurationPage",
d242ba11a04c Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 116
diff changeset
100 "preferences-refactoring.png"),
d242ba11a04c Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 116
diff changeset
101 createAutoCompletionPage, "editorAutocompletionPage", None],
d242ba11a04c Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 116
diff changeset
102 "ropeCallTipsPage": [
d242ba11a04c Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 116
diff changeset
103 QCoreApplication.translate("RefactoringRopePlugin", "Rope"),
d242ba11a04c Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 116
diff changeset
104 os.path.join("RefactoringRope", "ConfigurationPage",
d242ba11a04c Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 116
diff changeset
105 "preferences-refactoring.png"),
d242ba11a04c Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 116
diff changeset
106 createCallTipsPage, "editorCalltipsPage", None],
155
124974b2013d Reintroduced the version check to support distributions with old (i.e. pre 6.1.0) eric releases.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 153
diff changeset
107 }
124974b2013d Reintroduced the version check to support distributions with old (i.e. pre 6.1.0) eric releases.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 153
diff changeset
108
124974b2013d Reintroduced the version check to support distributions with old (i.e. pre 6.1.0) eric releases.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 153
diff changeset
109 ui = e5App().getObject("UserInterface")
124974b2013d Reintroduced the version check to support distributions with old (i.e. pre 6.1.0) eric releases.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 153
diff changeset
110 if ui.versionIsNewer("6.0.99", "20150627") or ui.versionIsNewer("16.10"):
156
5ca4ed46e3b4 Added some output indicating why refactoring might be disabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 155
diff changeset
111 data["ropeMouseClickHandlerPage"] = [
129
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
112 QCoreApplication.translate("RefactoringRopePlugin", "Rope"),
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
113 os.path.join("RefactoringRope", "ConfigurationPage",
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
114 "preferences-refactoring.png"),
155
124974b2013d Reintroduced the version check to support distributions with old (i.e. pre 6.1.0) eric releases.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 153
diff changeset
115 createMouseClickHandlerPage, "1editorMouseClickHandlers", None]
129
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
116
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
117 return data
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
118
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
119
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
120 def prepareUninstall():
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
121 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
122 Module function to prepare for an uninstallation.
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
123 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
124 Preferences.Prefs.settings.remove(RefactoringRopePlugin.PreferencesKey)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
125
20
83b71483e198 Made the code PEP-8 compliant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
126
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
127 class RefactoringRopePlugin(QObject):
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
128 """
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
129 Class implementing the Rope refactoring plugin.
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
130 """
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
131 PreferencesKey = "RefactoringRope"
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
132
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
133 def __init__(self, ui):
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
134 """
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
135 Constructor
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
136
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
137 @param ui reference to the user interface object (UI.UserInterface)
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
138 """
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
139 QObject.__init__(self, ui)
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
140 self.__ui = ui
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
141 self.__initialize()
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
142
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
143 self.__defaults = {
118
d242ba11a04c Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 116
diff changeset
144 "CodeAssistEnabled": False,
d242ba11a04c Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 116
diff changeset
145 "MaxFixes": 10,
d242ba11a04c Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 116
diff changeset
146 "CodeAssistTimeout": 100,
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
147
118
d242ba11a04c Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 116
diff changeset
148 "CodeAssistCalltipsEnabled": False,
d242ba11a04c Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 116
diff changeset
149 "CalltipsMaxFixes": 10,
129
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
150
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
151 "MouseClickEnabled": True,
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
152 "MouseClickGotoModifiers": int(Qt.ControlModifier),
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
153 "MouseClickGotoButton": int(Qt.LeftButton),
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
154 }
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
155
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
156 self.__translator = None
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
157 self.__loadTranslator()
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
158
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
159 self.__acTimer = QTimer(self)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
160 self.__acTimer.setSingleShot(True)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
161 self.__acTimer.setInterval(self.getPreferences("CodeAssistTimeout"))
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
162 self.__acTimer.timeout.connect(self.__codeAssist)
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
163
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
164 def __initialize(self):
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
165 """
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
166 Private slot to (re)initialize the plugin.
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
167 """
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
168 self.__object = None
104
f6049d39f83d Made the code completion work in case no project is open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 101
diff changeset
169 self.__caObject = None
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
170
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
171 self.__mainAct = None
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
172 self.__mainMenu = None
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
173
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
174 self.__editors = []
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
175
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
176 self.__currentEditor = None
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
177 self.__savedEditorName = None
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
178 self.__oldEditorText = ""
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
179
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
180 def activate(self):
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
181 """
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
182 Public method to activate this plugin.
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
183
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
184 @return tuple of None and activation status (boolean)
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
185 """
31
0389d4a924cc Dropped support for eric 5.0.x.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
186 global error
0389d4a924cc Dropped support for eric 5.0.x.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
187 error = "" # clear previous error
0389d4a924cc Dropped support for eric 5.0.x.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
188
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
189 global refactoringRopePluginObject
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
190 refactoringRopePluginObject = self
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
191
189
2711fdd91925 Renamed the 'Refactoring' module and class 'RefactoringServer'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 167
diff changeset
192 from RefactoringRope.RefactoringServer import RefactoringServer
104
f6049d39f83d Made the code completion work in case no project is open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 101
diff changeset
193 from RefactoringRope.CodeAssist import CodeAssist
f6049d39f83d Made the code completion work in case no project is open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 101
diff changeset
194
f6049d39f83d Made the code completion work in case no project is open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 101
diff changeset
195 self.__caObject = CodeAssist(self, self)
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
196
189
2711fdd91925 Renamed the 'Refactoring' module and class 'RefactoringServer'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 167
diff changeset
197 self.__object = RefactoringServer(self, self.__ui)
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
198 self.__object.initActions()
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
199 e5App().registerPluginObject("RefactoringRope", self.__object)
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
200 try:
20
83b71483e198 Made the code PEP-8 compliant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
201 readShortcuts(pluginName="RefactoringRope")
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
202 except TypeError:
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
203 # backwards comaytibility, ignore
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
204 pass
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
205
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
206 self.__mainMenu = self.__object.initMenu()
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
207 extrasAct = self.__ui.getMenuBarAction("extras")
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
208 self.__mainAct = self.__ui.menuBar().insertMenu(
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
209 extrasAct, self.__mainMenu)
167
3c8e875d0326 Some code cleanup and refinement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
210 self.__mainAct.setEnabled(False)
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
211
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
212 if e5App().getObject("Project").isOpen():
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
213 self.__object.projectOpened()
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
214
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
215 e5App().getObject("ViewManager").editorOpenedEd.connect(
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
216 self.__editorOpened)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
217 e5App().getObject("ViewManager").editorClosedEd.connect(
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
218 self.__editorClosed)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
219
31
0389d4a924cc Dropped support for eric 5.0.x.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
220 e5App().getObject("Project").projectOpened.connect(
0389d4a924cc Dropped support for eric 5.0.x.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
221 self.__object.projectOpened)
76
936b2a98fe4e Merge with Py2 comp.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 74 63
diff changeset
222 e5App().getObject("Project").projectPropertiesChanged.connect(
936b2a98fe4e Merge with Py2 comp.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 74 63
diff changeset
223 self.__object.projectOpened)
31
0389d4a924cc Dropped support for eric 5.0.x.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
224 e5App().getObject("Project").projectClosed.connect(
0389d4a924cc Dropped support for eric 5.0.x.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
225 self.__object.projectClosed)
0389d4a924cc Dropped support for eric 5.0.x.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
226 e5App().getObject("Project").newProject.connect(
0389d4a924cc Dropped support for eric 5.0.x.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
227 self.__object.projectOpened)
0389d4a924cc Dropped support for eric 5.0.x.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
228
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
229 if e5App().getObject("Project").isOpen():
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
230 for editor in e5App().getObject("ViewManager").getOpenEditors():
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
231 self.__editorOpened(editor)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
232
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
233 return None, True
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
234
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
235 def deactivate(self):
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
236 """
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
237 Public method to deactivate this plugin.
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
238 """
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
239 e5App().unregisterPluginObject("RefactoringRope")
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
240
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
241 e5App().getObject("ViewManager").editorOpenedEd.disconnect(
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
242 self.__editorOpened)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
243 e5App().getObject("ViewManager").editorClosedEd.disconnect(
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
244 self.__editorClosed)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
245
31
0389d4a924cc Dropped support for eric 5.0.x.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
246 e5App().getObject("Project").projectOpened.disconnect(
0389d4a924cc Dropped support for eric 5.0.x.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
247 self.__object.projectOpened)
76
936b2a98fe4e Merge with Py2 comp.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 74 63
diff changeset
248 e5App().getObject("Project").projectPropertiesChanged.disconnect(
936b2a98fe4e Merge with Py2 comp.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 74 63
diff changeset
249 self.__object.projectOpened)
31
0389d4a924cc Dropped support for eric 5.0.x.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
250 e5App().getObject("Project").projectClosed.disconnect(
0389d4a924cc Dropped support for eric 5.0.x.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
251 self.__object.projectClosed)
0389d4a924cc Dropped support for eric 5.0.x.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
252 e5App().getObject("Project").newProject.disconnect(
0389d4a924cc Dropped support for eric 5.0.x.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
253 self.__object.projectOpened)
0389d4a924cc Dropped support for eric 5.0.x.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
254
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
255 self.__ui.menuBar().removeAction(self.__mainAct)
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
256
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
257 for editor in self.__editors[:]:
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
258 self.__editorClosed(editor)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
259
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
260 self.__initialize()
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
261
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
262 def __loadTranslator(self):
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
263 """
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
264 Private method to load the translation file.
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
265 """
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
266 if self.__ui is not None:
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
267 loc = self.__ui.getLocale()
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
268 if loc and loc != "C":
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
269 locale_dir = \
20
83b71483e198 Made the code PEP-8 compliant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
270 os.path.join(os.path.dirname(__file__),
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
271 "RefactoringRope", "i18n")
151
5260100b6700 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 148
diff changeset
272 translation = "rope_{0}".format(loc)
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
273 translator = QTranslator(None)
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
274 loaded = translator.load(translation, locale_dir)
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
275 if loaded:
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
276 self.__translator = translator
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
277 e5App().installTranslator(self.__translator)
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
278 else:
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
279 print("Warning: translation file '{0}' could not"
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
280 " be loaded.".format(translation))
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
281 print("Using default.")
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
282
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
283 def getPreferences(self, key):
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
284 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
285 Public method to retrieve the various refactoring settings.
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
286
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
287 @param key the key of the value to get
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
288 @return the requested refactoring setting
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
289 """
118
d242ba11a04c Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 116
diff changeset
290 if key in ["CodeAssistEnabled", "CodeAssistCalltipsEnabled",
153
9557ef516806 Removed the outdated check for the correct eric version.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
291 "MouseClickEnabled"]:
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
292 return Preferences.toBool(Preferences.Prefs.settings.value(
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
293 self.PreferencesKey + "/" + key, self.__defaults[key]))
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
294 else:
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
295 return int(Preferences.Prefs.settings.value(
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
296 self.PreferencesKey + "/" + key, self.__defaults[key]))
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
297
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
298 def setPreferences(self, key, value):
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
299 """
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
300 Public method to store the various refactoring settings.
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
301
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
302 @param key the key of the setting to be set (string)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
303 @param value the value to be set
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
304 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
305 Preferences.Prefs.settings.setValue(
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
306 self.PreferencesKey + "/" + key, value)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
307
129
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
308 if key in ["CodeAssistEnabled", "CodeAssistCalltipsEnabled",
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
309 "MouseClickEnabled"]:
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
310 if value:
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
311 if e5App().getObject("Project").isOpen():
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
312 for editor in e5App().getObject("ViewManager")\
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
313 .getOpenEditors():
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
314 if editor not in self.__editors:
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
315 self.__editorOpened(editor)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
316 else:
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
317 for editor in self.__editors[:]:
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
318 self.__editorClosed(editor)
129
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
319 elif key in ["MouseClickGotoModifiers", "MouseClickGotoButton"]:
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
320 for editor in self.__editors:
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
321 self.__disconnectMouseClickHandler(editor)
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
322 self.__connectMouseClickHandler(editor)
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
323 elif key == "CodeAssistTimeout":
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
324 self.__acTimer.setInterval(value)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
325
167
3c8e875d0326 Some code cleanup and refinement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
326 def __determineLanguages(self):
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
327 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
328 Private method to determine the valid language strings.
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
329
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
330 @return list of valid language strings (list of string)
1
9f687137a929 Started implementing the basic functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
331 """
167
3c8e875d0326 Some code cleanup and refinement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
332 langs = []
76
936b2a98fe4e Merge with Py2 comp.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 74 63
diff changeset
333
167
3c8e875d0326 Some code cleanup and refinement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
334 interpreter = Preferences.getDebugger("PythonInterpreter")
3c8e875d0326 Some code cleanup and refinement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
335 if interpreter and Utilities.isinpath(interpreter):
3c8e875d0326 Some code cleanup and refinement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
336 langs.extend(["Python", "Python2", "Pygments|Python"])
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
337
167
3c8e875d0326 Some code cleanup and refinement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
338 interpreter = Preferences.getDebugger("Python3Interpreter")
3c8e875d0326 Some code cleanup and refinement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
339 if interpreter and Utilities.isinpath(interpreter):
3c8e875d0326 Some code cleanup and refinement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
340 langs.extend(["Python3", "Pygments|Python 3"])
3c8e875d0326 Some code cleanup and refinement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
341
3c8e875d0326 Some code cleanup and refinement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
342 return langs
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
343
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
344 def __editorOpened(self, editor):
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
345 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
346 Private slot called, when a new editor was opened.
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
347
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
348 @param editor reference to the new editor (QScintilla.Editor)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
349 """
167
3c8e875d0326 Some code cleanup and refinement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
350 langs = self.__determineLanguages()
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
351
167
3c8e875d0326 Some code cleanup and refinement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
352 if editor.getLanguage() in langs:
104
f6049d39f83d Made the code completion work in case no project is open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 101
diff changeset
353 self.__connectEditor(editor)
f6049d39f83d Made the code completion work in case no project is open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 101
diff changeset
354
f6049d39f83d Made the code completion work in case no project is open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 101
diff changeset
355 editor.languageChanged.connect(self.__editorLanguageChanged)
f6049d39f83d Made the code completion work in case no project is open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 101
diff changeset
356 self.__editors.append(editor)
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
357
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
358 def __editorClosed(self, editor):
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
359 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
360 Private slot called, when an editor was closed.
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
361
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
362 @param editor reference to the editor (QScintilla.Editor)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
363 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
364 if editor in self.__editors:
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
365 editor.languageChanged.disconnect(self.__editorLanguageChanged)
101
5098ad8960ed Fixed issues connecting/disconnecting editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 100
diff changeset
366 self.__disconnectEditor(editor)
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
367 self.__editors.remove(editor)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
368
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
369 def __editorLanguageChanged(self, language):
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
370 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
371 Private slot to handle the language change of an editor.
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
372
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
373 @param language programming language of the editor (string)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
374 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
375 editor = self.sender()
167
3c8e875d0326 Some code cleanup and refinement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
376 langs = self.__determineLanguages()
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
377
167
3c8e875d0326 Some code cleanup and refinement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 160
diff changeset
378 if language in langs:
125
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
379 try:
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
380 if editor.getCompletionListHook("rope") is None or \
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
381 editor.getCallTipHook("rope") is None:
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
382 self.__connectEditor(editor)
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
383 except AttributeError:
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
384 # old interface (before 6.1.0)
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
385 if editor.autoCompletionHook() != self.codeAssist or \
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
386 editor.callTipHook() != self.codeAssistCallTip:
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
387 self.__connectEditor(editor)
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
388 else:
101
5098ad8960ed Fixed issues connecting/disconnecting editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 100
diff changeset
389 self.__disconnectEditor(editor)
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
390
101
5098ad8960ed Fixed issues connecting/disconnecting editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 100
diff changeset
391 def __connectEditor(self, editor):
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
392 """
101
5098ad8960ed Fixed issues connecting/disconnecting editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 100
diff changeset
393 Private method to connect an editor.
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
394
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
395 @param editor reference to the editor (QScintilla.Editor)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
396 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
397 editor.editorAboutToBeSaved.connect(self.__editorAboutToBeSaved)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
398 editor.editorSaved.connect(self.__editorSaved)
101
5098ad8960ed Fixed issues connecting/disconnecting editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 100
diff changeset
399
5098ad8960ed Fixed issues connecting/disconnecting editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 100
diff changeset
400 if self.getPreferences("CodeAssistEnabled"):
5098ad8960ed Fixed issues connecting/disconnecting editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 100
diff changeset
401 self.__setAutoCompletionHook(editor)
5098ad8960ed Fixed issues connecting/disconnecting editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 100
diff changeset
402 if self.getPreferences("CodeAssistCalltipsEnabled"):
5098ad8960ed Fixed issues connecting/disconnecting editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 100
diff changeset
403 self.__setCalltipsHook(editor)
129
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
404
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
405 if self.getPreferences("MouseClickEnabled"):
140
584c697c66f4 Fix for an issue in the mouse click handler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 138
diff changeset
406 self.__disconnectMouseClickHandler(editor)
129
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
407 self.__connectMouseClickHandler(editor)
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
408
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
409 def __connectMouseClickHandler(self, editor):
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
410 """
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
411 Private method to connect the mouse click handler to an editor.
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
412
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
413 @param editor reference to the editor (QScintilla.Editor)
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
414 """
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
415 if self.getPreferences("MouseClickGotoButton"):
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
416 try:
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
417 editor.setMouseClickHandler(
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
418 "rope",
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
419 self.getPreferences("MouseClickGotoModifiers"),
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
420 self.getPreferences("MouseClickGotoButton"),
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
421 self.__object.gotoDefinition
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
422 )
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
423 except AttributeError:
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
424 # eric versions before 6.1.0 don't support this
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
425 pass
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
426
101
5098ad8960ed Fixed issues connecting/disconnecting editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 100
diff changeset
427 def __disconnectEditor(self, editor):
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
428 """
101
5098ad8960ed Fixed issues connecting/disconnecting editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 100
diff changeset
429 Private method to disconnect an editor.
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
430
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
431 @param editor reference to the editor (QScintilla.Editor)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
432 """
101
5098ad8960ed Fixed issues connecting/disconnecting editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 100
diff changeset
433 try:
5098ad8960ed Fixed issues connecting/disconnecting editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 100
diff changeset
434 editor.editorAboutToBeSaved.disconnect(self.__editorAboutToBeSaved)
5098ad8960ed Fixed issues connecting/disconnecting editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 100
diff changeset
435 editor.editorSaved.disconnect(self.__editorSaved)
5098ad8960ed Fixed issues connecting/disconnecting editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 100
diff changeset
436 except TypeError:
5098ad8960ed Fixed issues connecting/disconnecting editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 100
diff changeset
437 # just ignore it
5098ad8960ed Fixed issues connecting/disconnecting editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 100
diff changeset
438 pass
5098ad8960ed Fixed issues connecting/disconnecting editors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 100
diff changeset
439
125
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
440 try:
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
441 if editor.getCompletionListHook("rope"):
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
442 self.__unsetAutoCompletionHook(editor)
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
443 except AttributeError:
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
444 # old interface (before 6.1.0)
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
445 if editor.autoCompletionHook() == self.codeAssist:
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
446 self.__unsetAutoCompletionHook(editor)
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
447 try:
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
448 if editor.getCallTipHook("rope"):
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
449 self.__unsetCalltipsHook(editor)
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
450 except AttributeError:
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
451 # old interface (before 6.1.0)
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
452 if editor.callTipHook() == self.codeAssistCallTip:
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
453 self.__unsetCalltipsHook(editor)
129
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
454
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
455 self.__disconnectMouseClickHandler(editor)
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
456
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
457 def __disconnectMouseClickHandler(self, editor):
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
458 """
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
459 Private method to disconnect the mouse click handler from an editor.
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
460
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
461 @param editor reference to the editor (QScintilla.Editor)
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
462 """
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
463 try:
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
464 editor.removeMouseClickHandlers("rope")
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
465 except AttributeError:
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
466 # eric versions before 6.1.0 don't support this
23ee57a96ea3 Added capability to go to the definition of a class or function by clicking on it (while holding the Ctrl key or another configurable modifier sequence) (needs eric 6.1.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 127
diff changeset
467 pass
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
468
151
5260100b6700 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 148
diff changeset
469 def __completionListSelected(self, userListId, txt):
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
470 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
471 Private slot to handle the selection from the completion list.
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
472
151
5260100b6700 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 148
diff changeset
473 @param userListId the ID of the user list (should be 1) (integer)
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
474 @param txt the selected text (QString)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
475 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
476 from QScintilla.Editor import EditorAutoCompletionListID
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
477
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
478 editor = self.sender()
151
5260100b6700 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 148
diff changeset
479 if userListId == EditorAutoCompletionListID:
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
480 lst = txt.split()
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
481 if len(lst) > 1:
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
482 txt = lst[0]
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
483
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
484 if Preferences.getEditor("AutoCompletionReplaceWord"):
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
485 editor.selectCurrentWord()
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
486 editor.removeSelectedText()
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
487 line, col = editor.getCursorPosition()
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
488 else:
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
489 line, col = editor.getCursorPosition()
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
490 wLeft = editor.getWordLeft(line, col)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
491 if not txt.startswith(wLeft):
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
492 editor.selectCurrentWord()
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
493 editor.removeSelectedText()
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
494 line, col = editor.getCursorPosition()
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
495 elif wLeft:
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
496 txt = txt[len(wLeft):]
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
497 editor.insert(txt)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
498 editor.setCursorPosition(line, col + len(txt))
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
499
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
500 def __setAutoCompletionHook(self, editor):
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
501 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
502 Private method to set the autocompletion hook.
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
503
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
504 @param editor reference to the editor (QScintilla.Editor)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
505 """
125
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
506 try:
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
507 editor.addCompletionListHook("rope", self.getCompletionsList)
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
508 except AttributeError:
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
509 # old interface (before 6.1.0)
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
510 editor.userListActivated.connect(self.__completionListSelected)
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
511 editor.setAutoCompletionHook(self.codeAssist)
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
512
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
513 def __unsetAutoCompletionHook(self, editor):
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
514 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
515 Private method to unset the autocompletion hook.
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
516
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
517 @param editor reference to the editor (QScintilla.Editor)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
518 """
125
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
519 try:
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
520 editor.removeCompletionListHook("rope")
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
521 except AttributeError:
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
522 # old interface (before 6.1.0)
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
523 editor.unsetAutoCompletionHook()
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
524 editor.userListActivated.disconnect(self.__completionListSelected)
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
525
118
d242ba11a04c Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 116
diff changeset
526 def codeAssist(self, editor, context=False):
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
527 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
528 Public method to determine the autocompletion proposals.
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
529
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
530 @param editor reference to the editor object, that called this method
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
531 QScintilla.Editor)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
532 @param context flag indicating to autocomplete a context (boolean)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
533 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
534 self.__currentEditor = editor
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
535 if self.getPreferences("CodeAssistTimeout"):
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
536 self.__acTimer.stop()
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
537 self.__acTimer.start()
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
538 else:
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
539 self.__codeAssist()
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
540
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
541 def __codeAssist(self):
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
542 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
543 Private slot to show a list with completion proposals.
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
544 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
545 from QScintilla.Editor import EditorAutoCompletionListID
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
546
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
547 if self.__currentEditor is not None:
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
548 if self.__currentEditor.isListActive():
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
549 self.__currentEditor.cancelList()
119
a03f2be1997b Added some eye-candy and made the method to get a list of completions publicly available.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 118
diff changeset
550 completions = self.getCompletionsList(self.__currentEditor, False)
153
9557ef516806 Removed the outdated check for the correct eric version.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 151
diff changeset
551 if len(completions) == 0:
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
552 # try QScintilla autocompletion
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
553 self.__currentEditor.autoCompleteQScintilla()
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
554 else:
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
555 completions.sort()
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
556 self.__currentEditor.showUserList(EditorAutoCompletionListID,
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
557 completions)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
558
119
a03f2be1997b Added some eye-candy and made the method to get a list of completions publicly available.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 118
diff changeset
559 def getCompletionsList(self, editor, context):
a03f2be1997b Added some eye-candy and made the method to get a list of completions publicly available.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 118
diff changeset
560 """
a03f2be1997b Added some eye-candy and made the method to get a list of completions publicly available.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 118
diff changeset
561 Public method to get a list of possible completions.
a03f2be1997b Added some eye-candy and made the method to get a list of completions publicly available.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 118
diff changeset
562
a03f2be1997b Added some eye-candy and made the method to get a list of completions publicly available.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 118
diff changeset
563 @param editor reference to the editor object, that called this method
a03f2be1997b Added some eye-candy and made the method to get a list of completions publicly available.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 118
diff changeset
564 (QScintilla.Editor)
a03f2be1997b Added some eye-candy and made the method to get a list of completions publicly available.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 118
diff changeset
565 @param context flag indicating to autocomplete a context (boolean)
a03f2be1997b Added some eye-candy and made the method to get a list of completions publicly available.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 118
diff changeset
566 @return list of possible completions (list of strings)
a03f2be1997b Added some eye-candy and made the method to get a list of completions publicly available.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 118
diff changeset
567 """
a03f2be1997b Added some eye-candy and made the method to get a list of completions publicly available.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 118
diff changeset
568 completions = self.__caObject.getCompletions(editor)
a03f2be1997b Added some eye-candy and made the method to get a list of completions publicly available.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 118
diff changeset
569 return completions
a03f2be1997b Added some eye-candy and made the method to get a list of completions publicly available.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 118
diff changeset
570
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
571 def __editorAboutToBeSaved(self, filename):
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
572 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
573 Private slot to get the old contents of the named file.
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
574
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
575 @param filename name of the file about to be saved (string)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
576 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
577 if filename and os.path.exists(filename):
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
578 try:
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
579 self.__oldEditorText = Utilities.readEncodedFile(filename)[0]
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
580 except IOError:
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
581 self.__oldEditorText = ""
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
582 self.__savedEditorName = filename
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
583 else:
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
584 self.__savedEditorName = ""
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
585 self.__oldEditorText = ""
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
586
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
587 def __editorSaved(self, filename):
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
588 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
589 Private slot to activate SOA.
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
590
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
591 @param filename name of the file that was saved (string)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
592 """
104
f6049d39f83d Made the code completion work in case no project is open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 101
diff changeset
593 if filename == self.__savedEditorName and self.__oldEditorText:
106
b2b2107b8047 Little improvement to update the SOA database for refactoring upon saving a file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 104
diff changeset
594 self.__object.reportChanged(self.__savedEditorName,
b2b2107b8047 Little improvement to update the SOA database for refactoring upon saving a file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 104
diff changeset
595 self.__oldEditorText)
104
f6049d39f83d Made the code completion work in case no project is open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 101
diff changeset
596 self.__caObject.reportChanged(self.__savedEditorName,
f6049d39f83d Made the code completion work in case no project is open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 101
diff changeset
597 self.__oldEditorText)
f6049d39f83d Made the code completion work in case no project is open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 101
diff changeset
598 else:
106
b2b2107b8047 Little improvement to update the SOA database for refactoring upon saving a file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 104
diff changeset
599 self.__object.reportChanged(filename, "")
104
f6049d39f83d Made the code completion work in case no project is open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 101
diff changeset
600 self.__caObject.reportChanged(filename, "")
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
601
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
602 def __setCalltipsHook(self, editor):
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
603 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
604 Private method to set the calltip hook.
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
605
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
606 @param editor reference to the editor (QScintilla.Editor)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
607 """
125
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
608 try:
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
609 editor.addCallTipHook("rope", self.codeAssistCallTip)
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
610 except AttributeError:
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
611 # old interface (before 6.1.0)
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
612 editor.setCallTipHook(self.codeAssistCallTip)
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
613
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
614 def __unsetCalltipsHook(self, editor):
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
615 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
616 Private method to unset the calltip hook.
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
617
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
618 @param editor reference to the editor (QScintilla.Editor)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
619 """
125
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
620 try:
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
621 editor.removeCallTipHook("rope")
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
622 except AttributeError:
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
623 # old interface (before 6.1.0)
e775b4f9d07c Adapted to the extended Editor API as of eric 6.1.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 122
diff changeset
624 editor.unsetCallTipHook()
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
625
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
626 def codeAssistCallTip(self, editor, pos, commas):
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
627 """
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
628 Public method to return a list of calltips.
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
629
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
630 @param editor reference to the editor (QScintilla.Editor)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
631 @param pos position in the text for the calltip (integer)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
632 @param commas minimum number of commas contained in the calltip
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
633 (integer)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
634 @return list of possible calltips (list of strings)
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
635 """
104
f6049d39f83d Made the code completion work in case no project is open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 101
diff changeset
636 cts = self.__caObject.getCallTips(pos, editor)
100
2bfe9e3fad8d Ported the code completion and calltips support of the eric4 variant of this plug-in.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 99
diff changeset
637 return cts
151
5260100b6700 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 148
diff changeset
638
5260100b6700 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 148
diff changeset
639 #
5260100b6700 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 148
diff changeset
640 # eflag: noqa = M801

eric ide

mercurial