1
1
mirror of https://github.com/github/semantic.git synced 2025-01-09 00:56:32 +03:00

Revert "Do language specific formatting in renderer"

This reverts commit 562a9d2321376ba51f4e079ddaffa7e5e9390c85.
This commit is contained in:
Timothy Clem 2018-01-26 13:33:54 -08:00
parent bea7b35530
commit d556408898
2 changed files with 5 additions and 7 deletions

View File

@ -130,12 +130,15 @@ instance CustomHasDeclaration whole Declaration.Class where
instance (Declaration.ImportSymbol :< fs) => CustomHasDeclaration (Union fs) Declaration.Import where instance (Declaration.ImportSymbol :< fs) => CustomHasDeclaration (Union fs) Declaration.Import where
customToDeclaration Blob{..} _ (Declaration.Import (Term (In fromAnn _), _) (Term (In aliasAnn _), _) symbols) customToDeclaration Blob{..} _ (Declaration.Import (Term (In fromAnn _), _) (Term (In aliasAnn _), _) symbols)
= Just $ ImportDeclaration (getSource fromAnn) (getSource aliasAnn) (mapMaybe getSymbol symbols) blobLanguage | blobLanguage == Just Go
, T.null (getSource aliasAnn) = let i = getSource fromAnn in Just $ ImportDeclaration i (goLangDefaultAlias i) [] blobLanguage
| otherwise = Just $ ImportDeclaration (getSource fromAnn) (getSource aliasAnn) (mapMaybe getSymbol symbols) blobLanguage
where where
goLangDefaultAlias = last . T.splitOn "/"
getSource = T.dropAround (== '"') . toText . flip Source.slice blobSource . getField
getSymbol (Term (In _ f), _) | Just (Declaration.ImportSymbol (Term (In nameAnn _)) (Term (In aliasAnn _))) <- prj f getSymbol (Term (In _ f), _) | Just (Declaration.ImportSymbol (Term (In nameAnn _)) (Term (In aliasAnn _))) <- prj f
= Just (getSource nameAnn, getSource aliasAnn) = Just (getSource nameAnn, getSource aliasAnn)
| otherwise = Nothing | otherwise = Nothing
getSource = T.dropAround (== '"') . toText . flip Source.slice blobSource . getField
instance (Expression.MemberAccess :< fs) => CustomHasDeclaration (Union fs) Expression.Call where instance (Expression.MemberAccess :< fs) => CustomHasDeclaration (Union fs) Expression.Call where
customToDeclaration Blob{..} _ (Expression.Call _ (Term (In fromAnn fromF), _) _ _) customToDeclaration Blob{..} _ (Expression.Call _ (Term (In fromAnn fromF), _) _ _)

View File

@ -12,7 +12,6 @@ import Data.Blob
import Data.ByteString.Lazy (toStrict) import Data.ByteString.Lazy (toStrict)
import Data.Monoid import Data.Monoid
import Data.Maybe (mapMaybe) import Data.Maybe (mapMaybe)
import Data.Language as Language
import Data.Record import Data.Record
import Data.Output import Data.Output
import Data.Span import Data.Span
@ -73,12 +72,8 @@ declarationSummary record = case getDeclaration record of
importSummary :: (HasField fields (Maybe Declaration), HasField fields Span) => Record fields -> Maybe ImportStatement importSummary :: (HasField fields (Maybe Declaration), HasField fields Span) => Record fields -> Maybe ImportStatement
importSummary record = case getDeclaration record of importSummary record = case getDeclaration record of
Just ImportDeclaration{..} | Just Language.Go <- declarationLanguage
, T.null declarationAlias -> Just $ ImportStatement declarationIdentifier (goLangDefaultAlias declarationIdentifier) (uncurry ImportSymbol <$> declarationSymbols) (getField record)
Just ImportDeclaration{..} -> Just $ ImportStatement declarationIdentifier declarationAlias (uncurry ImportSymbol <$> declarationSymbols) (getField record) Just ImportDeclaration{..} -> Just $ ImportStatement declarationIdentifier declarationAlias (uncurry ImportSymbol <$> declarationSymbols) (getField record)
_ -> Nothing _ -> Nothing
where
goLangDefaultAlias = last . T.splitOn "/"
referenceSummary :: (HasField fields (Maybe Declaration), HasField fields Span) => Record fields -> Maybe CallExpression referenceSummary :: (HasField fields (Maybe Declaration), HasField fields Span) => Record fields -> Maybe CallExpression
referenceSummary record = case getDeclaration record of referenceSummary record = case getDeclaration record of