ghcide/test/data/GotoHover.hs
Moritz Kiefer 4f61cb66c9
Fix source spans for multi-clause definitions (#318)
* Fix source spans for multi-clause definitions

Currently, we use the source span of the match which corresponds to
the whole clause instead of just the function identifier. This
resulted in us pointing every goto definition request within a clause
to the function if there is no other information (either because it
failed because it came from an external package or simply because you
are not on an identifier).

This PR fixes this by getting the proper source spans frmo the
HsMatchContext. Somewhat annoyingly, we have to get it from the parsed
module since GHC messes this up during typechecking but it’s
reasonably simple.
2020-01-10 15:37:09 +01:00

51 lines
1.0 KiB
Haskell

{- HLINT ignore -}
module Testing ( module Testing ) where
import Data.Text (Text, pack)
data TypeConstructor = DataConstructor
{ fff :: Text
, ggg :: Int }
aaa :: TypeConstructor
aaa = DataConstructor
{ fff = "dfgy"
, ggg = 832
}
bbb :: TypeConstructor
bbb = DataConstructor "mjgp" 2994
ccc :: (Text, Int)
ccc = (fff bbb, ggg aaa)
ddd :: Num a => a -> a -> a
ddd vv ww = vv +! ww
a +! b = a - b
hhh (Just a) (><) = a >< a
iii a b = a `b` a
jjj s = pack $ s <> s
class MyClass a where
method :: a -> Int
instance MyClass Int where
method = succ
kkk :: MyClass a => Int -> a -> Int
kkk n c = n + method c
doBind :: Maybe ()
doBind = do unwrapped <- Just ()
return unwrapped
listCompBind :: [Char]
listCompBind = [ succ c | c <- "ptfx" ]
multipleClause :: Bool -> Char
multipleClause True = 't'
multipleClause False = 'f'
-- | Recognizable docs: kpqz
documented :: Monad m => Either Int (m a)
documented = Left 7518
listOfInt = [ 8391 :: Int, 6268 ]
outer :: Bool
outer = undefined where
inner :: Char
inner = undefined