1
1
mirror of https://github.com/github/semantic.git synced 2024-12-27 17:05:33 +03:00

slice/firstLine are total.

This commit is contained in:
Rob Rix 2019-09-27 11:33:13 -04:00
parent bbb583de55
commit 65eed49ecc
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -46,13 +46,13 @@ contextualizing Blob{..} symbolsToSummarize = Streaming.mapMaybeM $ \case
Exit x r -> Nothing <$ exitScope (x, r) Exit x r -> Nothing <$ exitScope (x, r)
Iden iden span docsLiteralRange -> get @[ContextToken] >>= pure . \case Iden iden span docsLiteralRange -> get @[ContextToken] >>= pure . \case
((x, r):("Context", cr):_) | x `elem` symbolsToSummarize ((x, r):("Context", cr):_) | x `elem` symbolsToSummarize
-> Just $ Tag iden x span (firstLine (slice (Just r))) (slice (Just cr)) -> Just $ Tag iden x span (Just (firstLine (slice r))) (Just (slice cr))
((x, r):_) | x `elem` symbolsToSummarize ((x, r):_) | x `elem` symbolsToSummarize
-> Just $ Tag iden x span (firstLine (slice (Just r))) (slice docsLiteralRange) -> Just $ Tag iden x span (Just (firstLine (slice r))) (slice <$> docsLiteralRange)
_ -> Nothing _ -> Nothing
where where
slice = fmap (stripEnd . Source.toText . Source.slice blobSource) slice = stripEnd . Source.toText . Source.slice blobSource
firstLine = fmap (T.take 180 . fst . breakOn "\n") firstLine = T.take 180 . fst . breakOn "\n"
enterScope, exitScope :: ( Member (State [ContextToken]) sig enterScope, exitScope :: ( Member (State [ContextToken]) sig
, Carrier sig m , Carrier sig m