Fixes errors being shown in the wrong file
This commit is contained in:
parent
b8ab8ea944
commit
4dd7c5861d
@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.1.2]
|
||||||
|
### Fixes
|
||||||
|
- Errors made in included files will now be correctly located
|
||||||
|
|
||||||
## [0.1.1] - 2017-11-17
|
## [0.1.1] - 2017-11-17
|
||||||
### Fixes
|
### Fixes
|
||||||
- Small fixes to documentation and package definition
|
- Small fixes to documentation and package definition
|
||||||
|
@ -23,10 +23,11 @@ class LinterMZN
|
|||||||
atomLinter.exec(@compilerPath, args, options)
|
atomLinter.exec(@compilerPath, args, options)
|
||||||
.then (result) =>
|
.then (result) =>
|
||||||
{stdout, stderr, exit} = result
|
{stdout, stderr, exit} = result
|
||||||
|
console.log stderr
|
||||||
if exit is 0
|
if exit is 0
|
||||||
[]
|
[]
|
||||||
else
|
else
|
||||||
@parse stderr, textEditor.getPath()
|
@parse stderr
|
||||||
.catch (error) ->
|
.catch (error) ->
|
||||||
console.log error
|
console.log error
|
||||||
atom.notifications.addError "Failed to run #{command}",
|
atom.notifications.addError "Failed to run #{command}",
|
||||||
@ -34,7 +35,7 @@ class LinterMZN
|
|||||||
dismissable: true
|
dismissable: true
|
||||||
[]
|
[]
|
||||||
|
|
||||||
parse: (output, filePath) =>
|
parse: (output) =>
|
||||||
messages = []
|
messages = []
|
||||||
output = output.split('\n')
|
output = output.split('\n')
|
||||||
warningLines = (i for line, i in output when /:([0-9]+):/.test(line) && ! /(did you forget to specify a data file\?)/.test(output[i+1]))
|
warningLines = (i for line, i in output when /:([0-9]+):/.test(line) && ! /(did you forget to specify a data file\?)/.test(output[i+1]))
|
||||||
@ -42,14 +43,16 @@ class LinterMZN
|
|||||||
i = 0
|
i = 0
|
||||||
while i < warningLines.length
|
while i < warningLines.length
|
||||||
if i >= warningLines.length - 1
|
if i >= warningLines.length - 1
|
||||||
messages.push @generateMessage output[warningLines[i]..], filePath
|
messages.push @generateMessage output[warningLines[i]..]
|
||||||
else
|
else
|
||||||
messages.push @generateMessage output[warningLines[i]..warningLines[i+1]-1], filePath
|
messages.push @generateMessage output[warningLines[i]..warningLines[i+1]-1]
|
||||||
i++
|
i++
|
||||||
|
|
||||||
return messages
|
return messages
|
||||||
|
|
||||||
generateMessage: (output, filePath) ->
|
generateMessage: (output) ->
|
||||||
|
file = output[0].match(/^[^:]*/)[0]
|
||||||
|
console.log file
|
||||||
match = output[0].match(/:([0-9]+):/)
|
match = output[0].match(/:([0-9]+):/)
|
||||||
line = parseInt(match[1])
|
line = parseInt(match[1])
|
||||||
output = output[1..]
|
output = output[1..]
|
||||||
@ -63,9 +66,9 @@ class LinterMZN
|
|||||||
|
|
||||||
message = {
|
message = {
|
||||||
severity: 'error',
|
severity: 'error',
|
||||||
excerpt: output.join('\n').replace(/MiniZinc: /, ""),
|
excerpt: output.join('\n').replace(/MiniZinc: /, "").replace(/Error: /, ""),
|
||||||
location:{
|
location:{
|
||||||
file: filePath,
|
file: file,
|
||||||
position: [[line-1,startcol], [line-1,endcol]],
|
position: [[line-1,startcol], [line-1,endcol]],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user