Skip to content

Commit a6fc658

Browse files
author
Monte Goulding
committed
Some changes to the linter to support column number in error and scope option so we can eventually work out how we can run the linter on server files
1 parent d13a6f6 commit a6fc658

File tree

2 files changed

+45
-25
lines changed

2 files changed

+45
-25
lines changed

lib/main.coffee

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports =
2121
provideLinter: ->
2222
helpers = require('atom-linter')
2323
provider =
24-
grammarScopes: ['source.livecodescript']
24+
grammarScopes: ['source.livecodescript', 'source.iRev']
2525
scope: 'file'
2626
lintOnFly: true
2727
lint: (textEditor) =>
@@ -31,14 +31,16 @@ module.exports =
3131
parameters.push('-ui')
3232
stackfile = @linterPath
3333
parameters.push(stackfile)
34+
scope = '-scope=' + textEditor.getRootScopeDescriptor()
35+
parameters.push(scope)
3436
text = textEditor.getText()
3537
return helpers.exec(command, parameters, {stdin: text}).then (output) ->
36-
regex = /(\d+),(.*)/g
38+
regex = /(\d+),(\d+),(.*)/g
3739
messages = []
3840
while((match = regex.exec(output)) isnt null)
3941
messages.push
4042
type: "Error"
4143
filePath: filePath
42-
range: helpers.rangeFromLineNumber(textEditor, match[1]-1)
43-
text: match[2]
44+
range: [[match[1]-1, match[2]-0],[match[1]-1, textEditor.getBuffer().lineLengthForRow(match[1]-1)]]
45+
text: match[3]
4446
return messages

tools/Linter.livecodescript

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,44 @@
11
script "Linter"
22

3+
local sErrorsList
4+
35
on startup
46
try
5-
read from stdin until empty
6-
put it into theScript
7+
local tScope
8+
repeat for each element theArgument in the commandArguments
9+
if theArgument begins with "-scope" then
10+
split theArgument with "="
11+
put theArgument[2] into tScope
12+
end if
13+
end repeat
714

8-
local isScriptOnly = false
9-
if word 1 of theScript is "script" then
10-
put true into isScriptOnly
11-
end if
15+
read from stdin until empty
16+
put it into tScript
1217

1318
put the filename of me into theFilename
1419
set the itemDelimiter to slash
1520
put "scriptErrors.txt" into item -1 of theFilename
16-
put url ("file:"&theFilename) into theErrorsList
21+
put url ("file:"&theFilename) into sErrorsList
22+
split sErrorsList with return
1723

1824
create script only stack "TestScript"
1925

20-
if isScriptOnly then
21-
delete line 1 of theScript
22-
end if
23-
24-
set the script of stack "TestScript" to theScript
26+
if tScope is empty or tScope is ".source.livecodescript" then
27+
local tLineOffset = 0
2528

26-
put the result into theErrors
27-
set the itemDelimiter to comma
29+
-- check for script only
30+
if word 1 of tScript is "script" then
31+
put 1 into tLineOffset
32+
end if
2833

29-
repeat for each line theError in theErrors
30-
if theError is not empty then
31-
if isScriptOnly then
32-
add 1 to item 2 of theError
33-
end if
34-
write item 2 of theError, line (item 1 of theError) of theErrorsList & linefeed to stdout
34+
if tLineOffset is 1 then
35+
delete line 1 of tScript
3536
end if
36-
end repeat
37+
38+
LintScript tScript, tLineOffset
39+
else if tScope is ".source.iRev" then
40+
41+
end if
3742

3843
write linefeed to stdout
3944
catch e
@@ -42,3 +47,16 @@ on startup
4247

4348
quit
4449
end startup
50+
51+
command LintScript pScript, pLineOffset
52+
set the script of stack "TestScript" to pScript
53+
54+
put the result into theErrors
55+
set the itemDelimiter to comma
56+
57+
repeat for each line theError in theErrors
58+
if theError is not empty then
59+
write item 2 of theError + pLineOffset, item 3 of theError, sErrorsList[item 1 of theError] & linefeed to stdout
60+
end if
61+
end repeat
62+
end LintScript

0 commit comments

Comments
 (0)