Repository navigation
Expand file tree
/
Copy pathlinter.py
More file actions
78 lines (60 loc) · 2.02 KB
/
Copy pathlinter.py
File metadata and controls
78 lines (60 loc) · 2.02 KB
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
###
# Erlang linter plugin for SublimeLinter3
# Uses erlc, make sure it is in your PATH
#
# Copyright (C) 2014 Clement 'cmc' Rey <cr.rey.clement@gmail.com>
#
# MIT License
###
"""This module exports the Erlc plugin class."""
from SublimeLinter.lint import Linter, util
class Erlc(Linter):
"""Provides an interface to erlc."""
tempfile_suffix = "-"
# ERROR FORMAT # <file>:<line>: [Warning:|] <message> #
# ERROR FORMAT # <file>:<line>:<col>: [Warning:|] <message> #
regex = (
r"^.+?:(?P<line>\d+):(?:(?P<col>\d+):)?"
r"(?:(?P<warning>\sWarning:\s)|(?P<error>\s))+"
r"(?P<message>.+)"
)
error_stream = util.STREAM_STDERR
defaults = {
"selector": "source.erlang",
"-I": [],
"-pa": [],
"-pz": [],
"-o": ".",
}
def cmd(self):
"""
return the command line to execute.
this func is overridden so we can handle included directories.
"""
command = ['erlc', '-W', '${args}']
settings = self.settings
dirs = settings.get('include_dirs', [])
pa_dirs = settings.get('pa_dirs', [])
pz_dirs = settings.get('pz_dirs', [])
output_dir = settings.get('output_dir', ".")
if dirs:
self.logger.warn(
"Setting 'include_dirs' has been renamed to just 'I'.")
if pa_dirs:
self.logger.warn(
"Setting 'pa_dirs' has been renamed to just 'pa'.")
if pz_dirs:
self.logger.warn(
"Setting 'pz_dirs' has been renamed to just 'pz'.")
if "output_dir" in settings and output_dir != ".":
self.logger.warn(
"Setting 'output_dir' has been renamed to just 'o'.")
for d in dirs:
command.extend(["-I", d])
for d in pa_dirs:
command.extend(["-pa", d])
for d in pz_dirs:
command.extend(["-pz", d])
command.extend(["-o", output_dir])
command.extend(["${file_on_disk}"])
return command