1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 16:02:43 +03:00

Store Name and Span in Located

This commit is contained in:
Timothy Clem 2018-07-20 09:34:18 -07:00
parent 89ca32661e
commit c9502add3f
2 changed files with 6 additions and 3 deletions

View File

@ -34,11 +34,11 @@ instance Member NonDet effects => Addressable Monovariant effects where
derefCell _ = traverse (foldMapA pure) . nonEmpty . toList derefCell _ = traverse (foldMapA pure) . nonEmpty . toList
-- | 'Located' addresses allocate & dereference using the underlying address, contextualizing addresses with the current 'PackageInfo' & 'ModuleInfo'. -- | 'Located' addresses allocate & dereference using the underlying address, contextualizing addresses with the current 'PackageInfo' & 'ModuleInfo'.
instance (Addressable address effects, Member (Reader ModuleInfo) effects, Member (Reader PackageInfo) effects) => Addressable (Located address) effects where instance (Addressable address effects, Member (Reader ModuleInfo) effects, Member (Reader PackageInfo) effects, Member (Reader Span) effects) => Addressable (Located address) effects where
type Cell (Located address) = Cell address type Cell (Located address) = Cell address
allocCell name = relocate (Located <$> allocCell name <*> currentPackage <*> currentModule) allocCell name = relocate (Located <$> allocCell name <*> currentPackage <*> currentModule <*> pure name <*> ask)
derefCell (Located loc _ _) = relocate . derefCell loc derefCell (Located loc _ _ _ _) = relocate . derefCell loc
instance (Addressable address effects, Ord context, Show context) => Addressable (Hole context address) effects where instance (Addressable address effects, Ord context, Show context) => Addressable (Hole context address) effects where
type Cell (Hole context address) = Cell address type Cell (Hole context address) = Cell address

View File

@ -12,6 +12,7 @@ import Data.Abstract.Name
import Data.Abstract.Package (PackageInfo) import Data.Abstract.Package (PackageInfo)
import Data.Monoid (Last(..)) import Data.Monoid (Last(..))
import Data.Semigroup.Reducer import Data.Semigroup.Reducer
import Data.Span
import Data.Set as Set import Data.Set as Set
import Prologue import Prologue
@ -35,6 +36,8 @@ data Located address = Located
{ address :: address { address :: address
, addressPackage :: {-# UNPACK #-} !PackageInfo , addressPackage :: {-# UNPACK #-} !PackageInfo
, addressModule :: !ModuleInfo , addressModule :: !ModuleInfo
, addressName :: Name
, addressSpan :: Span
} }
deriving (Eq, Ord, Show) deriving (Eq, Ord, Show)