mirror of
https://github.com/github/semantic.git
synced 2024-12-23 23:11:50 +03:00
Transition back to our language enum
This commit is contained in:
parent
f14412fe8f
commit
61319cdc2c
@ -161,7 +161,7 @@ enum Language {
|
||||
message Blob {
|
||||
string content = 1;
|
||||
string path = 2;
|
||||
string scope = 3;
|
||||
Language language = 3;
|
||||
}
|
||||
|
||||
message BlobPair {
|
||||
|
@ -6,7 +6,6 @@ module Data.Language
|
||||
, extensionsForLanguage
|
||||
, knownLanguage
|
||||
, languageForFilePath
|
||||
, languageForScope
|
||||
, languageForType
|
||||
) where
|
||||
|
||||
@ -136,24 +135,6 @@ languageForType mediaType = case mediaType of
|
||||
".phpt" -> PHP
|
||||
_ -> 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 = case language of
|
||||
Go -> [".go"]
|
||||
|
@ -9,7 +9,6 @@ module Semantic.API.Helpers
|
||||
|
||||
import Data.Bifunctor.Join
|
||||
import qualified Data.Blob as Data
|
||||
import Data.Language (languageForScope)
|
||||
import Data.Source (fromText)
|
||||
import qualified Data.Span as Data
|
||||
import qualified Data.Text as T
|
||||
@ -33,7 +32,7 @@ toChangeType = \case
|
||||
_ -> API.None
|
||||
|
||||
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 (Just before) (Just after)) = Join (These (apiBlobToBlob before) (apiBlobToBlob after))
|
||||
|
@ -94,7 +94,7 @@ data Blob
|
||||
= Blob
|
||||
{ content :: T.Text
|
||||
, path :: FilePath
|
||||
, scope :: String
|
||||
, language :: Language
|
||||
}
|
||||
deriving stock (Eq, Show, Generic)
|
||||
deriving anyclass (Message, Named, FromJSON)
|
||||
|
Loading…
Reference in New Issue
Block a user