mirror of
https://github.com/github/semantic.git
synced 2025-01-07 07:58:12 +03:00
contextualize comments around callSignatureParts
This commit is contained in:
parent
27979eb2e8
commit
e1bb4b741b
@ -26,6 +26,7 @@ import qualified Data.Term as Term
|
|||||||
import Data.List.NonEmpty (some1)
|
import Data.List.NonEmpty (some1)
|
||||||
import Data.Function (on)
|
import Data.Function (on)
|
||||||
import Data.Foldable (toList)
|
import Data.Foldable (toList)
|
||||||
|
import Data.List.NonEmpty (nonEmpty)
|
||||||
|
|
||||||
-- | The type of TypeScript syntax.
|
-- | The type of TypeScript syntax.
|
||||||
type 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)
|
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 :: 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 :: Assignment
|
||||||
callSignature = makeTerm <$> symbol Grammar.CallSignature <*> children (TypeScript.Syntax.CallSignature <$> (fromMaybe <$> emptyTerm <*> optional (term typeParameters)) <*> formalParameters <*> (fromMaybe <$> emptyTerm <*> optional (term typeAnnotation')))
|
callSignature = makeTerm <$> symbol Grammar.CallSignature <*> children (TypeScript.Syntax.CallSignature <$> (fromMaybe <$> emptyTerm <*> optional (term typeParameters)) <*> formalParameters <*> (fromMaybe <$> emptyTerm <*> optional (term typeAnnotation')))
|
||||||
|
Loading…
Reference in New Issue
Block a user