Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckService.py

branch
BgService
changeset 3412
9364dab2d472
parent 3241
957673fc463a
child 3418
27ab90e0f25e
equal deleted inserted replaced
3241:957673fc463a 3412:9364dab2d472
22 Implement the syntax check service. 22 Implement the syntax check service.
23 23
24 Plugins can add other languages to the syntax check by calling addLanguage 24 Plugins can add other languages to the syntax check by calling addLanguage
25 and support of an extra checker module on the client side which has to 25 and support of an extra checker module on the client side which has to
26 connect directly to the background service. 26 connect directly to the background service.
27
28 @signal syntaxChecked(str, dict) emited when the syntax check was done.
27 """ 29 """
28 syntaxChecked = pyqtSignal(str, bool, int, int, str, str, list) 30 syntaxChecked = pyqtSignal(str, dict)
29 31
30 def __init__(self): 32 def __init__(self):
31 """ 33 """
32 Contructor of SyntaxCheckService. 34 Contructor of SyntaxCheckService.
33
34 @param backgroundService to connect to (BackgroundService class)
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
40 def __determineLanguage(self, filename, source): 40 def __determineLanguage(self, filename, source):
41 """ 41 """
42 Private methode to determine the language of the file. 42 Private methode to determine the language of the file.
43 43
44 @param filename of the sourcefile (str)
45 @param source code of the file (str)
44 @return language of the file or None if not found (str or None) 46 @return language of the file or None if not found (str or None)
45 """ 47 """
46 pyVer = determinePythonVersion(filename, source) 48 pyVer = determinePythonVersion(filename, source)
47 if pyVer: 49 if pyVer:
48 return 'Python{0}'.format(pyVer) 50 return 'Python{0}'.format(pyVer)
101 for getArgs, getExt in self.__supportedLanguages.values(): 103 for getArgs, getExt in self.__supportedLanguages.values():
102 for ext in getExt(): 104 for ext in getExt():
103 extensions.add(ext) 105 extensions.add(ext)
104 return extensions 106 return extensions
105 107
106 def syntaxCheck(self, lang, filename, source=""): 108 def syntaxCheck(self, lang, filename, source):
107 """ 109 """
108 Method to prepare to compile one Python source file to Python bytecode 110 Method to prepare to compile one Python source file to Python bytecode
109 and to perform a pyflakes check in another task. 111 and to perform a pyflakes check in another task.
110 112
111 @param lang language of the file or None to determine by internal 113 @param lang language of the file or None to determine by internal
112 algorithm (str or None) 114 algorithm (str or None)
113 @param filename source filename (string) 115 @param filename source filename (string)
114 @keyparam source string containing the code to check (string) 116 @param source string containing the code to check (string)
115 """ 117 """
116 if not lang: 118 if not lang:
117 lang = self.__determineLanguage(filename, source) 119 lang = self.__determineLanguage(filename, source)
118 if lang not in self.getLanguages(): 120 if lang not in self.getLanguages():
119 return 121 return

eric ide

mercurial