-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlinter.py
85 lines (73 loc) · 2.04 KB
/
linter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#
# linter.py
# Linter for SublimeLinter4, a code checking framework for Sublime Text 3
#
# Written by nirm03
# Copyright (c) 2013 nirm03
#
# License: MIT
#
"""This module exports the Clang plugin class."""
import re
from SublimeLinter.lint import Linter
OUTPUT_RE = re.compile(
r'<stdin>:(?P<line>\d+):'
r'((?P<col>\d*): )?' # column number, colon and space are only applicable for single line messages
# several lines of anything followed by
# either error/warning/note or newline (= irrelevant backtrace content)
# (lazy quantifiers so we don’t skip what we seek)
r'(.*?((?P<error>error)|(?P<warning>warning|note)|\r?\n))+?'
r': (?P<message>.+)', # match the remaining content of the current line for output
re.MULTILINE
)
class Clang(Linter):
cmd = 'clang ${args} -'
defaults = {
'selector': 'source.c',
'args': '-Wall -fsyntax-only -fno-caret-diagnostics',
'-I +': [],
'-isystem +': [],
'-x': 'c'
}
regex = OUTPUT_RE
multiline = True
on_stderr = None
class ClangPlus(Linter):
name = 'clang++'
cmd = 'clang ${args} -'
defaults = {
'selector': 'source.c++',
'args': '-Wall -fsyntax-only -fno-caret-diagnostics',
'-I +': [],
'-isystem +': [],
'-x': 'c++'
}
regex = OUTPUT_RE
multiline = True
on_stderr = None
class ClangObjC(Linter):
name = 'clang-objc'
cmd = 'clang ${args} -'
defaults = {
'selector': 'source.objc',
'args': '-Wall -fsyntax-only -fno-caret-diagnostics -fobjc-arc',
'-I +': [],
'-isystem +': [],
'-x': 'objective-c'
}
regex = OUTPUT_RE
multiline = True
on_stderr = None
class ClangObjCPlus(Linter):
name = 'clang-objc++'
cmd = 'clang ${args} -'
defaults = {
'selector': 'source.objc++',
'args': '-Wall -fsyntax-only -fno-caret-diagnostics -fobjc-arc',
'-I +': [],
'-isystem +': [],
'-x': 'objective-c++'
}
regex = OUTPUT_RE
multiline = True
on_stderr = None