1
1
mirror of https://github.com/github/semantic.git synced 2024-12-24 15:35:14 +03:00

Transition back to our language enum

This commit is contained in:
Timothy Clem 2019-01-31 13:11:55 -08:00
parent f14412fe8f
commit 61319cdc2c
4 changed files with 3 additions and 23 deletions

View File

@ -161,7 +161,7 @@ enum Language {
message Blob { message Blob {
string content = 1; string content = 1;
string path = 2; string path = 2;
string scope = 3; Language language = 3;
} }
message BlobPair { message BlobPair {

View File

@ -6,7 +6,6 @@ module Data.Language
, extensionsForLanguage , extensionsForLanguage
, knownLanguage , knownLanguage
, languageForFilePath , languageForFilePath
, languageForScope
, languageForType , languageForType
) where ) where
@ -136,24 +135,6 @@ languageForType mediaType = case mediaType of
".phpt" -> PHP ".phpt" -> PHP
_ -> Unknown _ -> Unknown
-- | Returns a Language for a TextMate Scope.
languageForScope :: String -> Language
languageForScope = \case
"source.gfm" -> Markdown
"source.go" -> Go
"source.haskell" -> Haskell
"source.java" -> Java
"source.js.jsx" -> JSX
"source.js" -> TypeScript
"source.json" -> JSON
"source.md" -> Markdown
"source.php" -> PHP
"source.python" -> Python
"source.ruby" -> Ruby
"source.ts" -> TypeScript
"source.tsx" -> TypeScript
_ -> Unknown
extensionsForLanguage :: Language -> [String] extensionsForLanguage :: Language -> [String]
extensionsForLanguage language = case language of extensionsForLanguage language = case language of
Go -> [".go"] Go -> [".go"]

View File

@ -9,7 +9,6 @@ module Semantic.API.Helpers
import Data.Bifunctor.Join import Data.Bifunctor.Join
import qualified Data.Blob as Data import qualified Data.Blob as Data
import Data.Language (languageForScope)
import Data.Source (fromText) import Data.Source (fromText)
import qualified Data.Span as Data import qualified Data.Span as Data
import qualified Data.Text as T import qualified Data.Text as T
@ -33,7 +32,7 @@ toChangeType = \case
_ -> API.None _ -> API.None
apiBlobToBlob :: API.Blob -> Data.Blob apiBlobToBlob :: API.Blob -> Data.Blob
apiBlobToBlob API.Blob{..} = Data.Blob (fromText content) path (languageForScope scope) apiBlobToBlob API.Blob{..} = Data.Blob (fromText content) path language
apiBlobPairToBlobPair :: API.BlobPair -> Data.BlobPair apiBlobPairToBlobPair :: API.BlobPair -> Data.BlobPair
apiBlobPairToBlobPair (API.BlobPair (Just before) (Just after)) = Join (These (apiBlobToBlob before) (apiBlobToBlob after)) apiBlobPairToBlobPair (API.BlobPair (Just before) (Just after)) = Join (These (apiBlobToBlob before) (apiBlobToBlob after))

View File

@ -94,7 +94,7 @@ data Blob
= Blob = Blob
{ content :: T.Text { content :: T.Text
, path :: FilePath , path :: FilePath
, scope :: String , language :: Language
} }
deriving stock (Eq, Show, Generic) deriving stock (Eq, Show, Generic)
deriving anyclass (Message, Named, FromJSON) deriving anyclass (Message, Named, FromJSON)