-
Notifications
You must be signed in to change notification settings - Fork 56
/
Util.elm
44 lines (29 loc) · 1.07 KB
/
Util.elm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
module Analyser.Messages.Util exposing (blockForShas, compareMessageFile, compareMessageLocation, firstRange, markFixing, messageFile)
import AST.Ranges as AstRanges
import Analyser.Messages.Data as Data
import Analyser.Messages.Types exposing (Message, MessageStatus(..))
import Elm.Syntax.Range exposing (Range, emptyRange)
blockForShas : String -> Message -> Message
blockForShas sha message =
if message.file.version == sha then
{ message | status = Blocked }
else
message
markFixing : Int -> Message -> Message
markFixing x message =
if message.id == x then
{ message | status = Fixing }
else
message
messageFile : Message -> String
messageFile m =
m.file.path
firstRange : Message -> Range
firstRange a =
Data.firstRange a.data |> Maybe.withDefault emptyRange
compareMessageLocation : Message -> Message -> Order
compareMessageLocation a b =
AstRanges.orderByStart (firstRange a) (firstRange b)
compareMessageFile : Message -> Message -> Order
compareMessageFile a b =
compare (messageFile a) (messageFile b)