1
1
mirror of https://github.com/github/semantic.git synced 2024-12-21 05:41:54 +03:00

Combine the code paths.

This commit is contained in:
Rob Rix 2019-10-01 12:01:04 -04:00
parent 44b0614c7d
commit 7259059b51
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -69,19 +69,16 @@ parseSymbols blobs = do
go modes blob@Blob{..}
| Precise <- pythonMode modes
, Python <- blobLanguage'
= catching $ renderPreciseToSymbols <$> parse precisePythonParser blob
| otherwise = catching $ withSomeTerm renderToSymbols <$> doParse blob
= catching $ renderToSymbols <$> parse precisePythonParser blob
| otherwise = catching $ withSomeTerm (renderToSymbols . ALaCarteTerm (blobLanguage blob)) <$> doParse blob
where
catching m = m `catchError` (\(SomeException e) -> pure $ errorFile (show e))
blobLanguage' = blobLanguage blob
blobPath' = pack $ blobPath blob
errorFile e = File blobPath' (bridging # blobLanguage') mempty (V.fromList [ParseError (T.pack e)]) blobOid
renderToSymbols :: IsTaggable f => Term f Loc -> File
renderToSymbols term = renderPreciseToSymbols (ALaCarteTerm (blobLanguage blob) term)
renderPreciseToSymbols :: Precise.ToTags t => t Loc -> File
renderPreciseToSymbols term = tagsToFile (Precise.tags blobSource term)
renderToSymbols :: Precise.ToTags t => t Loc -> File
renderToSymbols term = tagsToFile (Precise.tags blobSource term)
tagsToFile :: [Tag] -> File
tagsToFile tags = File blobPath' (bridging # blobLanguage') (V.fromList (fmap tagToSymbol tags)) mempty blobOid