1
1
mirror of https://github.com/github/semantic.git synced 2024-12-21 22:01:46 +03:00

Define a function selecting the annotations of nodes representing declarations.

This commit is contained in:
Rob Rix 2017-05-10 11:58:08 -04:00
parent fdcf96cd4c
commit 63482dc151

View File

@ -7,6 +7,7 @@ module Renderer.TOC
, isErrorSummary , isErrorSummary
, Declaration(..) , Declaration(..)
, DeclarationType(..) , DeclarationType(..)
, declaration
, Entry(..) , Entry(..)
, tableOfContentsBy , tableOfContentsBy
) where ) where
@ -71,6 +72,12 @@ data Declaration = Declaration { declarationIdentifier :: Text, declarationType
data DeclarationType = Method | Function | Class data DeclarationType = Method | Function | Class
deriving (Eq, Show) deriving (Eq, Show)
declaration :: HasField fields (Maybe Declaration) => TermF (Syntax Text) (Record fields) a -> Maybe (Record fields)
declaration (annotation :< syntax) | S.Method{} <- syntax = Just annotation
| S.Function{} <- syntax = Just annotation
| otherwise = Nothing
-- | An entry in a table of contents. -- | An entry in a table of contents.
data Entry a data Entry a
= Unchanged a -- ^ An entry for an unchanged portion of a diff (i.e. a diff node not containing any patches). = Unchanged a -- ^ An entry for an unchanged portion of a diff (i.e. a diff node not containing any patches).