mirror of
https://github.com/github/semantic.git
synced 2024-12-24 15:35:14 +03:00
Move languageForType to Language
This commit is contained in:
parent
4a5c844f34
commit
f45fd562a1
@ -1,6 +1,7 @@
|
|||||||
module Parsers (parserForType, Parser, lineByLineParser) where
|
module Parsers (parserForType, Parser, lineByLineParser) where
|
||||||
|
|
||||||
import Diff
|
import Diff
|
||||||
|
import Language
|
||||||
import Range
|
import Range
|
||||||
import Parser
|
import Parser
|
||||||
import Source hiding ((++))
|
import Source hiding ((++))
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
module Language where
|
module Language where
|
||||||
|
|
||||||
|
import Data.Text
|
||||||
|
|
||||||
-- | A programming language.
|
-- | A programming language.
|
||||||
data Language =
|
data Language =
|
||||||
C
|
C
|
||||||
| JavaScript
|
| 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
|
||||||
|
@ -9,7 +9,6 @@ import qualified Data.Set as Set
|
|||||||
import Foreign
|
import Foreign
|
||||||
import Foreign.C
|
import Foreign.C
|
||||||
import Foreign.C.Types
|
import Foreign.C.Types
|
||||||
import qualified Data.Text as T
|
|
||||||
import Foreign.CStorable
|
import Foreign.CStorable
|
||||||
import qualified GHC.Generics as Generics
|
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_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
|
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.
|
-- | Returns the TreeSitter language for the given language.
|
||||||
grammarForLanguage :: Language -> Maybe (Ptr TSLanguage)
|
grammarForLanguage :: Language -> Maybe (Ptr TSLanguage)
|
||||||
grammarForLanguage language = case language of
|
grammarForLanguage language = case language of
|
||||||
|
Loading…
Reference in New Issue
Block a user