mirror of
https://github.com/github/semantic.git
synced 2024-12-21 13:51:44 +03:00
Don’t call toTermName for Pure nodes.
This commit is contained in:
parent
a3ac8c308a
commit
58ed93f559
@ -90,7 +90,7 @@ diffTOC blobs = removeDupes . diffToTOCSummaries >=> toJSONSummaries
|
||||
Pure patch -> fmap summarize (sequenceA (runBothWith mapPatch (toInfo . source <$> blobs) patch))
|
||||
|
||||
toInfo :: HasDefaultFields fields => Source -> Term (Syntax Text) (Record fields) -> [DiffInfo]
|
||||
toInfo source = para $ \ (annotation :< syntax) -> let termName = toTermName source (cofree (annotation :< fmap fst syntax)) in case syntax of
|
||||
toInfo source = para $ \ (annotation :< syntax) -> let termName = fromMaybe (textFor source (byteRange annotation)) (identifierFor (textFor source . termRange) (Just . unwrap) syntax) in case syntax of
|
||||
S.ParseError{} -> [DiffInfo Nothing termName (sourceSpan annotation)]
|
||||
S.Indexed{} -> foldMap snd syntax
|
||||
S.Fixed{} -> foldMap snd syntax
|
||||
@ -134,16 +134,6 @@ toJSONSummaries TOCSummary{..} = case infoCategory of
|
||||
_ -> maybe [] (pure . JSONSummary) parentInfo
|
||||
where DiffInfo{..} = afterOrBefore summaryPatch
|
||||
|
||||
toTermName :: HasDefaultFields fields => Source -> Term (Syntax Text) (Record fields) -> Text
|
||||
toTermName source = para $ \ (annotation :< syntax) -> case syntax of
|
||||
S.Function (_, identifier) _ _ -> identifier
|
||||
S.Method _ (_, identifier) Nothing _ _ -> identifier
|
||||
S.Method _ (_, identifier) (Just (receiver, receiverSource)) _ _
|
||||
| S.Indexed [receiverParams] <- unwrap receiver
|
||||
, S.ParameterDecl (Just ty) _ <- unwrap receiverParams -> "(" <> toTermName source ty <> ") " <> identifier
|
||||
| otherwise -> receiverSource <> "." <> identifier
|
||||
_ -> toText (Source.slice (byteRange annotation) source)
|
||||
|
||||
-- The user-facing category name
|
||||
toCategoryName :: Category -> Text
|
||||
toCategoryName category = case category of
|
||||
|
Loading…
Reference in New Issue
Block a user