-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlinter.py
45 lines (35 loc) · 1.37 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
#
# linter.py
# Linter for SublimeLinter, a code checking framework for Sublime Text 3
#
# Written by Adam Cadamally
# Copyright (c) 2014 Adam Cadamally
#
# License: MIT
#
"""This module exports the Dxl plugin class."""
from SublimeLinter.lint import Linter, util
from os.path import abspath, dirname, join, isfile
def LinterPath():
"""Ascertain the dxl.exe path from this .py files path because sublime.packages_path is unavailable at startup."""
ThisPath = abspath(dirname(__file__))
if isfile(ThisPath):
# We are in a .sublime-package file in the 'Installed Package' folder
return abspath(join(ThisPath, '..', '..', 'Packages', 'DXL', 'Lint', 'dxl.exe'))
else:
# We are in a subfolder of the 'Packages' folder
return abspath(join(ThisPath, '..', 'DXL', 'Lint', 'dxl.exe'))
LINTER_PATH = LinterPath()
class Dxl(Linter):
"""Provides an interface to dxl."""
defaults = {
'selector': 'source.dxl'
}
cmd = [LINTER_PATH]
regex = (
r'^-(?:(?P<error>E)|(?P<warning>W))- DXL:'
r' <(?P<path>.*?):(?P<line>[0-9]+)> '
r'''(?P<message>(?:undeclared variable|badly formed token|incorrect arguments? for(?: function)|Invalid '//<Requires>' syntax: Expected '#include '|could not (?:open|run) include file) \((?P<near>.*?)\).*|.*)'''
)
tempfile_suffix = 'dxl'
error_stream = util.STREAM_STDOUT