1
1
mirror of https://github.com/github/semantic.git synced 2025-01-03 13:02:37 +03:00

contextualize comments around callSignatureParts

This commit is contained in:
joshvera 2017-10-31 19:59:44 -04:00
parent 27979eb2e8
commit e1bb4b741b

View File

@ -26,6 +26,7 @@ import qualified Data.Term as Term
import Data.List.NonEmpty (some1)
import Data.Function (on)
import Data.Foldable (toList)
import Data.List.NonEmpty (nonEmpty)
-- | The type of TypeScript syntax.
type Syntax = '[
@ -404,7 +405,15 @@ methodDefinition = makeMethod <$>
makeMethod loc (modifier, readonly, receiver, propertyName', (typeParameters', params, ty'), statements) = makeTerm loc (Declaration.Method [modifier, readonly, typeParameters', ty'] receiver propertyName' params statements)
callSignatureParts :: HasCallStack => Assignment.Assignment [] Grammar (Term, [Term], Term)
callSignatureParts = symbol Grammar.CallSignature *> children ((,,) <$> (fromMaybe <$> emptyTerm <*> optional (term typeParameters)) <*> formalParameters <*> (fromMaybe <$> emptyTerm <*> optional (term typeAnnotation')))
callSignatureParts = contextualize' <$> Assignment.manyThrough comment (postContextualize'
<$> (symbol Grammar.CallSignature *> children ((,,) <$> (fromMaybe <$> emptyTerm <*> optional (term typeParameters)) <*> formalParameters <*> (fromMaybe <$> emptyTerm <*> optional (term typeAnnotation')))) <*> many comment)
where
contextualize' (cs, (typeParams, formalParams, annotation)) = case nonEmpty cs of
Just cs -> (makeTerm1 (Syntax.Context cs typeParams), formalParams, annotation)
Nothing -> (typeParams, formalParams, annotation)
postContextualize' (typeParams, formalParams, annotation) cs = case nonEmpty cs of
Just cs -> (typeParams, formalParams, makeTerm1 (Syntax.Context cs annotation))
Nothing -> (typeParams, formalParams, annotation)
callSignature :: Assignment
callSignature = makeTerm <$> symbol Grammar.CallSignature <*> children (TypeScript.Syntax.CallSignature <$> (fromMaybe <$> emptyTerm <*> optional (term typeParameters)) <*> formalParameters <*> (fromMaybe <$> emptyTerm <*> optional (term typeAnnotation')))