1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 22:31:36 +03:00

Have to check parentInfo for duplicates

This commit is contained in:
Timothy Clem 2017-02-14 08:27:00 -08:00
parent 2770540191
commit 8bc4da76c9

View File

@ -67,7 +67,7 @@ diffTOC :: (StringConv leaf Text, DefaultFields fields) => Both SourceBlob -> Sy
diffTOC blobs diff = removeDupes (diffToTOCSummaries (source <$> blobs) diff) >>= toJSONSummaries diffTOC blobs diff = removeDupes (diffToTOCSummaries (source <$> blobs) diff) >>= toJSONSummaries
where where
removeDupes :: [TOCSummary DiffInfo] -> [TOCSummary DiffInfo] removeDupes :: [TOCSummary DiffInfo] -> [TOCSummary DiffInfo]
removeDupes = foldl' (\xs x -> case (x `elem` xs, x `findSimilarSummaryIndex` xs) of removeDupes = foldl' (\xs x -> case (x `anyDuplicateSummary` xs, x `findSimilarSummaryIndex` xs) of
(True, Nothing) -> xs (True, Nothing) -> xs
(False, Nothing) -> xs <> [x] (False, Nothing) -> xs <> [x]
(_, Just n) -> (_, Just n) ->
@ -78,10 +78,10 @@ diffTOC blobs diff = removeDupes (diffToTOCSummaries (source <$> blobs) diff) >>
in in
a <> (replacement : b) a <> (replacement : b)
) [] ) []
anyDuplicateSummary a = List.any (\b -> parentInfo a == parentInfo b)
findSimilarSummaryIndex summary = List.findIndex (isSimilarSummary summary) findSimilarSummaryIndex summary = List.findIndex (isSimilarSummary summary)
isSimilarSummary a b = case (parentInfo a, parentInfo b) of isSimilarSummary a b = case (parentInfo a, parentInfo b) of
-- TODO: Only do this for methods in the same source file? (Summarizable catA nameA _ _, Summarizable catB nameB _ _) -> catA == catB && toLower nameA == toLower nameB
(Summarizable _ nameA _ _, Summarizable _ nameB _ _) -> toLower nameA == toLower nameB
(_, _) -> False (_, _) -> False
diffToTOCSummaries :: (StringConv leaf Text, DefaultFields fields) => Both Source -> SyntaxDiff leaf fields -> [TOCSummary DiffInfo] diffToTOCSummaries :: (StringConv leaf Text, DefaultFields fields) => Both Source -> SyntaxDiff leaf fields -> [TOCSummary DiffInfo]