1
1
mirror of https://github.com/github/semantic.git synced 2024-11-29 02:44:36 +03:00

JavaScript term assignment is (notionally) partial.

This commit is contained in:
Rob Rix 2017-01-20 13:47:06 -05:00
parent 2e7c4c2ac4
commit 45621eedd8
2 changed files with 3 additions and 3 deletions

View File

@ -17,7 +17,7 @@ termAssignment
-> Record '[Range, Category, SourceSpan] -- ^ The proposed annotation for the term.
-> [ SyntaxTerm Text '[Range, Category, SourceSpan] ] -- ^ The child nodes of the term.
-> IO [ SyntaxTerm Text '[Range, Category, SourceSpan] ] -- ^ All child nodes (included unnamed productions) of the term as 'IO'. Only use this if you need it.
-> IO (SyntaxTerm Text '[Range, Category, SourceSpan]) -- ^ The resulting term, in IO.
-> IO (Maybe (SyntaxTerm Text '[Range, Category, SourceSpan])) -- ^ The resulting term, in IO.
termAssignment source (range :. category :. sourceSpan :. Nil) children allChildren
| category == Error = withDefaultInfo (S.Error children)
| category `elem` operators = do
@ -102,7 +102,7 @@ termAssignment source (range :. category :. sourceSpan :. Nil) children allChild
_ -> S.Indexed children
where
withDefaultInfo syntax =
pure $! case syntax of
pure $! Just $ case syntax of
S.MethodCall{} -> cofree ((range :. MethodCall :. sourceSpan :. Nil) :< syntax)
_ -> cofree ((range :. category :. sourceSpan :. Nil) :< syntax)

View File

@ -76,7 +76,7 @@ assignTerm language source annotation children allChildren = do
_ -> cofree (annotation :< defaultTermAssignment source (category annotation) children)
where assignTermByLanguage :: Language -> Source Char -> Record '[Range, Category, SourceSpan] -> [ SyntaxTerm Text '[ Range, Category, SourceSpan ] ] -> IO [ SyntaxTerm Text '[ Range, Category, SourceSpan ] ] -> IO (Maybe (SyntaxTerm Text '[ Range, Category, SourceSpan ]))
assignTermByLanguage = \case
JavaScript -> (fmap . fmap . fmap $ fmap Just) . JS.termAssignment
JavaScript -> JS.termAssignment
C -> C.termAssignment
Language.Go -> (fmap . fmap . fmap $ fmap Just) . Go.termAssignment
Ruby -> Ruby.termAssignment