Skip to content

Commit

Permalink
highlight errors
Browse files Browse the repository at this point in the history
  • Loading branch information
swr1bm86 committed Sep 7, 2016
1 parent 5d8bc04 commit 22bcc5c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
30 changes: 28 additions & 2 deletions lib/idris-controller.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Symbol = require './utils/symbol'
editorHelper = require './utils/editor'

class IdrisController
errorMarkers: []

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

isIdrisFile: (uri) ->
uri?.match? /\.idr$/

createMarker: (editor, range, type) ->
marker = editor.markBufferRange(range, invalidate: 'never')
editor.decorateMarker marker,
type: type
class: 'highlight-idris-error'
marker

destroyMarkers: () ->
for marker in @errorMarkers
marker.destroy()

destroy: ->
if @model
Expand All @@ -44,6 +56,7 @@ class IdrisController
editor.getTextInBufferRange cursorPosition

initialize: (compilerOptions) ->
@destroyMarkers()
if !@model
@model = new IdrisModel
@messages = new MessagePanelView
Expand Down Expand Up @@ -416,9 +429,22 @@ class IdrisController
className: 'idris-error'

for warning in err.warnings
line = warning[1][0]
character = warning[1][1]
@messages.add new LineMessageView
line: warning[1][0]
character: warning[1][1]
line: line
character: character
message: warning[3]

editor = atom.workspace.getActiveTextEditor()
if line > 0 && warning[0].replace("./", err.cwd + "/") == editor.getURI()
startPoint = warning[1]
startPoint[0] = startPoint[0] - 1
endPoint = warning[2]
endPoint[0] = endPoint[0] - 1
gutterMarker = @createMarker editor, [startPoint, endPoint], 'line-number'
lineMarker = @createMarker editor, [[line - 1, character - 1], [line, 0]], 'line'
@errorMarkers.push gutterMarker
@errorMarkers.push lineMarker

module.exports = IdrisController
1 change: 1 addition & 0 deletions lib/idris-model.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class IdrisModel
message: ret[1]
warnings: @warnings[id]
highlightInformation: ret[2]
cwd: @compilerOptions.src
subject.onCompleted()
delete @subjects[id]
when ':write-string'
Expand Down
21 changes: 21 additions & 0 deletions styles/highlight.atom-text-editor.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@import "syntax-variables";

@red-color: @syntax-color-removed;

atom-text-editor::shadow
{
.gutter .line-number
{
&.highlight-idris-error
{
background-color: @red-color;
}
}
.line
{
&.highlight-idris-error
{
background-color: lighten(@red-color, 20%);
}
}
}

0 comments on commit 22bcc5c

Please sign in to comment.