163 @param preventPassiveDebugging flag overriding the PassiveDbgEnabled |
160 @param preventPassiveDebugging flag overriding the PassiveDbgEnabled |
164 setting (boolean) |
161 setting (boolean) |
165 """ |
162 """ |
166 super(DebugServer, self).__init__() |
163 super(DebugServer, self).__init__() |
167 |
164 |
|
165 self.__debuggerInterfaces = {} |
|
166 # the interface name is the key, a function to get the |
|
167 # registration data is the value |
168 self.__debuggerInterfaceRegistry = {} |
168 self.__debuggerInterfaceRegistry = {} |
169 # the client language is the key, a list containing the client |
169 # the client language is the key, a list containing the client |
170 # capabilities, the list of associated file extensions, a |
170 # capabilities, a list of associated file extensions, a |
171 # function reference to create the debugger interface (see |
171 # function reference to create the debugger interface (see |
172 # __createDebuggerInterface() below) and a function to be called |
172 # __createDebuggerInterface() below) and the interface name is |
173 # to get the registration data as values |
173 # the value |
174 |
174 |
175 # create our models |
175 # create our models |
176 self.breakpointModel = BreakPointModel(self) |
176 self.breakpointModel = BreakPointModel(self) |
177 self.watchpointModel = WatchPointModel(self) |
177 self.watchpointModel = WatchPointModel(self) |
178 self.watchSpecialCreated = \ |
178 self.watchSpecialCreated = \ |
292 |
292 |
293 def preferencesChanged(self): |
293 def preferencesChanged(self): |
294 """ |
294 """ |
295 Public slot to handle the preferencesChanged signal. |
295 Public slot to handle the preferencesChanged signal. |
296 """ |
296 """ |
297 # TODO: just build a set of registry data functions and call |
|
298 # registerDebuggerInterface with each of them |
|
299 registeredInterfaces = {} |
297 registeredInterfaces = {} |
300 for language in self.__debuggerInterfaceRegistry: |
298 for interfaceName in self.__debuggerInterfaces: |
301 registeredInterfaces[language] = \ |
299 registeredInterfaces[interfaceName] = \ |
302 self.__debuggerInterfaceRegistry[language][-1] |
300 self.__debuggerInterfaces[interfaceName] |
303 # last entry is the registry data function |
301 |
304 |
302 self.__debuggerInterfaces = {} |
305 self.__debuggerInterfaceRegistry = {} |
303 self.__debuggerInterfaceRegistry = {} |
306 for language, getRegistryData in registeredInterfaces.items(): |
304 for interfaceName, getRegistryData in registeredInterfaces.items(): |
307 self.registerDebuggerInterface(language, getRegistryData) |
305 self.registerDebuggerInterface(interfaceName, getRegistryData) |
308 |
306 |
309 def registerDebuggerInterface(self, name, getRegistryData): |
307 def registerDebuggerInterface(self, interfaceName, getRegistryData): |
310 """ |
308 """ |
311 Public method to register a debugger interface. |
309 Public method to register a debugger interface. |
312 |
310 |
313 @param name name of the debugger interface |
311 @param interfaceName name of the debugger interface |
314 @type str |
312 @type str |
315 @param getRegistryData reference to a function to be called |
313 @param getRegistryData reference to a function to be called |
316 to get the debugger interface details. This method shall |
314 to get the debugger interface details. This method shall |
317 return the client language, the client capabilities, the |
315 return the client language, the client capabilities, the |
318 list of associated file extensions and a function reference |
316 list of associated file extensions and a function reference |
319 to create the debugger interface (see __createDebuggerInterface()) |
317 to create the debugger interface (see __createDebuggerInterface()) |
320 @type function |
318 @type function |
321 """ |
319 """ |
322 # TODO: remove the 'name' parameter and move the check below against |
320 if interfaceName in self.__debuggerInterfaces: |
323 # clientLanguage |
|
324 if name in self.__debuggerInterfaceRegistry: |
|
325 E5MessageBox.warning( |
321 E5MessageBox.warning( |
326 None, |
322 None, |
327 self.tr("Register Debugger Interface"), |
323 self.tr("Register Debugger Interface"), |
328 self.tr("""<p>The debugger interface <b>{0}</b> has already""" |
324 self.tr("""<p>The debugger interface <b>{0}</b> has already""" |
329 """ been registered. Ignoring this request.</p>""")) |
325 """ been registered. Ignoring this request.</p>""")) |
330 return |
326 return |
331 |
327 |
332 # TODO: change getRegistryData to return a list of registry entries |
328 registryDataList = getRegistryData() |
333 clientLanguage, clientCapabilities, clientExtensions, \ |
329 if registryDataList: |
334 interfaceCreator = getRegistryData() |
330 self.__debuggerInterfaces[interfaceName] = getRegistryData |
335 if clientLanguage: |
331 for clientLanguage, clientCapabilities, clientExtensions, \ |
336 self.__debuggerInterfaceRegistry[clientLanguage] = \ |
332 interfaceCreator in registryDataList: |
337 [clientCapabilities, clientExtensions, interfaceCreator, |
333 self.__debuggerInterfaceRegistry[clientLanguage] = [ |
338 getRegistryData] |
334 clientCapabilities, clientExtensions, interfaceCreator, |
339 |
335 interfaceName] |
340 def unregisterDebuggerInterface(self, name): |
336 |
|
337 def unregisterDebuggerInterface(self, interfaceName): |
341 """ |
338 """ |
342 Public method to unregister a debugger interface. |
339 Public method to unregister a debugger interface. |
343 |
340 |
344 @param name name of the debugger interface |
341 @param interfaceName interfaceName of the debugger interface |
345 @type str |
342 @type str |
346 """ |
343 """ |
347 # TODO: change name to a list of names |
344 if interfaceName in self.__debuggerInterfaces: |
348 if name in self.__debuggerInterfaceRegistry: |
345 clientLanguages = [] |
349 del self.__debuggerInterfaceRegistry[name] |
346 for clientLanguage, registryData in \ |
|
347 self.__debuggerInterfaceRegistry.items(): |
|
348 if interfaceName == registryData[-1]: |
|
349 clientLanguages.append(clientLanguage) |
|
350 for clientLanguage in clientLanguages: |
|
351 del self.__debuggerInterfaceRegistry[clientLanguage] |
|
352 del self.__debuggerInterfaces[interfaceName] |
350 |
353 |
351 def __findLanguageForExtension(self, ext): |
354 def __findLanguageForExtension(self, ext): |
352 """ |
355 """ |
353 Private method to get the language associated with a file extension. |
356 Private method to get the language associated with a file extension. |
354 |
357 |
365 |
368 |
366 def __registerDebuggerInterfaces(self): |
369 def __registerDebuggerInterfaces(self): |
367 """ |
370 """ |
368 Private method to register the available internal debugger interfaces. |
371 Private method to register the available internal debugger interfaces. |
369 """ |
372 """ |
370 # TODO: apply DebuggerInterfaces being a list |
|
371 for name, interface in DebuggerInterfaces.items(): |
373 for name, interface in DebuggerInterfaces.items(): |
372 modName = "Debugger.{0}".format(interface) |
374 modName = "Debugger.{0}".format(interface) |
373 mod = __import__(modName) |
375 mod = __import__(modName) |
374 components = modName.split('.') |
376 components = modName.split('.') |
375 for comp in components[1:]: |
377 for comp in components[1:]: |
376 mod = getattr(mod, comp) |
378 mod = getattr(mod, comp) |
377 |
379 |
378 # TODO: remove name parameter |
|
379 self.registerDebuggerInterface(name, mod.getRegistryData) |
380 self.registerDebuggerInterface(name, mod.getRegistryData) |
380 |
381 |
381 def getSupportedLanguages(self, shellOnly=False): |
382 def getSupportedLanguages(self, shellOnly=False): |
382 """ |
383 """ |
383 Public slot to return the supported programming languages. |
384 Public slot to return the supported programming languages. |