15 |
15 |
16 try: |
16 try: |
17 import rope.base.libutils |
17 import rope.base.libutils |
18 import rope.base.project |
18 import rope.base.project |
19 import rope.contrib.codeassist |
19 import rope.contrib.codeassist |
20 |
20 import rope.contrib.findit |
|
21 |
|
22 from rope.base import pynames, pyobjects, pyobjectsdef |
21 from rope.base.exceptions import BadIdentifierError, ModuleSyntaxError |
23 from rope.base.exceptions import BadIdentifierError, ModuleSyntaxError |
|
24 from rope.contrib import fixsyntax |
22 except ImportError: |
25 except ImportError: |
23 sys.exit(42) |
26 sys.exit(42) |
24 |
27 |
25 from eric7.EricNetwork.EricJsonClient import EricJsonClient |
28 from eric7.EricNetwork.EricJsonClient import EricJsonClient |
26 |
29 |
44 order to identify the connection |
47 order to identify the connection |
45 @type str |
48 @type str |
46 @param projectPath path to the project |
49 @param projectPath path to the project |
47 @type str |
50 @type str |
48 """ |
51 """ |
|
52 from FileSystemCommands import RefactoringClientFileSystemCommands # noqa: I102 |
|
53 |
49 super().__init__(host, port, idString) |
54 super().__init__(host, port, idString) |
50 |
55 |
51 self.__methodMapping = { |
56 self.__methodMapping = { |
52 "getConfig": self.__getConfig, |
57 "getConfig": self.__getConfig, |
53 "configChanged": self.__configChanged, |
58 "configChanged": self.__configChanged, |
58 "gotoDefinition": self.__gotoDefinition, |
63 "gotoDefinition": self.__gotoDefinition, |
59 "gotoReferences": self.__getReferences, |
64 "gotoReferences": self.__getReferences, |
60 "reportChanged": self.__reportChanged, |
65 "reportChanged": self.__reportChanged, |
61 } |
66 } |
62 |
67 |
63 from FileSystemCommands import RefactoringClientFileSystemCommands |
|
64 |
|
65 self.__fsCommands = RefactoringClientFileSystemCommands(self) |
68 self.__fsCommands = RefactoringClientFileSystemCommands(self) |
66 |
69 |
67 self.__projectpath = projectPath |
70 self.__projectpath = projectPath |
68 self.__project = rope.base.project.Project( |
71 self.__project = rope.base.project.Project( |
69 self.__projectpath, fscommands=self.__fsCommands |
72 self.__projectpath, fscommands=self.__fsCommands |
102 errorDict["ErrorFile"] = err.filename |
105 errorDict["ErrorFile"] = err.filename |
103 errorDict["ErrorLine"] = err.lineno |
106 errorDict["ErrorLine"] = err.lineno |
104 |
107 |
105 return errorDict |
108 return errorDict |
106 |
109 |
107 def __getConfig(self, params): |
110 def __getConfig(self, params): # noqa: U100 |
108 """ |
111 """ |
109 Private method to send some configuration data to the server. |
112 Private method to send some configuration data to the server. |
110 |
113 |
111 @param params dictionary containing the method parameters sent by |
114 @param params dictionary containing the method parameters sent by |
112 the server |
115 the server |
117 "Id": self.__id, |
120 "Id": self.__id, |
118 } |
121 } |
119 |
122 |
120 self.sendJson("Config", result) |
123 self.sendJson("Config", result) |
121 |
124 |
122 def __configChanged(self, params): |
125 def __configChanged(self, params): # noqa: U100 |
123 """ |
126 """ |
124 Private method to handle a change of the configuration file. |
127 Private method to handle a change of the configuration file. |
125 |
128 |
126 @param params dictionary containing the method parameters sent by |
129 @param params dictionary containing the method parameters sent by |
127 the server |
130 the server |
131 self.__project = rope.base.project.Project( |
134 self.__project = rope.base.project.Project( |
132 self.__projectpath, fscommands=self.__fsCommands |
135 self.__projectpath, fscommands=self.__fsCommands |
133 ) |
136 ) |
134 self.__project.validate(self.__project.root) |
137 self.__project.validate(self.__project.root) |
135 |
138 |
136 def __closeProject(self, params): |
139 def __closeProject(self, params): # noqa: U100 |
137 """ |
140 """ |
138 Private slot to validate the project. |
141 Private slot to validate the project. |
139 |
142 |
140 @param params dictionary containing the method parameters sent by |
143 @param params dictionary containing the method parameters sent by |
141 the server |
144 the server |
362 @param maxfixes number of fixes to be done |
365 @param maxfixes number of fixes to be done |
363 @type int |
366 @type int |
364 @return tuple containing the object type and name |
367 @return tuple containing the object type and name |
365 @rtype tuple of (str, str) |
368 @rtype tuple of (str, str) |
366 """ |
369 """ |
367 from rope.base import pynames, pyobjects, pyobjectsdef |
|
368 from rope.contrib import fixsyntax |
|
369 |
|
370 try: |
370 try: |
371 fixer = fixsyntax.FixSyntax(project, sourceCode, resource, maxfixes) |
371 fixer = fixsyntax.FixSyntax(project, sourceCode, resource, maxfixes) |
372 pyname = fixer.pyname_at(offset) |
372 pyname = fixer.pyname_at(offset) |
373 except BadIdentifierError: |
373 except BadIdentifierError: |
374 pyname = None |
374 pyname = None |