Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py

changeset 4207
a0c8a7f9839c
parent 4021
195a471c327b
child 4231
0b38613388c9
child 4315
2ebb98e99054
equal deleted inserted replaced
4206:8f0d697e6384 4207:a0c8a7f9839c
15 try: 15 try:
16 from pyflakes.checker import Checker 16 from pyflakes.checker import Checker
17 from pyflakes.messages import ImportStarUsed 17 from pyflakes.messages import ImportStarUsed
18 except ImportError: 18 except ImportError:
19 pass 19 pass
20
21 VcsConflictMarkerRe = re.compile(
22 r"""^<<<<<<< .*?=======.*?>>>>>>> .*?$""",
23 re.MULTILINE | re.DOTALL)
20 24
21 25
22 def initService(): 26 def initService():
23 """ 27 """
24 Initialize the service and return the entry point. 28 Initialize the service and return the entry point.
102 # It also encode the code back to avoid 'Encoding declaration in 106 # It also encode the code back to avoid 'Encoding declaration in
103 # unicode string' exception on Python2 107 # unicode string' exception on Python2
104 codestring = normalizeCode(codestring) 108 codestring = normalizeCode(codestring)
105 109
106 # Check for VCS conflict markers 110 # Check for VCS conflict markers
107 lineindex = 1 111 conflict = VcsConflictMarkerRe.search(codestring)
108 for line in codestring.splitlines(): 112 if conflict is not None:
109 if any(line.startswith(c * 7) for c in "<>=|"): 113 start, i = conflict.span()
110 return [{'error': 114 lineindex = 1 + codestring.count("\n", 0, start)
111 (file_enc, lineindex, 0, "", 115 return [{'error':
112 "VCS conflict marker found") 116 (file_enc, lineindex, 0, "",
113 }] 117 "VCS conflict marker found")
114 lineindex += 1 118 }]
115 119
116 if filename.endswith('.ptl'): 120 if filename.endswith('.ptl'):
117 try: 121 try:
118 import quixote.ptl_compile 122 import quixote.ptl_compile
119 except ImportError: 123 except ImportError:

eric ide

mercurial