1{-# LANGUAGE DeriveAnyClass        #-}
2{-# LANGUAGE DeriveGeneric         #-}
3{-# LANGUAGE DuplicateRecordFields #-}
4
5module Ide.Plugin.CallHierarchy.Types where
6
7import           Data.Aeson
8import           Database.SQLite.Simple
9import           Database.SQLite.Simple.ToField
10import           GHC.Generics
11
12data Vertex = Vertex {
13  mod    :: String
14, occ    :: String
15, hieSrc :: FilePath
16, sl     :: Int
17, sc     :: Int
18, el     :: Int
19, ec     :: Int
20, casl   :: Int -- sl for call appear
21, casc   :: Int -- sc for call appear
22, cael   :: Int -- el for call appear
23, caec   :: Int -- ec for call appear
24} deriving (Eq, Show, Generic, FromJSON, ToJSON)
25
26instance ToRow Vertex where
27  toRow (Vertex a b c d e f g h i j k) =
28    [ toField a, toField b, toField c, toField d
29    , toField e, toField f, toField g, toField h
30    , toField i, toField j, toField k
31    ]
32
33instance FromRow Vertex where
34  fromRow = Vertex <$> field <*> field <*> field
35                   <*> field <*> field <*> field
36                   <*> field <*> field <*> field
37                   <*> field <*> field
38
39data SymbolPosition = SymbolPosition {
40  psl :: Int
41, psc :: Int
42} deriving (Eq, Show, Generic, FromJSON, ToJSON)
43
44instance ToRow SymbolPosition where
45  toRow (SymbolPosition a b) = toRow (a, b)
46
47instance FromRow SymbolPosition where
48  fromRow = SymbolPosition <$> field <*> field
49