mirror of
https://github.com/github/semantic.git
synced 2024-12-22 06:11:49 +03:00
Rename the entry field of Dedupe to change.
This commit is contained in:
parent
2d3f74f2b5
commit
5b452bf471
@ -1,4 +1,4 @@
|
|||||||
{-# LANGUAGE DerivingVia, RankNTypes, ScopedTypeVariables, TupleSections #-}
|
{-# LANGUAGE DerivingVia, DuplicateRecordFields, RankNTypes, ScopedTypeVariables, TupleSections #-}
|
||||||
module Rendering.TOC
|
module Rendering.TOC
|
||||||
( diffTOC
|
( diffTOC
|
||||||
, Summaries(..)
|
, Summaries(..)
|
||||||
@ -83,9 +83,9 @@ data DedupeKey = DedupeKey {-# UNPACK #-} !T.Text {-# UNPACK #-} !T.Text
|
|||||||
deriving (Eq, Ord)
|
deriving (Eq, Ord)
|
||||||
|
|
||||||
data Dedupe = Dedupe
|
data Dedupe = Dedupe
|
||||||
{ index :: {-# UNPACK #-} !Int
|
{ index :: {-# UNPACK #-} !Int
|
||||||
, entry :: {-# UNPACK #-} !Change
|
, change :: {-# UNPACK #-} !Change
|
||||||
, decl :: {-# UNPACK #-} !Declaration
|
, decl :: {-# UNPACK #-} !Declaration
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Dedupe entries in a final pass. This catches two specific scenarios with
|
-- Dedupe entries in a final pass. This catches two specific scenarios with
|
||||||
@ -96,11 +96,11 @@ data Dedupe = Dedupe
|
|||||||
-- identifiers) are in the list.
|
-- identifiers) are in the list.
|
||||||
-- Action: Combine them into a single Replaced entry.
|
-- Action: Combine them into a single Replaced entry.
|
||||||
dedupe :: [(Change, Declaration)] -> [(Change, Declaration)]
|
dedupe :: [(Change, Declaration)] -> [(Change, Declaration)]
|
||||||
dedupe = map (entry &&& decl) . sortOn index . Map.elems . foldl' go Map.empty . zipWith (uncurry . Dedupe) [0..] where
|
dedupe = map ((change :: Dedupe -> Change) &&& decl) . sortOn index . Map.elems . foldl' go Map.empty . zipWith (uncurry . Dedupe) [0..] where
|
||||||
go m d@(Dedupe _ _ decl) = let key = dedupeKey decl in case Map.lookup key m of
|
go m d@(Dedupe _ _ decl) = let key = dedupeKey decl in case Map.lookup key m of
|
||||||
Just (Dedupe _ _ similar)
|
Just (Dedupe _ _ similar)
|
||||||
| similar == decl -> m
|
| similar == decl -> m
|
||||||
| otherwise -> Map.insert key d { entry = Replaced, decl = similar } m
|
| otherwise -> Map.insert key d { change = Replaced, decl = similar } m
|
||||||
_ -> Map.insert key d m
|
_ -> Map.insert key d m
|
||||||
|
|
||||||
dedupeKey (Declaration kind ident _ _ _) = DedupeKey (formatKind kind) (T.toLower ident)
|
dedupeKey (Declaration kind ident _ _ _) = DedupeKey (formatKind kind) (T.toLower ident)
|
||||||
|
Loading…
Reference in New Issue
Block a user