1
1
mirror of https://github.com/github/semantic.git synced 2024-11-27 03:09:48 +03:00

Remove legacy types entirely

This commit is contained in:
Timothy Clem 2020-06-04 11:24:17 -07:00
parent acc1fa421d
commit cf636f7e97
3 changed files with 0 additions and 80 deletions

View File

@ -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

View File

@ -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

View File

@ -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)