forked from nixel2007/sublime-language-1c-bsl
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
166 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
{ | ||
"tab_size": 4, | ||
"translate_tabs_to_spaces": false, | ||
"lintBSLFiles": false | ||
"onescriptPath": "", | ||
"lintOtherExtensions": "", | ||
"linterEntryPoint": "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,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 = ('oscript -encoding=utf-8 -check @') | ||
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): | ||
lintBSLFiles = sublime.load_settings('Language 1C (BSL).sublime-settings').get('lintBSLFiles') | ||
if not (self.filename.endswith('.bsl') and not lintBSLFiles): | ||
return self.communicate(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) |