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

Parse out Go imports a bit more

This commit is contained in:
Timothy Clem 2018-01-25 11:45:20 -08:00
parent 479606fb35
commit 5920b0fd10

View File

@ -121,8 +121,12 @@ instance CustomHasDeclaration Declaration.Class where
instance CustomHasDeclaration Declaration.Import where
customToDeclaration blob@Blob{..} ann decl@(Declaration.Import (Term (In fromAnn _), _) (Term (In aliasAnn _), _) _)
= Just $ ImportDeclaration (getSource fromAnn) (getSource aliasAnn) (getImportSource blob (In ann decl)) blobLanguage
where getSource = toText . flip Source.slice blobSource . getField
| blobLanguage == Just Go
, getSource aliasAnn == "" = let i = getSource fromAnn in Just $ ImportDeclaration i (goLangDefaultAlias i) (getImportSource blob (In ann decl)) blobLanguage
| otherwise = Just $ ImportDeclaration (getSource fromAnn) (getSource aliasAnn) (getImportSource blob (In ann decl)) blobLanguage
where
goLangDefaultAlias = last . T.splitOn "/"
getSource = T.dropAround (== '"') . toText . flip Source.slice blobSource . getField
instance CustomHasDeclaration Expression.Call where
customToDeclaration Blob{..} _ (Expression.Call _ (Term (In fromAnn fromF), _) _ _)