Skip to content

Commit

Permalink
Support OPTIONS_HADDOCK pragma
Browse files Browse the repository at this point in the history
  * Adds a test for JustusAdam#165, updates the test for JustusAdam#153
  • Loading branch information
sheaf committed Jun 13, 2020
1 parent 4b700e9 commit 0aa06bf
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
- Fix highlighting for GADT with where clause using `{`/`}` for indentation.
- Improve highlighting of existential data constructor in complex situations.
- Fix highlighting of symbolic pattern declarations and symbolic data constructors.
- Improvements to highlighting of pragmas [#163](https://github.com/JustusAdam/language-haskell/issues/163).
- Improvements to highlighting of pragmas [#163](https://github.com/JustusAdam/language-haskell/issues/163),
including support for Haddock options.
- Fix highlighting of record at syntax following an identifier that ends with an apostrophe.
- Improve highlighting of symbolic constructors in import/export lists.

Expand Down
2 changes: 1 addition & 1 deletion syntaxes/haskell.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ repository:
- match: >-
(?xi)
\b(?<!')
(LANGUAGE|OPTIONS_GHC|INCLUDE
(LANGUAGE|OPTIONS_GHC|OPTIONS_HADDOCK|OPTIONS|INCLUDE
|MINIMAL|UNPACK|OVERLAPS|INCOHERENT
|NOUNPACK|SOURCE|OVERLAPPING|OVERLAPPABLE|INLINE
|NOINLINE|INLINE?ABLE|CONLIKE|LINE|COLUMN|RULES
Expand Down
2 changes: 2 additions & 0 deletions test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ tickets=($PWD/tickets/*)
# Arrays containing filenames of broken tests.
namedBroken=()
ticketsBroken=(
"T0153.hs"
"T0165.hs"
)

# Colours used to display test outputs.
Expand Down
5 changes: 5 additions & 0 deletions test/tests/Haddocks.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
-- SYNTAX TEST "source.haskell" "Haddock documentation"

{-# OPTIONS_HADDOCK ignore-exports #-}
-- ^^^^^^^^^^^^^^^ keyword.other.preprocessor.haskell
-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preprocessor.haskell


-- | Doc
-- ^^^ comment.block.documentation.haskell

Expand Down
7 changes: 7 additions & 0 deletions test/tickets/T0153.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
-- ^^^ constant.other.haskell
-- ^ ^ ^ variable.other.generic-type.haskell
-- ^ ^ ^ storage.type.haskell
data E x =C x=> Bar x A
-- ^^^^ keyword.other.data.haskell
-- ^ keyword.operator.eq.haskell
-- ^^ keyword.operator.big-arrow.haskell
-- ^^^ constant.other.haskell
-- ^ ^ ^ variable.other.generic-type.haskell
-- ^ ^ ^ storage.type.haskell
data E x = forall x. Bar x A
-- ^^^^ keyword.other.data.haskell
-- ^ keyword.operator.eq.haskell
Expand Down
49 changes: 49 additions & 0 deletions test/tickets/T0165.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
-- SYNTAX TEST "source.haskell" "Data constructor constraint arrow in comment"

data D = C {- => X -} X
-- ^ constant.other.haskell
-- ^^ - keyword.operator.big-arrow.haskell
-- ^^^^^^^^^^ comment.block.haskell
-- ^ ^ storage.type.haskell
-- ^ ^ - constant.other.haskell

data D = C {- xxx -} => X
-- ^ ^ storage.type.haskell
-- ^^^^^^^^^ comment.block.haskell
-- ^ constant.other.haskell

data D = C-- => X
-- ^ storage.type.haskell
-- ^ constant.other.haskell
-- ^^ - keyword.operator.big-arrow.haskell
-- ^^^^^^^ comment.line.double-dash.haskell
-- ^^^^^^^^^^ comment.block.haskell
-- ^ - constant.other.haskell

data D = C -- => X
-- ^ storage.type.haskell
-- ^ constant.other.haskell
-- ^^ - keyword.operator.big-arrow.haskell
-- ^^^^^^^ comment.line.double-dash.haskell
-- ^^^^^^^^^^ comment.block.haskell
-- ^ - constant.other.haskell

data QCInst -- A much simplified version of ClsInst
-- See Note [Quantified constraints] in GHC.Tc.Solver.Canonical
= QCI { qci_ev :: CtEvidence -- Always of type forall tvs. context => ty
-- ^^^ constant.other.haskell
-- ^^^^^^ variable.other.member.definition.haskel
-- ^^ keyword.operator.double-colon.haskell
-- ^^^^^^^^^^ storage.type.haskell
-- ^^ - keyword.operator.big-arrow.haskell
-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-dash.haskell

-- Always Given
, qci_tvs :: [TcTyVar] -- The tvs
-- ^^^^^^^ variable.other.member.definition.haskel
, qci_pred :: TcPredType -- The ty
-- ^^^^^^^^ variable.other.member.definition.haskel
, qci_pend_sc :: Bool -- Same as cc_pend_sc flag in CDictCan
-- ^^^^^^^^^^^ variable.other.member.definition.haskel
-- Invariant: True => qci_pred is a ClassPred
}

0 comments on commit 0aa06bf

Please sign in to comment.