1
1
mirror of https://github.com/github/semantic.git synced 2024-12-27 00:44:57 +03:00

ContextTokens always have Ranges.

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

View File

@ -32,7 +32,7 @@ runTagging blob symbolsToSummarize
. contextualizing blob symbolsToSummarize
. tagging blob
type ContextToken = (Text, Maybe Range)
type ContextToken = (Text, Range)
contextualizing :: ( Member (State [ContextToken]) sig
, Carrier sig m
@ -42,13 +42,13 @@ contextualizing :: ( Member (State [ContextToken]) sig
-> Stream (Of Token) m a
-> Stream (Of Tag) m a
contextualizing Blob{..} symbolsToSummarize = Streaming.mapMaybeM $ \case
Enter x r -> Nothing <$ enterScope (x, Just r)
Exit x r -> Nothing <$ exitScope (x, Just r)
Enter x r -> Nothing <$ enterScope (x, r)
Exit x r -> Nothing <$ exitScope (x, r)
Iden iden span docsLiteralRange -> get @[ContextToken] >>= pure . \case
((x, r):("Context", cr):_) | x `elem` symbolsToSummarize
-> Just $ Tag iden x span (firstLine (slice r)) (slice cr)
-> Just $ Tag iden x span (firstLine (slice (Just r))) (slice (Just cr))
((x, r):_) | x `elem` symbolsToSummarize
-> Just $ Tag iden x span (firstLine (slice r)) (slice docsLiteralRange)
-> Just $ Tag iden x span (firstLine (slice (Just r))) (slice docsLiteralRange)
_ -> Nothing
where
slice = fmap (stripEnd . Source.toText . Source.slice blobSource)