From cf636f7e978ed1ecb4300b4d7d9fdc2acbf72978 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Thu, 4 Jun 2020 11:24:17 -0700 Subject: [PATCH] Remove legacy types entirely --- semantic.cabal | 1 - src/Semantic/Api/Bridge.hs | 11 ------ src/Semantic/Api/LegacyTypes.hs | 68 --------------------------------- 3 files changed, 80 deletions(-) delete mode 100644 src/Semantic/Api/LegacyTypes.hs diff --git a/semantic.cabal b/semantic.cabal index 5f626d139..df86f9187 100644 --- a/semantic.cabal +++ b/semantic.cabal @@ -217,7 +217,6 @@ library , Semantic.Api , Semantic.Api.Bridge , Semantic.Api.Diffs - , Semantic.Api.LegacyTypes , Semantic.Api.StackGraph , Semantic.Api.Symbols , Semantic.Api.Terms diff --git a/src/Semantic/Api/Bridge.hs b/src/Semantic/Api/Bridge.hs index 32f388fd0..eb558724c 100644 --- a/src/Semantic/Api/Bridge.hs +++ b/src/Semantic/Api/Bridge.hs @@ -18,7 +18,6 @@ import qualified Data.Text as T import Data.Text.Lens import qualified Proto.Semantic as API import Proto.Semantic_Fields as P hiding (to) -import qualified Semantic.Api.LegacyTypes as Legacy import qualified Source.Source as Source (fromText, toText, totalSpan) import qualified Source.Span as Source import qualified System.Path as Path @@ -52,11 +51,6 @@ class APIConvert api native | api -> native where rev #? item = item ^? re rev infixr 8 #? -instance APIBridge Legacy.Position Source.Pos where - bridging = iso fromAPI toAPI where - toAPI Source.Pos{..} = Legacy.Position line column - fromAPI Legacy.Position{..} = Source.Pos line column - instance APIBridge API.Position Source.Pos where bridging = iso fromAPI toAPI where toAPI Source.Pos{..} = defMessage & P.line .~ fromIntegral line & P.column .~ fromIntegral column @@ -67,11 +61,6 @@ instance APIConvert API.Span Source.Span where toAPI Source.Span{..} = defMessage & P.maybe'start .~ (bridging #? start) & P.maybe'end .~ (bridging #? end) fromAPI span = Source.Span <$> (span^.maybe'start >>= preview bridging) <*> (span^.maybe'end >>= preview bridging) -instance APIConvert Legacy.Span Source.Span where - converting = prism' toAPI fromAPI where - toAPI Source.Span{..} = Legacy.Span (bridging #? start) (bridging #? end) - fromAPI Legacy.Span {..} = Source.Span <$> (start >>= preview bridging) <*> (end >>= preview bridging) - instance APIBridge T.Text Data.Language where bridging = iso Data.textToLanguage Data.languageToText diff --git a/src/Semantic/Api/LegacyTypes.hs b/src/Semantic/Api/LegacyTypes.hs deleted file mode 100644 index c166dfe78..000000000 --- a/src/Semantic/Api/LegacyTypes.hs +++ /dev/null @@ -1,68 +0,0 @@ -{-# LANGUAGE DeriveAnyClass #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE DerivingVia #-} -{-# LANGUAGE DuplicateRecordFields #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RecordWildCards #-} -module Semantic.Api.LegacyTypes - ( ParseTreeRequest(..) - , ParseTreeSymbolResponse(..) - , File(..) - , Symbol(..) - , Span(..) - , Position(..) - ) where - -import Data.Aeson -import Data.Blob -import Data.Text (Text) -import GHC.Generics (Generic) - --- --- Legacy Symbols API --- - -newtype ParseTreeRequest = ParseTreeRequest { blobs :: [Blob] } - deriving (Eq, Show, Generic, FromJSON) - -newtype ParseTreeSymbolResponse = ParseTreeSymbolResponse { files :: [File] } - deriving (Eq, Show, Generic, ToJSON) - -data File = File - { filePath :: Text - , fileLanguage :: Text - , fileSymbols :: [Symbol] - } - deriving (Eq, Show, Generic) - -instance ToJSON File where - toJSON File{..} - = object [ "path" .= filePath - , "language" .= fileLanguage - , "symbols" .= fileSymbols - ] - -data Symbol = Symbol - { symbolName :: Text - , symbolKind :: Text - , symbolLine :: Text - , symbolSpan :: Maybe Span - } - deriving (Generic, Eq, Show) - -instance ToJSON Symbol where - toJSON Symbol{..} - = object [ "symbol" .= symbolName - , "kind" .= symbolKind - , "line" .= symbolLine - , "span" .= symbolSpan - ] - -data Position = Position { line :: Int, column :: Int } - deriving (Eq, Ord, Show, Generic) - -instance ToJSON Position - where toJSON Position{..} = toJSON [line, column] - -data Span = Span { start :: Maybe Position, end :: Maybe Position } - deriving (Eq, Ord, Show, Generic, ToJSON)