Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckService.py

changeset 3591
2f2a4a76dd22
parent 3525
66f4b8646622
child 3656
441956d8fce5
equal deleted inserted replaced
3590:5280e37405b8 3591:2f2a4a76dd22
29 """ 29 """
30 syntaxChecked = pyqtSignal(str, dict) 30 syntaxChecked = pyqtSignal(str, dict)
31 31
32 def __init__(self): 32 def __init__(self):
33 """ 33 """
34 Contructor of SyntaxCheckService. 34 Constructor
35 """ 35 """
36 super(SyntaxCheckService, self).__init__() 36 super(SyntaxCheckService, self).__init__()
37 self.backgroundService = e5App().getObject("BackgroundService") 37 self.backgroundService = e5App().getObject("BackgroundService")
38 self.__supportedLanguages = {} 38 self.__supportedLanguages = {}
39 39
56 return None 56 return None
57 57
58 def addLanguage( 58 def addLanguage(
59 self, lang, env, path, module, getArgs, getExt, callback, onError): 59 self, lang, env, path, module, getArgs, getExt, callback, onError):
60 """ 60 """
61 Register the new language to the supported languages. 61 Public method to register a new language to the supported languages.
62 62
63 @param lang new language to check syntax (str) 63 @param lang new language to check syntax (str)
64 @param env the environment in which the checker is implemented (str) 64 @param env the environment in which the checker is implemented (str)
65 @param path full path to the module (str) 65 @param path full path to the module (str)
66 @param module name to import (str) 66 @param module name to import (str)
77 self.backgroundService.serviceConnect( 77 self.backgroundService.serviceConnect(
78 '{0}Syntax'.format(lang), env, path, module, callback, onError) 78 '{0}Syntax'.format(lang), env, path, module, callback, onError)
79 79
80 def getLanguages(self): 80 def getLanguages(self):
81 """ 81 """
82 Return the supported language names. 82 Public method to return the supported language names.
83 83
84 @return list of languanges supported (list of str) 84 @return list of languanges supported (list of str)
85 """ 85 """
86 return list(self.__supportedLanguages.keys()) 86 return list(self.__supportedLanguages.keys())
87 87
88 def removeLanguage(self, lang): 88 def removeLanguage(self, lang):
89 """ 89 """
90 Remove the language from syntax check. 90 Public method to remove the language from syntax check.
91 91
92 @param lang language to remove (str) 92 @param lang language to remove (str)
93 """ 93 """
94 self.__supportedLanguages.pop(lang, None) 94 self.__supportedLanguages.pop(lang, None)
95 self.backgroundService.serviceDisconnect( 95 self.backgroundService.serviceDisconnect(
96 '{0}Syntax'.format(lang), lang) 96 '{0}Syntax'.format(lang), lang)
97 97
98 def getExtensions(self): 98 def getExtensions(self):
99 """ 99 """
100 Return all supported file extensions for the syntax checker dialog. 100 Public method to return all supported file extensions for the
101 syntax checker dialog.
101 102
102 @return set of all supported file extensions (set of str) 103 @return set of all supported file extensions (set of str)
103 """ 104 """
104 extensions = set() 105 extensions = set()
105 for env, getArgs, getExt in self.__supportedLanguages.values(): 106 for env, getArgs, getExt in self.__supportedLanguages.values():
107 extensions.add(ext) 108 extensions.add(ext)
108 return extensions 109 return extensions
109 110
110 def syntaxCheck(self, lang, filename, source): 111 def syntaxCheck(self, lang, filename, source):
111 """ 112 """
112 Method to prepare to compile one Python source file to Python bytecode 113 Public method to prepare to compile one Python source file to Python
113 and to perform a pyflakes check in another task. 114 bytecode and to perform a pyflakes check.
114 115
115 @param lang language of the file or None to determine by internal 116 @param lang language of the file or None to determine by internal
116 algorithm (str or None) 117 algorithm (str or None)
117 @param filename source filename (string) 118 @param filename source filename (string)
118 @param source string containing the code to check (string) 119 @param source string containing the code to check (string)

eric ide

mercurial