Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

highlight errors #124

Merged
merged 1 commit into from
Sep 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 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,10 +429,25 @@ class IdrisController
className: 'idris-error'

for warning in err.warnings
line = warning[1][0]
character = warning[1][1]
uri = warning[0].replace("./", err.cwd + "/")

@messages.add new LineMessageView
line: warning[1][0]
character: warning[1][1]
line: line
character: character
message: warning[3]
file: warning[0].replace("./", err.cwd + "/")
file: uri

editor = atom.workspace.getActiveTextEditor()
if line > 0 && uri == 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
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%);
}
}
}