Skip to content

Commit b7a141b

Browse files
committed
highlight errors
1 parent 5d8bc04 commit b7a141b

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

lib/idris-controller.coffee

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Symbol = require './utils/symbol'
99
editorHelper = require './utils/editor'
1010

1111
class IdrisController
12+
errorMarkers: []
1213

1314
getCommands: ->
1415
'language-idris:type-of': @runCommand @getTypeForWord
@@ -28,6 +29,17 @@ class IdrisController
2829

2930
isIdrisFile: (uri) ->
3031
uri?.match? /\.idr$/
32+
33+
createMarker: (editor, range, type) ->
34+
marker = editor.markBufferRange(range, invalidate: 'never')
35+
editor.decorateMarker marker,
36+
type: type
37+
class: 'highlight-idris-error'
38+
marker
39+
40+
destroyMarkers: () ->
41+
for marker in @errorMarkers
42+
marker.destroy()
3143

3244
destroy: ->
3345
if @model
@@ -44,6 +56,7 @@ class IdrisController
4456
editor.getTextInBufferRange cursorPosition
4557

4658
initialize: (compilerOptions) ->
59+
@destroyMarkers()
4760
if !@model
4861
@model = new IdrisModel
4962
@messages = new MessagePanelView
@@ -416,9 +429,22 @@ class IdrisController
416429
className: 'idris-error'
417430

418431
for warning in err.warnings
432+
line = warning[1][0]
433+
character = warning[1][1]
419434
@messages.add new LineMessageView
420-
line: warning[1][0]
421-
character: warning[1][1]
435+
line: line
436+
character: character
422437
message: warning[3]
438+
439+
editor = atom.workspace.getActiveTextEditor()
440+
if warning[0].replace("./", err.cwd + "/") == editor.getURI()
441+
startPoint = warning[1]
442+
startPoint[0] = startPoint[0] - 1
443+
endPoint = warning[2]
444+
endPoint[0] = endPoint[0] - 1
445+
gutterMarker = @createMarker editor, [startPoint, endPoint], 'line-number'
446+
lineMarker = @createMarker editor, [[line - 1, character - 1], [line, 0]], 'line'
447+
@errorMarkers.push gutterMarker
448+
@errorMarkers.push lineMarker
423449

424450
module.exports = IdrisController

lib/idris-model.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class IdrisModel
5353
message: ret[1]
5454
warnings: @warnings[id]
5555
highlightInformation: ret[2]
56+
cwd: @compilerOptions.src
5657
subject.onCompleted()
5758
delete @subjects[id]
5859
when ':write-string'
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@import "syntax-variables";
2+
3+
@red-color: @syntax-color-removed;
4+
5+
atom-text-editor::shadow
6+
{
7+
.gutter .line-number
8+
{
9+
&.highlight-idris-error
10+
{
11+
background-color: @red-color;
12+
}
13+
}
14+
.line
15+
{
16+
&.highlight-idris-error
17+
{
18+
background-color: lighten(@red-color, 20%);
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)