-
Notifications
You must be signed in to change notification settings - Fork 20
/
linter.py
61 lines (51 loc) · 1.78 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
#
# linter.py
# Linter for SublimeLinter3, a code checking framework for Sublime Text 3
#
# Written by William Meldon
# Copyright (c) 2013 William Meldon
# https://github.com/WMeldon/SublimeLinter-apiblueprint
#
# Modified by Zdenek Nemec
#
# License: MIT
"""This module exports the Apiblueprint plugin class."""
def ApiBlueprintFactory():
""" Define API Blueprint Linter Class"""
class ApiBlueprint(Linter):
"""Provides an interface to apiblueprint."""
syntax = 'apiblueprint'
cmd = 'drafter --validate'
executable = 'drafter'
executable = None
regex = (
r'(?:(?P<warning>warning)|(?P<error>error)):\s*\((?P<code>\d+)\)'
r'(?P<message>.+?)(?::|$)'
r'(?P<line>\d+):(?P<col>\d+)(?:.*)'
)
multiline = False
line_col_base = (0, 0)
tempfile_suffix = None
error_stream = util.STREAM_BOTH
selectors = {}
word_re = None
defaults = {}
inline_settings = None
inline_overrides = None
comment_re = None
def split_match(self, match):
"""
Run default match. If match is found, convert line variable to line number
and adjust col.
"""
match, line, col, error, warning, message, near = super().split_match(match)
if line is not None:
line, col = self.view.rowcol((int(line)))
line = int(line) - self.line_col_base[0]
return match, line, col, error, warning, message, near
try:
"""Attempt to import SublimeLinter3"""
from SublimeLinter.lint import Linter, util
ApiBlueprintFactory()
except ImportError:
print("No SublimeLinter3 installed - Install SublimeLinter3 to lint your API blueprints (ST3 Only)")