1
1
mirror of https://github.com/github/semantic.git synced 2024-12-29 18:06:14 +03:00

Extract the declaration getter to the top level.

This commit is contained in:
Rob Rix 2017-06-05 11:53:49 -04:00
parent 977d459995
commit 41e6180e7b

View File

@ -78,6 +78,9 @@ data Declaration
| ErrorDeclaration { declarationIdentifier :: Text }
deriving (Eq, Generic, NFData, Show)
getDeclaration :: HasField fields (Maybe Declaration) => Record fields -> Maybe Declaration
getDeclaration = getField
-- | Produce the annotations of nodes representing declarations.
declaration :: (HasField fields (Maybe Declaration), HasField fields Category) => TermF f (Record fields) a -> Maybe (Record fields)
declaration (annotation :< _) = annotation <$ (getField annotation :: Maybe Declaration)
@ -145,8 +148,6 @@ dedupe = foldl' go []
similarMatch a b = sameCategory a b && similarDeclaration a b
sameCategory = (==) `on` category
similarDeclaration = (==) `on` fmap (toLower . declarationIdentifier) . getDeclaration
getDeclaration :: HasField fields (Maybe Declaration) => Record fields -> Maybe Declaration
getDeclaration = getField
-- | Construct a 'JSONSummary' from an 'Entry'. Returns 'Nothing' for 'Unchanged' patches.
entrySummary :: (HasField fields Category, HasField fields (Maybe Declaration), HasField fields SourceSpan) => Entry (Record fields) -> Maybe JSONSummary