forked from nixel2007/sublime-language-1c-bsl
-
Notifications
You must be signed in to change notification settings - Fork 2
/
linter.py
47 lines (38 loc) · 1.66 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
"""This module exports the OneScriptLint plugin class."""
import sublime
import os
from SublimeLinter.lint import Linter, util
def getCommandId():
onescriptPath = sublime.load_settings('Language 1C (BSL).sublime-settings').get('onescriptPath')
if not onescriptPath or len(onescriptPath) == 0:
command = 'oscript'
else:
command = onescriptPath
return command
class OneScriptLint(Linter):
"""Provides an interface to OneScriptLint."""
syntax = '1c'
cmd_string = getCommandId() + ' -encoding=utf-8 -check @'
cmd = (cmd_string)
regex = r'\{\S+\s+(?P<error>.*)\s\/\s.*:\s+(?P<line>\d+)\s+\/\s+(?P<message>.*)\}'
error_stream = util.STREAM_BOTH
comment_re = r'\s*//'
def run(self, cmd, code):
lintOtherExtensions = sublime.load_settings('Language 1C (BSL).sublime-settings').get('lintOtherExtensions')
linterEntryPoint = sublime.load_settings('Language 1C (BSL).sublime-settings').get('linterEntryPoint')
filePath = self.filename
arrFilePath = filePath.split('.')
if len(arrFilePath) == 0:
return
extension = arrFilePath[len(arrFilePath) - 1];
if not extension == 'os' and lintOtherExtensions.find(extension) == -1:
return
if not linterEntryPoint == '':
project_path = ''
projectPaths = sublime.active_window().folders()
for projectPath in projectPaths:
if filePath.find(projectPath) > -1:
project_path = projectPath;
break
cmd.append("-env=" + os.path.join(project_path, linterEntryPoint))
return self.communicate(cmd, code)