From 1a331f66a4aad420d8e7f52a7b6b776d9b304d32 Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Sat, 13 Feb 2016 10:09:23 -0800 Subject: [PATCH] improve marker positions for schemas and schematron --- lib/init.coffee | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/init.coffee b/lib/init.coffee index e9d050c..fc8d634 100644 --- a/lib/init.coffee +++ b/lib/init.coffee @@ -206,16 +206,13 @@ module.exports = return helpers.exec(@executablePath, params, options) .then (output) => if argSchemaType is '--schematron' - messages = @parseSchematronMessages(output) + messages = @parseSchematronMessages(textEditor, output) else - messages = @parseSchemaMessages(output) + messages = @parseSchemaMessages(textEditor, output) for message in messages message.type = 'Error' message.text = message.text + ' (' + schemaUrl + ')' message.filePath = textEditor.getPath() - # make range the full line - message.range = helpers.rangeFromLineNumber( - textEditor, message.range[0][0], message.range[0][1]) return messages parseMessages: (output) -> @@ -239,12 +236,15 @@ module.exports = }) return messages - parseSchemaMessages: (output) -> + parseSchemaMessages: (textEditor, output) -> helpers ?= require 'atom-linter' regex = '(?.+):(?\\d+): .*: .* : (?.+)' - helpers.parse(output, regex) + messages = helpers.parse(output, regex) + for message in messages + message.range = helpers.rangeFromLineNumber(textEditor, message.range[0][0]) + return messages - parseSchematronMessages: (output) -> + parseSchematronMessages: (textEditor, output) -> XRegExp ?= require('xregexp').XRegExp messages = [] regex = XRegExp( @@ -255,6 +255,6 @@ module.exports = line = parseInt(match.line) - 1 messages.push({ text: match.rule + ': ' + match.message - range: [[line, 0], [line, 0]] + range: helpers.rangeFromLineNumber(textEditor, line) }) return messages