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

Special Ruby handling for now

This commit is contained in:
Timothy Clem 2018-01-26 13:55:44 -08:00
parent 35b4776b50
commit be33451563

View File

@ -130,11 +130,12 @@ instance CustomHasDeclaration whole Declaration.Class where
instance (Declaration.ImportSymbol :< fs) => CustomHasDeclaration (Union fs) Declaration.Import where
customToDeclaration Blob{..} _ (Declaration.Import (Term (In fromAnn _), _) (Term (In aliasAnn _), _) symbols)
= Just $ ImportDeclaration name (getAlias (getSource aliasAnn)) (mapMaybe getSymbol symbols) blobLanguage
= Just $ ImportDeclaration name (getAlias blobLanguage (getSource aliasAnn)) (mapMaybe getSymbol symbols) blobLanguage
where
name = getSource fromAnn
getAlias alias | T.null alias = basename name
| otherwise = alias
getAlias lang alias | Just Ruby <- lang, T.null alias = alias
| T.null alias = basename name
| otherwise = alias
basename = last . T.splitOn "/"
getSource = T.dropAround (`elem` ['"', '\'']) . toText . flip Source.slice blobSource . getField
getSymbol (Term (In _ f), _) | Just (Declaration.ImportSymbol (Term (In nameAnn _)) (Term (In aliasAnn _))) <- prj f