forked from SublimeLinter/SublimeLinter-javac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinter.py
72 lines (55 loc) · 1.65 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
#
# linter.py
# Linter for SublimeLinter3, a code checking framework for Sublime Text 3
#
# Written by Aparajita Fishman
# Copyright (c) 2013 Aparajita Fishman
#
# License: MIT
#
"""This module exports the Javac plugin class."""
from SublimeLinter.lint import Linter, util
class Javac(Linter):
"""Provides an interface to javac."""
syntax = 'java'
executable = 'javac'
version_args = '-version'
version_re = r'(?P<version>\d+\.\d+\.\d+)'
version_requirement = '>= 1.7'
regex = (
r'^(?P<file>.+?):(?P<line>\d+): '
r'(?:(?P<error>error)|(?P<warning>warning)): '
r'(?:\[.+?\] )?(?P<message>[^\r\n]+)\r?\n'
r'[^\r\n]+\r?\n'
r'(?P<col>[^\^]*)\^'
)
multiline = True
tempfile_suffix = '-'
error_stream = util.STREAM_STDERR
defaults = {
'lint': ''
}
inline_settings = 'lint'
comment_re = r'\s*/[/*]'
def cmd(self):
"""
Return the command line to execute.
We override this because we have to munge the -Xlint argument
based on the 'lint' setting.
"""
xlint = '-Xlint'
settings = self.get_view_settings()
options = settings.get('lint')
if options:
xlint += ':' + options
return (self.executable_path, xlint, '*')
def split_match(self, match):
"""
Return the components of the match.
We override this because javac lints all referenced files,
and we only want errors from the linted file.
"""
if match:
if match.group('file') != self.filename:
match = None
return super().split_match(match)