Archived
1
0

Adds disabling of linting

This commit is contained in:
Jip J. Dekker 2016-01-18 21:18:55 +01:00
parent 68ba9ee827
commit deb978614c
2 changed files with 30 additions and 23 deletions

View File

@ -2,10 +2,14 @@
module.exports = AtomLanguageMZN = module.exports = AtomLanguageMZN =
config: config:
enableLinter:
type: 'boolean'
default: true
description: "Enable linting using `mzn2fzn`"
mzn2fznPath: mzn2fznPath:
type: 'string' type: 'string'
default: 'mzn2fzn' default: 'mzn2fzn'
description: "Path to Minizinc's compiler `mzn2fzn`" description: 'Path to Minizinc\'s compiler `mzn2fzn`'
activate: (state) -> activate: (state) ->
console.log 'language-mzn: package loaded, console.log 'language-mzn: package loaded,

View File

@ -7,30 +7,33 @@ class LinterMZN
atom.config.get "language-mzn.#{key}" atom.config.get "language-mzn.#{key}"
lint: (textEditor) => lint: (textEditor) =>
return new Promise (resolve, reject) => if @config 'enableLinter'
output = '' return new Promise (resolve, reject) =>
command = @config 'mzn2fznPath' output = ''
args = ['--instance-check-only', textEditor.getPath()] command = @config 'mzn2fznPath'
options = process.env args = ['--instance-check-only', textEditor.getPath()]
options = process.env
stdout = (data) -> stdout = (data) ->
atom.notifications.addWarning data atom.notifications.addWarning data
stderr = (data) -> stderr = (data) ->
output += data output += data
exit = (code) => exit = (code) =>
if code is 0 if code is 0
resolve []
else
messages = @parse output, textEditor.getPath()
resolve messages
@lintProcess = new BufferedProcess({command, args, options, stdout, stderr, exit})
@lintProcess.onWillThrowError ({error, handle}) ->
atom.notifications.addError "Failed to run #{command}",
detail: "#{error.message}"
dismissable: true
handle()
resolve [] resolve []
else else
messages = @parse output, textEditor.getPath() return []
resolve messages
@lintProcess = new BufferedProcess({command, args, options, stdout, stderr, exit})
@lintProcess.onWillThrowError ({error, handle}) ->
atom.notifications.addError "Failed to run #{command}",
detail: "#{error.message}"
dismissable: true
handle()
resolve []
parse: (output, filePath) => parse: (output, filePath) =>
messages = [] messages = []