1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 23:11:50 +03:00

Move languageForType to Language

This commit is contained in:
Matt Diephouse 2016-02-10 14:32:11 -08:00
parent 4a5c844f34
commit f45fd562a1
3 changed files with 11 additions and 9 deletions

View File

@ -1,6 +1,7 @@
module Parsers (parserForType, Parser, lineByLineParser) where
import Diff
import Language
import Range
import Parser
import Source hiding ((++))

View File

@ -1,6 +1,16 @@
module Language where
import Data.Text
-- | A programming language.
data Language =
C
| JavaScript
-- | Returns a Language based on the file extension (including the ".").
languageForType :: Text -> Maybe Language
languageForType mediaType = case mediaType of
".h" -> Just C
".c" -> Just C
".js" -> Just JavaScript
_ -> Nothing

View File

@ -9,7 +9,6 @@ import qualified Data.Set as Set
import Foreign
import Foreign.C
import Foreign.C.Types
import qualified Data.Text as T
import Foreign.CStorable
import qualified GHC.Generics as Generics
@ -41,14 +40,6 @@ foreign import ccall "app/bridge.h ts_node_p_named_child" ts_node_p_named_child
foreign import ccall "app/bridge.h ts_node_p_start_char" ts_node_p_start_char :: Ptr TSNode -> CSize
foreign import ccall "app/bridge.h ts_node_p_end_char" ts_node_p_end_char :: Ptr TSNode -> CSize
-- | Returns a Language based on the file extension (including the ".").
languageForType :: T.Text -> Maybe Language
languageForType mediaType = case mediaType of
".h" -> Just C
".c" -> Just C
".js" -> Just JavaScript
_ -> Nothing
-- | Returns the TreeSitter language for the given language.
grammarForLanguage :: Language -> Maybe (Ptr TSLanguage)
grammarForLanguage language = case language of