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

make file paths clickable using pattern #3473

Merged
merged 1 commit into from Dec 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/Language/PureScript/AST/SourcePos.hs
Expand Up @@ -33,6 +33,11 @@ displaySourcePos sp =
"line " <> T.pack (show (sourcePosLine sp)) <>
", column " <> T.pack (show (sourcePosColumn sp))

displaySourcePosShort :: SourcePos -> Text
displaySourcePosShort sp =
T.pack (show (sourcePosLine sp)) <>
":" <> T.pack (show (sourcePosColumn sp))

instance A.ToJSON SourcePos where
toJSON SourcePos{..} =
A.toJSON [sourcePosLine, sourcePosColumn]
Expand All @@ -55,12 +60,19 @@ instance NFData SourceSpan

displayStartEndPos :: SourceSpan -> Text
displayStartEndPos sp =
"(" <>
displaySourcePos (spanStart sp) <> " - " <>
displaySourcePos (spanEnd sp)
displaySourcePos (spanEnd sp) <> ")"

displayStartEndPosShort :: SourceSpan -> Text
displayStartEndPosShort sp =
displaySourcePosShort (spanStart sp) <> " - " <>
displaySourcePosShort (spanEnd sp)

displaySourceSpan :: FilePath -> SourceSpan -> Text
displaySourceSpan relPath sp =
T.pack (makeRelative relPath (spanName sp)) <> " " <>
T.pack (makeRelative relPath (spanName sp)) <> ":" <>
displayStartEndPosShort sp <> " " <>
displayStartEndPos sp

instance A.ToJSON SourceSpan where
Expand Down