From d166c752bc3a2a640968722a68d38460cb3b9779 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Tue, 14 Jan 2020 14:05:08 -0800 Subject: [PATCH] Sort out a la carte source line trimming --- src/Tags/Tagging.hs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Tags/Tagging.hs b/src/Tags/Tagging.hs index 12de5b4e2..ed9b201ba 100644 --- a/src/Tags/Tagging.hs +++ b/src/Tags/Tagging.hs @@ -39,14 +39,14 @@ runTagging lang symbolsToSummarize source toKind x = do guard (x `elem` symbolsToSummarize) case x of - "Function" -> Just Function - "Method" -> Just Method - "Class" -> Just Class - "Module" -> Just Module - "Call" -> Just Call - "Send" -> Just Call -- Ruby’s Send is considered to be a kind of 'Call' + "Function" -> Just Function + "Method" -> Just Method + "Class" -> Just Class + "Module" -> Just Module + "Call" -> Just Call + "Send" -> Just Call -- Ruby’s Send is considered to be a kind of 'Call' "AmbientFunction" -> Just Function -- Classify TypeScript ambient functions as 'Function' - _ -> Nothing + _ -> Nothing type ContextToken = (Text, Range) @@ -60,12 +60,12 @@ contextualizing source toKind = Streaming.mapMaybeM $ \case Exit x r -> Nothing <$ exitScope (x, r) Iden iden loc docsLiteralRange -> fmap go (get @[ContextToken]) where go = \case - ((x, r):("Context", cr):_) | Just kind <- toKind x -> Just $ Tag iden kind loc (firstLine (slice r)) (Just (slice cr)) - ((x, r):_) | Just kind <- toKind x -> Just $ Tag iden kind loc (firstLine (slice r)) (slice <$> docsLiteralRange) + ((x, r):("Context", cr):_) | Just kind <- toKind x -> Just $ Tag iden kind loc (firstLine r) (Just (slice cr)) + ((x, r):_) | Just kind <- toKind x -> Just $ Tag iden kind loc (firstLine r) (slice <$> docsLiteralRange) _ -> Nothing where - slice = Source.toText . Source.slice source - firstLine = stripEnd . T.take 180 . fst . breakOn "\n" + slice = T.stripEnd . Source.toText . Source.slice source + firstLine = T.stripEnd . T.takeWhile (/= '\n') . Source.toText . Source.take 180 . Source.slice source enterScope, exitScope :: Has (State [ContextToken]) sig m => ContextToken