mirror of
https://github.com/github/semantic.git
synced 2024-12-25 07:55:12 +03:00
Sort out a la carte source line trimming
This commit is contained in:
parent
7edad0f9ec
commit
d166c752bc
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user